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

Side by Side Diff: components/autofill/core/browser/autofill_data_model_unittest.cc

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Rebase Created 3 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/core/browser/autofill_data_model.h" 5 #include "components/autofill/core/browser/autofill_data_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "components/autofill/core/browser/autofill_clock.h"
12 #include "components/autofill/core/common/autofill_constants.h" 13 #include "components/autofill/core/common/autofill_constants.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace autofill { 16 namespace autofill {
16 17
17 namespace { 18 namespace {
18 19
19 // Provides concrete implementations for pure virtual methods. 20 // Provides concrete implementations for pure virtual methods.
20 class TestAutofillDataModel : public AutofillDataModel { 21 class TestAutofillDataModel : public AutofillDataModel {
21 public: 22 public:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 EXPECT_TRUE(model.IsVerified()); 66 EXPECT_TRUE(model.IsVerified());
66 67
67 model.set_origin("Some gibberish string"); 68 model.set_origin("Some gibberish string");
68 EXPECT_TRUE(model.IsVerified()); 69 EXPECT_TRUE(model.IsVerified());
69 70
70 model.set_origin(std::string()); 71 model.set_origin(std::string());
71 EXPECT_FALSE(model.IsVerified()); 72 EXPECT_FALSE(model.IsVerified());
72 } 73 }
73 74
74 TEST(AutofillDataModelTest, CompareFrecency) { 75 TEST(AutofillDataModelTest, CompareFrecency) {
75 base::Time now = base::Time::Now(); 76 base::Time now = AutofillClock::Now();
76 enum Expectation { GREATER, LESS }; 77 enum Expectation { GREATER, LESS };
77 78
78 struct { 79 struct {
79 const std::string guid_a; 80 const std::string guid_a;
80 const int use_count_a; 81 const int use_count_a;
81 const base::Time use_date_a; 82 const base::Time use_date_a;
82 const std::string guid_b; 83 const std::string guid_b;
83 const int use_count_b; 84 const int use_count_b;
84 const base::Time use_date_b; 85 const base::Time use_date_b;
85 Expectation expectation; 86 Expectation expectation;
(...skipping 28 matching lines...) Expand all
114 test_case.use_date_b); 115 test_case.use_date_b);
115 116
116 EXPECT_EQ(test_case.expectation == GREATER, 117 EXPECT_EQ(test_case.expectation == GREATER,
117 model_a.CompareFrecency(&model_b, now)); 118 model_a.CompareFrecency(&model_b, now));
118 EXPECT_NE(test_case.expectation == GREATER, 119 EXPECT_NE(test_case.expectation == GREATER,
119 model_b.CompareFrecency(&model_a, now)); 120 model_b.CompareFrecency(&model_a, now));
120 } 121 }
121 } 122 }
122 123
123 } // namespace autofill 124 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698