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

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

Issue 2770853002: Create Ukm ReportingService implementation. (Closed)
Patch Set: Also revert datatracker unittest change Created 3 years, 9 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
« no previous file with comments | « components/metrics/data_use_tracker.cc ('k') | components/metrics/metrics_pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/data_use_tracker.h" 5 #include "components/metrics/data_use_tracker.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "components/metrics/metrics_pref_names.h" 8 #include "components/metrics/metrics_pref_names.h"
9 #include "components/prefs/pref_registry_simple.h" 9 #include "components/prefs/pref_registry_simple.h"
10 #include "components/prefs/testing_pref_service.h" 10 #include "components/prefs/testing_pref_service.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace metrics { 13 namespace metrics {
14 14
15 namespace { 15 namespace {
16 16
17 const char kTodayStr[] = "2016-03-16"; 17 const char kTodayStr[] = "2016-03-16";
18 const char kYesterdayStr[] = "2016-03-15"; 18 const char kYesterdayStr[] = "2016-03-15";
19 const char kExpiredDateStr1[] = "2016-03-09"; 19 const char kExpiredDateStr1[] = "2016-03-09";
20 const char kExpiredDateStr2[] = "2016-03-01"; 20 const char kExpiredDateStr2[] = "2016-03-01";
21 21
22 class TestDataUsePrefService : public TestingPrefServiceSimple { 22 class TestDataUsePrefService : public TestingPrefServiceSimple {
23 public: 23 public:
24 TestDataUsePrefService() { 24 TestDataUsePrefService() { DataUseTracker::RegisterPrefs(registry()); }
25 registry()->RegisterDictionaryPref(metrics::prefs::kUserCellDataUse);
26 registry()->RegisterDictionaryPref(metrics::prefs::kUmaCellDataUse);
27 }
28 25
29 void ClearDataUsePrefs() { 26 void ClearDataUsePrefs() {
30 ClearPref(metrics::prefs::kUserCellDataUse); 27 ClearPref(metrics::prefs::kUserCellDataUse);
31 ClearPref(metrics::prefs::kUmaCellDataUse); 28 ClearPref(metrics::prefs::kUmaCellDataUse);
32 } 29 }
33 30
34 private: 31 private:
35 DISALLOW_COPY_AND_ASSIGN(TestDataUsePrefService); 32 DISALLOW_COPY_AND_ASSIGN(TestDataUsePrefService);
36 }; 33 };
37 34
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 can_upload = data_use_tracker.ShouldUploadLogOnCellular(100); 194 can_upload = data_use_tracker.ShouldUploadLogOnCellular(100);
198 EXPECT_TRUE(can_upload); 195 EXPECT_TRUE(can_upload);
199 // this is about 0.49% 196 // this is about 0.49%
200 can_upload = data_use_tracker.ShouldUploadLogOnCellular(200); 197 can_upload = data_use_tracker.ShouldUploadLogOnCellular(200);
201 EXPECT_TRUE(can_upload); 198 EXPECT_TRUE(can_upload);
202 can_upload = data_use_tracker.ShouldUploadLogOnCellular(300); 199 can_upload = data_use_tracker.ShouldUploadLogOnCellular(300);
203 EXPECT_FALSE(can_upload); 200 EXPECT_FALSE(can_upload);
204 } 201 }
205 202
206 } // namespace metrics 203 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/data_use_tracker.cc ('k') | components/metrics/metrics_pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698