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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <tuple> | 9 #include <tuple> |
10 | 10 |
(...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); | 1235 EXPECT_TRUE(delegate_->unresponsive_timer_fired()); |
1236 } | 1236 } |
1237 | 1237 |
1238 // Test that the rendering timeout for newly loaded content fires | 1238 // Test that the rendering timeout for newly loaded content fires |
1239 // when enough time passes without receiving a new compositor frame. | 1239 // when enough time passes without receiving a new compositor frame. |
1240 TEST_F(RenderWidgetHostTest, NewContentRenderingTimeout) { | 1240 TEST_F(RenderWidgetHostTest, NewContentRenderingTimeout) { |
1241 host_->set_new_content_rendering_delay_for_testing( | 1241 host_->set_new_content_rendering_delay_for_testing( |
1242 base::TimeDelta::FromMicroseconds(10)); | 1242 base::TimeDelta::FromMicroseconds(10)); |
1243 | 1243 |
1244 // Test immediate start and stop, ensuring that the timeout doesn't fire. | 1244 // Test immediate start and stop, ensuring that the timeout doesn't fire. |
1245 host_->StartNewContentRenderingTimeout(0); | 1245 host_->StartNewContentRenderingTimeout(); |
1246 host_->OnFirstPaintAfterLoad(); | 1246 host_->OnFirstPaintAfterLoad(); |
1247 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1247 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1248 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1248 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
1249 TimeDelta::FromMicroseconds(20)); | 1249 TimeDelta::FromMicroseconds(20)); |
1250 base::RunLoop().Run(); | 1250 base::RunLoop().Run(); |
1251 | 1251 |
1252 EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); | 1252 EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); |
1253 | 1253 |
1254 // Test that the timer doesn't fire if it receives a stop before | 1254 // Test that the timer doesn't fire if it receives a stop before |
1255 // a start. | 1255 // a start. |
1256 host_->OnFirstPaintAfterLoad(); | 1256 host_->OnFirstPaintAfterLoad(); |
1257 host_->StartNewContentRenderingTimeout(0); | 1257 host_->StartNewContentRenderingTimeout(); |
1258 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1258 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1259 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1259 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
1260 TimeDelta::FromMicroseconds(20)); | 1260 TimeDelta::FromMicroseconds(20)); |
1261 base::RunLoop().Run(); | 1261 base::RunLoop().Run(); |
1262 | 1262 |
1263 EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); | 1263 EXPECT_FALSE(host_->new_content_rendering_timeout_fired()); |
1264 | 1264 |
1265 // Test with a long delay to ensure that it does fire this time. | 1265 // Test with a long delay to ensure that it does fire this time. |
1266 host_->StartNewContentRenderingTimeout(0); | 1266 host_->StartNewContentRenderingTimeout(); |
1267 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1267 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1268 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1268 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
1269 TimeDelta::FromMicroseconds(20)); | 1269 TimeDelta::FromMicroseconds(20)); |
1270 base::RunLoop().Run(); | 1270 base::RunLoop().Run(); |
1271 EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); | 1271 EXPECT_TRUE(host_->new_content_rendering_timeout_fired()); |
1272 } | 1272 } |
1273 | 1273 |
1274 // This tests that a compositor frame received with a stale content source ID | |
1275 // in its metadata is properly discarded. | |
1276 TEST_F(RenderWidgetHostTest, SwapCompositorFrameWithBadSourceId) { | |
1277 host_->StartNewContentRenderingTimeout(100); | |
1278 host_->OnFirstPaintAfterLoad(); | |
1279 | |
1280 // First swap a frame with an invalid ID. | |
1281 cc::CompositorFrame frame; | |
1282 frame.metadata.content_source_id = 99; | |
1283 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | |
1284 0, 0, frame, std::vector<IPC::Message>())); | |
1285 EXPECT_FALSE( | |
1286 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | |
1287 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); | |
1288 | |
1289 // Test with a valid content ID as a control. | |
1290 frame.metadata.content_source_id = 100; | |
1291 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | |
1292 0, 0, frame, std::vector<IPC::Message>())); | |
1293 EXPECT_TRUE( | |
1294 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | |
1295 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); | |
1296 | |
1297 // We also accept frames with higher content IDs, to cover the case where | |
1298 // the browser process receives a compositor frame for a new page before | |
1299 // the corresponding DidCommitProvisionalLoad (it's a race). | |
1300 frame.metadata.content_source_id = 101; | |
1301 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | |
1302 0, 0, frame, std::vector<IPC::Message>())); | |
1303 EXPECT_TRUE( | |
1304 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | |
1305 } | |
1306 | |
1307 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 1274 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
1308 simulated_event_time_delta_seconds_ = 0.1; | 1275 simulated_event_time_delta_seconds_ = 0.1; |
1309 // Immediately ack all touches instead of sending them to the renderer. | 1276 // Immediately ack all touches instead of sending them to the renderer. |
1310 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1277 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
1311 host_->SetTouchEventEmulationEnabled( | 1278 host_->SetTouchEventEmulationEnabled( |
1312 true, ui::GestureProviderConfigType::GENERIC_MOBILE); | 1279 true, ui::GestureProviderConfigType::GENERIC_MOBILE); |
1313 process_->sink().ClearMessages(); | 1280 process_->sink().ClearMessages(); |
1314 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); | 1281 view_->set_bounds(gfx::Rect(0, 0, 400, 200)); |
1315 view_->Show(); | 1282 view_->Show(); |
1316 | 1283 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 ui::LatencyInfo()); | 1732 ui::LatencyInfo()); |
1766 | 1733 |
1767 | 1734 |
1768 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1735 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
1769 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1736 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
1770 | 1737 |
1771 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1738 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
1772 } | 1739 } |
1773 | 1740 |
1774 } // namespace content | 1741 } // namespace content |
OLD | NEW |