// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/metrics/date_changed_helper.h" #include "base/time/time.h" #include "base/time/time_override.h" #include "components/prefs/testing_pref_service.h" #include "testing/gtest/include/gtest/gtest.h" namespace metrics { namespace { TimeNowIgnoringOverride; const char kTestPrefName[] = …; // TODO(crbug.com/40099277): Use TaskEnvironment::TimeSource::MOCK_TIME here // instead of explicit clock overrides when it better supports setting a // specific time of day and rewinding time. class DateChangedHelperTest : public testing::Test { … }; } // namespace // Should not consider date changed if the preference is not available. TEST_F(DateChangedHelperTest, TestNewDoesNotFire) { … } // Should consider date changed if the preference is more than a day old. TEST_F(DateChangedHelperTest, TestOldFires) { … } // Should consider date changed if the preference is more than a day in the // future. TEST_F(DateChangedHelperTest, TestFutureFires) { … } // Should not consider date changed if the preference is earlier the same day. TEST_F(DateChangedHelperTest, TestEarlierSameDayNotFired) { … } // Should not consider date changed if the preference is later the same day. TEST_F(DateChangedHelperTest, TestLaterSameDayNotFired) { … } // Should consider date changed if the preference is in the previous day. TEST_F(DateChangedHelperTest, TestJustNextDayFired) { … } // Should consider date changed if the preference is in the next day. TEST_F(DateChangedHelperTest, TestJustPreviousDayFired) { … } } // namespace metrics