| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "base/time/time.h" | 6 #include "base/time/time.h" |
| 7 #include "content/child/blink_platform_impl.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "webkit/child/webkitplatformsupport_impl.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 // Derives BlinkPlatformImpl for testing shared timers. | 12 // Derives WebKitPlatformSupportImpl for testing shared timers. |
| 13 class TestBlinkPlatformImpl : public BlinkPlatformImpl { | 13 class TestBlinkPlatformImpl : public webkit_glue::WebKitPlatformSupportImpl { |
| 14 public: | 14 public: |
| 15 TestBlinkPlatformImpl() : mock_monotonically_increasing_time_(0) {} | 15 TestBlinkPlatformImpl() : mock_monotonically_increasing_time_(0) {} |
| 16 | 16 |
| 17 // webkit_glue::BlinkPlatformImpl: | 17 // webkit_glue::WebKitPlatformSupportImpl: |
| 18 virtual base::string16 GetLocalizedString(int) OVERRIDE { | 18 virtual base::string16 GetLocalizedString(int) OVERRIDE { |
| 19 return base::string16(); | 19 return base::string16(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) OVERRIDE { | 22 virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) OVERRIDE { |
| 23 return base::StringPiece(); | 23 return base::StringPiece(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( | 26 virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader( |
| 27 const webkit_glue::ResourceLoaderBridge::RequestInfo&) OVERRIDE { | 27 const webkit_glue::ResourceLoaderBridge::RequestInfo&) OVERRIDE { |
| 28 return NULL; | 28 return NULL; |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual WebSocketStreamHandleBridge* CreateWebSocketStreamBridge( | 31 virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge( |
| 32 blink::WebSocketStreamHandle*, | 32 blink::WebSocketStreamHandle*, |
| 33 WebSocketStreamHandleDelegate*) OVERRIDE { | 33 webkit_glue::WebSocketStreamHandleDelegate*) OVERRIDE { |
| 34 return NULL; | 34 return NULL; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Returns mock time when enabled. | 37 // Returns mock time when enabled. |
| 38 virtual double monotonicallyIncreasingTime() OVERRIDE { | 38 virtual double monotonicallyIncreasingTime() OVERRIDE { |
| 39 if (mock_monotonically_increasing_time_ > 0.0) | 39 if (mock_monotonically_increasing_time_ > 0.0) |
| 40 return mock_monotonically_increasing_time_; | 40 return mock_monotonically_increasing_time_; |
| 41 return BlinkPlatformImpl::monotonicallyIncreasingTime(); | 41 return webkit_glue::WebKitPlatformSupportImpl:: |
| 42 monotonicallyIncreasingTime(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 virtual void OnStartSharedTimer(base::TimeDelta delay) OVERRIDE { | 45 virtual void OnStartSharedTimer(base::TimeDelta delay) OVERRIDE { |
| 45 shared_timer_delay_ = delay; | 46 shared_timer_delay_ = delay; |
| 46 } | 47 } |
| 47 | 48 |
| 48 base::TimeDelta shared_timer_delay() { return shared_timer_delay_; } | 49 base::TimeDelta shared_timer_delay() { return shared_timer_delay_; } |
| 49 | 50 |
| 50 void set_mock_monotonically_increasing_time(double mock_time) { | 51 void set_mock_monotonically_increasing_time(double mock_time) { |
| 51 mock_monotonically_increasing_time_ = mock_time; | 52 mock_monotonically_increasing_time_ = mock_time; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 78 platform_impl.set_mock_monotonically_increasing_time(new_time); | 79 platform_impl.set_mock_monotonically_increasing_time(new_time); |
| 79 | 80 |
| 80 // Resume timers so that the timer set above will be set again to fire | 81 // Resume timers so that the timer set above will be set again to fire |
| 81 // immediately. | 82 // immediately. |
| 82 platform_impl.ResumeSharedTimer(); | 83 platform_impl.ResumeSharedTimer(); |
| 83 | 84 |
| 84 EXPECT_TRUE(base::TimeDelta() == platform_impl.shared_timer_delay()); | 85 EXPECT_TRUE(base::TimeDelta() == platform_impl.shared_timer_delay()); |
| 85 } | 86 } |
| 86 | 87 |
| 87 } // namespace content | 88 } // namespace content |
| OLD | NEW |