Chromium Code Reviews| Index: components/autofill/core/browser/test_autofill_clock.cc |
| diff --git a/components/autofill/core/browser/test_autofill_clock.cc b/components/autofill/core/browser/test_autofill_clock.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9457d00668de980041cbdb54fcc2f407eced5d50 |
| --- /dev/null |
| +++ b/components/autofill/core/browser/test_autofill_clock.cc |
| @@ -0,0 +1,32 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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
|
| + |
| +#include <utility> |
| + |
| +#include "base/test/simple_test_clock.h" |
| +#include "components/autofill/core/common/autofill_clock.h" |
| + |
| +namespace autofill { |
| + |
| +TestAutofillClock::TestAutofillClock() { |
| + // 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.
|
| + // pointer to manipulate the time it returns. |
| + std::unique_ptr<base::SimpleTestClock> unique_test_clock( |
| + new base::SimpleTestClock()); |
| + 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.
|
| + AutofillClock::SetTestClock(std::move(unique_test_clock)); |
| +} |
| + |
| +TestAutofillClock::~TestAutofillClock() { |
| + // Destroys the test clock and resets a normal clock. |
| + AutofillClock::SetClock(); |
| +} |
| + |
| +void TestAutofillClock::SetNow(base::Time now) { |
| + test_clock_->SetNow(now); |
| +} |
| + |
| +} // namespace autofill |