Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_unittest.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc |
| index 3cd868ae20351596bc62fac007ed9a3e1a5c898d..eddc482a617678661031ac871bc9e15c24903226 100644 |
| --- a/content/browser/renderer_host/render_widget_host_unittest.cc |
| +++ b/content/browser/renderer_host/render_widget_host_unittest.cc |
| @@ -139,7 +139,8 @@ class MockRenderWidgetHost : public RenderWidgetHostImpl { |
| GpuSurfaceTracker::Get()->AddSurfaceForRenderer(process->GetID(), |
| routing_id), |
| false), |
| - unresponsive_timer_fired_(false) { |
| + unresponsive_timer_fired_(false), |
| + new_content_rendering_timeout_fired_(false) { |
| acked_touch_event_type_ = blink::WebInputEvent::Undefined; |
| } |
| @@ -164,6 +165,10 @@ class MockRenderWidgetHost : public RenderWidgetHostImpl { |
| return unresponsive_timer_fired_; |
| } |
| + bool new_content_rendering_timeout_fired() const { |
| + return new_content_rendering_timeout_fired_; |
| + } |
| + |
| void DisableGestureDebounce() { |
| input_router_.reset(new InputRouterImpl( |
| process_, this, this, routing_id_, InputRouterImpl::Config())); |
| @@ -186,7 +191,12 @@ class MockRenderWidgetHost : public RenderWidgetHostImpl { |
| unresponsive_timer_fired_ = true; |
| } |
| + void NotifyNewContentRenderingTimeout() override { |
| + new_content_rendering_timeout_fired_ = true; |
| + } |
| + |
| bool unresponsive_timer_fired_; |
| + bool new_content_rendering_timeout_fired_; |
| WebInputEvent::Type acked_touch_event_type_; |
| DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHost); |
| @@ -1092,6 +1102,31 @@ TEST_F(RenderWidgetHostTest, MultipleInputEvents) { |
| EXPECT_TRUE(host_->unresponsive_timer_fired()); |
| } |
| +// Test that the rendering timeout for newly loaded content fires |
| +// when enough time passes without receiving a new compositor frame. |
| +TEST_F(RenderWidgetHostTest, NewContentRenderingTimeout) { |
| + host_->set_new_content_rendering_delay( |
| + base::TimeDelta::FromMicroseconds(10)); |
| + |
| + // Test immediate start and stop, ensuring that the timeout doesn't fire. |
| + host_->StartNewContentRenderingTimeout(); |
| + host_->StopNewContentRenderingTimeout(); |
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| + FROM_HERE, base::MessageLoop::QuitClosure(), |
| + TimeDelta::FromMicroseconds(20)); |
| + base::MessageLoop::current()->Run(); |
| + |
| + EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); |
| + |
| + // Test with a long delay to ensure that it does fire this time. |
| + host_->StartNewContentRenderingTimeout(); |
| + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| + FROM_HERE, base::MessageLoop::QuitClosure(), |
| + TimeDelta::FromMicroseconds(20)); |
| + base::MessageLoop::current()->Run(); |
| + EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); |
|
Charlie Reis
2015/09/14 20:54:55
This is a nice test of the new timer API, though i
kenrb
2015/09/14 21:29:36
I was looking at this earlier, and I couldn't see
Charlie Reis
2015/09/14 21:40:18
Acknowledged.
|
| +} |
| + |
| std::string GetInputMessageTypes(RenderWidgetHostProcess* process) { |
| std::string result; |
| for (size_t i = 0; i < process->sink().message_count(); ++i) { |