| 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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1270 } |
| 1271 | 1271 |
| 1272 // This tests that a compositor frame received with a stale content source ID | 1272 // This tests that a compositor frame received with a stale content source ID |
| 1273 // in its metadata is properly discarded. | 1273 // in its metadata is properly discarded. |
| 1274 TEST_F(RenderWidgetHostTest, SwapCompositorFrameWithBadSourceId) { | 1274 TEST_F(RenderWidgetHostTest, SwapCompositorFrameWithBadSourceId) { |
| 1275 host_->StartNewContentRenderingTimeout(100); | 1275 host_->StartNewContentRenderingTimeout(100); |
| 1276 host_->OnFirstPaintAfterLoad(); | 1276 host_->OnFirstPaintAfterLoad(); |
| 1277 | 1277 |
| 1278 // First swap a frame with an invalid ID. | 1278 // First swap a frame with an invalid ID. |
| 1279 cc::CompositorFrame frame; | 1279 cc::CompositorFrame frame; |
| 1280 cc::LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); |
| 1280 frame.metadata.content_source_id = 99; | 1281 frame.metadata.content_source_id = 99; |
| 1281 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | 1282 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( |
| 1282 0, 0, frame, std::vector<IPC::Message>())); | 1283 0, 0, local_surface_id, frame, std::vector<IPC::Message>())); |
| 1283 EXPECT_FALSE( | 1284 EXPECT_FALSE( |
| 1284 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | 1285 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); |
| 1285 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); | 1286 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); |
| 1286 | 1287 |
| 1287 // Test with a valid content ID as a control. | 1288 // Test with a valid content ID as a control. |
| 1288 frame.metadata.content_source_id = 100; | 1289 frame.metadata.content_source_id = 100; |
| 1289 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | 1290 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( |
| 1290 0, 0, frame, std::vector<IPC::Message>())); | 1291 0, 0, local_surface_id, frame, std::vector<IPC::Message>())); |
| 1291 EXPECT_TRUE( | 1292 EXPECT_TRUE( |
| 1292 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | 1293 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); |
| 1293 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); | 1294 static_cast<TestView*>(host_->GetView())->reset_did_swap_compositor_frame(); |
| 1294 | 1295 |
| 1295 // We also accept frames with higher content IDs, to cover the case where | 1296 // We also accept frames with higher content IDs, to cover the case where |
| 1296 // the browser process receives a compositor frame for a new page before | 1297 // the browser process receives a compositor frame for a new page before |
| 1297 // the corresponding DidCommitProvisionalLoad (it's a race). | 1298 // the corresponding DidCommitProvisionalLoad (it's a race). |
| 1298 frame.metadata.content_source_id = 101; | 1299 frame.metadata.content_source_id = 101; |
| 1299 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( | 1300 host_->OnMessageReceived(ViewHostMsg_SwapCompositorFrame( |
| 1300 0, 0, frame, std::vector<IPC::Message>())); | 1301 0, 0, local_surface_id, frame, std::vector<IPC::Message>())); |
| 1301 EXPECT_TRUE( | 1302 EXPECT_TRUE( |
| 1302 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); | 1303 static_cast<TestView*>(host_->GetView())->did_swap_compositor_frame()); |
| 1303 } | 1304 } |
| 1304 | 1305 |
| 1305 TEST_F(RenderWidgetHostTest, TouchEmulator) { | 1306 TEST_F(RenderWidgetHostTest, TouchEmulator) { |
| 1306 simulated_event_time_delta_seconds_ = 0.1; | 1307 simulated_event_time_delta_seconds_ = 0.1; |
| 1307 // Immediately ack all touches instead of sending them to the renderer. | 1308 // Immediately ack all touches instead of sending them to the renderer. |
| 1308 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); | 1309 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); |
| 1309 host_->SetTouchEventEmulationEnabled( | 1310 host_->SetTouchEventEmulationEnabled( |
| 1310 true, ui::GestureProviderConfigType::GENERIC_MOBILE); | 1311 true, ui::GestureProviderConfigType::GENERIC_MOBILE); |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 ui::LatencyInfo()); | 1795 ui::LatencyInfo()); |
| 1795 | 1796 |
| 1796 | 1797 |
| 1797 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1798 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1798 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1799 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1799 | 1800 |
| 1800 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1801 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1801 } | 1802 } |
| 1802 | 1803 |
| 1803 } // namespace content | 1804 } // namespace content |
| OLD | NEW |