Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: components/metrics/daily_event_unittest.cc

Issue 636363004: Make remaining parts of components/metrics use metrics namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix cros compile Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/daily_event.h" 5 #include "components/metrics/daily_event.h"
6 6
7 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace metrics { 10 namespace metrics {
(...skipping 20 matching lines...) Expand all
31 bool fired_; 31 bool fired_;
32 32
33 DISALLOW_COPY_AND_ASSIGN(TestDailyObserver); 33 DISALLOW_COPY_AND_ASSIGN(TestDailyObserver);
34 }; 34 };
35 35
36 class DailyEventTest : public testing::Test { 36 class DailyEventTest : public testing::Test {
37 public: 37 public:
38 DailyEventTest() : event_(&prefs_, kTestPrefName, kTestMetricName) { 38 DailyEventTest() : event_(&prefs_, kTestPrefName, kTestMetricName) {
39 DailyEvent::RegisterPref(prefs_.registry(), kTestPrefName); 39 DailyEvent::RegisterPref(prefs_.registry(), kTestPrefName);
40 observer_ = new TestDailyObserver(); 40 observer_ = new TestDailyObserver();
41 scoped_ptr<metrics::DailyEvent::Observer> p(observer_); 41 event_.AddObserver(make_scoped_ptr(observer_));
42 event_.AddObserver(p.Pass());
43 } 42 }
44 43
45 protected: 44 protected:
46 TestingPrefServiceSimple prefs_; 45 TestingPrefServiceSimple prefs_;
47 TestDailyObserver* observer_; 46 TestDailyObserver* observer_;
48 DailyEvent event_; 47 DailyEvent event_;
49 48
50 private: 49 private:
51 DISALLOW_COPY_AND_ASSIGN(DailyEventTest); 50 DISALLOW_COPY_AND_ASSIGN(DailyEventTest);
52 }; 51 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 84
86 // The event should not fire if the preference is less than a day in the future. 85 // The event should not fire if the preference is less than a day in the future.
87 TEST_F(DailyEventTest, TestSoonNotFired) { 86 TEST_F(DailyEventTest, TestSoonNotFired) {
88 base::Time last_time = base::Time::Now() + base::TimeDelta::FromMinutes(2); 87 base::Time last_time = base::Time::Now() + base::TimeDelta::FromMinutes(2);
89 prefs_.SetInt64(kTestPrefName, last_time.ToInternalValue()); 88 prefs_.SetInt64(kTestPrefName, last_time.ToInternalValue());
90 event_.CheckInterval(); 89 event_.CheckInterval();
91 EXPECT_FALSE(observer_->fired()); 90 EXPECT_FALSE(observer_->fired());
92 } 91 }
93 92
94 } // namespace metrics 93 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/cloned_install_detector.cc ('k') | components/metrics/gpu/gpu_metrics_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698