OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/glue/webkit_glue.h" | 5 #include "webkit/glue/webkit_glue.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 TEST(WebkitGlueTest, SuspendResumeSharedTimer) { | 100 TEST(WebkitGlueTest, SuspendResumeSharedTimer) { |
101 TestWebKitPlatformSupport platform_support; | 101 TestWebKitPlatformSupport platform_support; |
102 | 102 |
103 // Set a timer to fire as soon as possible. | 103 // Set a timer to fire as soon as possible. |
104 platform_support.setSharedTimerFireInterval(0); | 104 platform_support.setSharedTimerFireInterval(0); |
105 // Suspend timers immediately so the above timer wouldn't be fired. | 105 // Suspend timers immediately so the above timer wouldn't be fired. |
106 platform_support.SuspendSharedTimer(); | 106 platform_support.SuspendSharedTimer(); |
107 // The above timer would have posted a task which can be processed out of the | 107 // The above timer would have posted a task which can be processed out of the |
108 // message loop. | 108 // message loop. |
109 MessageLoop::current()->RunAllPending(); | 109 MessageLoop::current()->RunUntilIdle(); |
110 // Set a mock time after 1 second to simulate timers suspended for 1 second. | 110 // Set a mock time after 1 second to simulate timers suspended for 1 second. |
111 double new_time = base::Time::Now().ToDoubleT() + 1; | 111 double new_time = base::Time::Now().ToDoubleT() + 1; |
112 platform_support.set_mock_monotonically_increasing_time(new_time); | 112 platform_support.set_mock_monotonically_increasing_time(new_time); |
113 // Resume timers so that the timer set above will be set again to fire | 113 // Resume timers so that the timer set above will be set again to fire |
114 // immediately. | 114 // immediately. |
115 platform_support.ResumeSharedTimer(); | 115 platform_support.ResumeSharedTimer(); |
116 EXPECT_TRUE(base::TimeDelta() == platform_support.shared_timer_delay()); | 116 EXPECT_TRUE(base::TimeDelta() == platform_support.shared_timer_delay()); |
117 } | 117 } |
118 | 118 |
119 } // namespace | 119 } // namespace |
OLD | NEW |