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

Unified Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 1339803002: Clear page display after navigation if no rendered output arrives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made ClearCompositorFrame pure virtual Created 5 years, 3 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: 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..8b5074d7358e359794c542fe06b6f42be38483ee 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 NotifyNewContentRenderingTimeoutForTesting() 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_for_testing(
+ 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());
+}
+
std::string GetInputMessageTypes(RenderWidgetHostProcess* process) {
std::string result;
for (size_t i = 0; i < process->sink().message_count(); ++i) {

Powered by Google App Engine
This is Rietveld 408576698