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

Unified Diff: components/autofill/core/browser/test_autofill_clock.h

Issue 2639403002: [Autofill] Remove direct use of base::Time::Now() in Autofill (Closed)
Patch Set: Added DCHECK 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/test_autofill_clock.h
diff --git a/components/autofill/core/browser/test_autofill_clock.h b/components/autofill/core/browser/test_autofill_clock.h
new file mode 100644
index 0000000000000000000000000000000000000000..a40f54fbd2fcbc01a92aeeda43104f2fb99acb4f
--- /dev/null
+++ b/components/autofill/core/browser/test_autofill_clock.h
@@ -0,0 +1,39 @@
+// 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.
+
+#ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLOCK_H_
+#define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLOCK_H_
+
+#include <memory>
+
+#include "base/macros.h"
+
+namespace base {
+class SimpleTestClock;
+class Time;
+} // namespace base
+
+namespace autofill {
+
+// Handles the customization of the time in tests. Replaces the clock in
+// AutofillClock with a test version that can be manipulated from this class.
+// Automatically resets a normal clock to AutofillClock when this gets
+// destroyed,
+class TestAutofillClock {
+ public:
+ TestAutofillClock();
+ ~TestAutofillClock();
+
+ // Set the time to be returned from AutofillClock::Now() calls.
+ void SetNow(base::Time now);
+
+ private:
+ base::SimpleTestClock* test_clock_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestAutofillClock);
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLOCK_H_

Powered by Google App Engine
This is Rietveld 408576698