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

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

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Added a scoped TestAutofillClock 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/autofill/core/browser/test_autofill_clock.h"
Mathieu 2017/01/31 18:19:37 could this be in common too?
sebsg 2017/01/31 21:55:56 I put it with all the other test utils used for te
6
7 #include <utility>
8
9 #include "base/test/simple_test_clock.h"
10 #include "components/autofill/core/common/autofill_clock.h"
11
12 namespace autofill {
13
14 TestAutofillClock::TestAutofillClock() {
15 // Create a new test clock and set it as the AutofillClock clock and keep a
Roger McFarlane (Chromium) 2017/01/31 19:05:54 indent -2, or maybe you've got tabs?
sebsg 2017/01/31 21:55:56 Done.
16 // pointer to manipulate the time it returns.
17 std::unique_ptr<base::SimpleTestClock> unique_test_clock(
18 new base::SimpleTestClock());
19 test_clock_ = unique_test_clock.get();
Roger McFarlane (Chromium) 2017/01/31 19:05:54 this is kind of evil. Document that you're keeping
sebsg 2017/01/31 21:55:56 Done.
20 AutofillClock::SetTestClock(std::move(unique_test_clock));
21 }
22
23 TestAutofillClock::~TestAutofillClock() {
24 // Destroys the test clock and resets a normal clock.
25 AutofillClock::SetClock();
26 }
27
28 void TestAutofillClock::SetNow(base::Time now) {
29 test_clock_->SetNow(now);
30 }
31
32 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698