OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(akalin): Change all users of this class to use SimpleTestClock | 5 // TODO(akalin): Change all users of this class to use SimpleTestClock |
6 // or SimpleTestTickClock and remove this class. | 6 // or SimpleTestTickClock and remove this class. |
7 | 7 |
8 // A helper class used to mock out calls to the static method base::Time::Now. | 8 // A helper class used to mock out calls to the static method base::Time::Now. |
9 // | 9 // |
10 // Example usage: | 10 // Example usage: |
(...skipping 27 matching lines...) Expand all Loading... |
38 // | 38 // |
39 // StopWatch sw(&MockTimeProvider::StaticNow); | 39 // StopWatch sw(&MockTimeProvider::StaticNow); |
40 // sw.Start(); // First call to Now. | 40 // sw.Start(); // First call to Now. |
41 // TimeDelta elapsed = sw.stop(); // Second call to Now. | 41 // TimeDelta elapsed = sw.stop(); // Second call to Now. |
42 // ASSERT_EQ(elapsed, TimeDelta::FromSeconds(6)); | 42 // ASSERT_EQ(elapsed, TimeDelta::FromSeconds(6)); |
43 // } | 43 // } |
44 | 44 |
45 #ifndef BASE_TEST_MOCK_TIME_PROVIDER_H_ | 45 #ifndef BASE_TEST_MOCK_TIME_PROVIDER_H_ |
46 #define BASE_TEST_MOCK_TIME_PROVIDER_H_ | 46 #define BASE_TEST_MOCK_TIME_PROVIDER_H_ |
47 | 47 |
48 #include "base/time.h" | 48 #include "base/time/time.h" |
49 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
50 | 50 |
51 namespace base { | 51 namespace base { |
52 | 52 |
53 class MockTimeProvider { | 53 class MockTimeProvider { |
54 public: | 54 public: |
55 MockTimeProvider(); | 55 MockTimeProvider(); |
56 ~MockTimeProvider(); | 56 ~MockTimeProvider(); |
57 | 57 |
58 MOCK_METHOD0(Now, Time()); | 58 MOCK_METHOD0(Now, Time()); |
59 | 59 |
60 static Time StaticNow(); | 60 static Time StaticNow(); |
61 | 61 |
62 private: | 62 private: |
63 static MockTimeProvider* instance_; | 63 static MockTimeProvider* instance_; |
64 DISALLOW_COPY_AND_ASSIGN(MockTimeProvider); | 64 DISALLOW_COPY_AND_ASSIGN(MockTimeProvider); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace base | 67 } // namespace base |
68 | 68 |
69 #endif // BASE_TEST_MOCK_TIME_PROVIDER_H_ | 69 #endif // BASE_TEST_MOCK_TIME_PROVIDER_H_ |
OLD | NEW |