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

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

Issue 2605293002: Add WARN_UNUSED_RESULT to base::Time methods that return bool. (Closed)
Patch Set: Use ASSERT_TRUE in unit test Created 3 years, 11 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 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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return true; 44 return true;
45 } 45 }
46 46
47 bool GetUmaRatio(double* ratio) const override { 47 bool GetUmaRatio(double* ratio) const override {
48 *ratio = 0.05; 48 *ratio = 0.05;
49 return true; 49 return true;
50 } 50 }
51 51
52 base::Time GetCurrentMeasurementDate() const override { 52 base::Time GetCurrentMeasurementDate() const override {
53 base::Time today_for_test; 53 base::Time today_for_test;
54 base::Time::FromUTCString(kTodayStr, &today_for_test); 54 if (base::Time::FromUTCString(kTodayStr, &today_for_test)) {
55 return today_for_test; 55 return today_for_test;
56 } else {
57 return {};
58 }
56 } 59 }
57 60
58 std::string GetCurrentMeasurementDateAsString() const override { 61 std::string GetCurrentMeasurementDateAsString() const override {
59 return kTodayStr; 62 return kTodayStr;
60 } 63 }
61 64
62 private: 65 private:
63 DISALLOW_COPY_AND_ASSIGN(FakeDataUseTracker); 66 DISALLOW_COPY_AND_ASSIGN(FakeDataUseTracker);
64 }; 67 };
65 68
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 can_upload = data_use_tracker.ShouldUploadLogOnCellular(100); 200 can_upload = data_use_tracker.ShouldUploadLogOnCellular(100);
198 EXPECT_TRUE(can_upload); 201 EXPECT_TRUE(can_upload);
199 // this is about 0.49% 202 // this is about 0.49%
200 can_upload = data_use_tracker.ShouldUploadLogOnCellular(200); 203 can_upload = data_use_tracker.ShouldUploadLogOnCellular(200);
201 EXPECT_TRUE(can_upload); 204 EXPECT_TRUE(can_upload);
202 can_upload = data_use_tracker.ShouldUploadLogOnCellular(300); 205 can_upload = data_use_tracker.ShouldUploadLogOnCellular(300);
203 EXPECT_FALSE(can_upload); 206 EXPECT_FALSE(can_upload);
204 } 207 }
205 208
206 } // namespace metrics 209 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698