| 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 widget_host_->ShutdownAndDestroyWidget(true); | 486 widget_host_->ShutdownAndDestroyWidget(true); |
| 487 else | 487 else |
| 488 delete widget_host_; | 488 delete widget_host_; |
| 489 | 489 |
| 490 parent_view_->Destroy(); | 490 parent_view_->Destroy(); |
| 491 delete parent_host_; | 491 delete parent_host_; |
| 492 | 492 |
| 493 browser_context_.reset(); | 493 browser_context_.reset(); |
| 494 aura_test_helper_->TearDown(); | 494 aura_test_helper_->TearDown(); |
| 495 | 495 |
| 496 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 496 message_loop_.task_runner()->DeleteSoon(FROM_HERE, |
| 497 message_loop_.RunUntilIdle(); | 497 browser_context_.release()); |
| 498 base::RunLoop().RunUntilIdle(); |
| 498 ImageTransportFactory::Terminate(); | 499 ImageTransportFactory::Terminate(); |
| 499 } | 500 } |
| 500 | 501 |
| 501 void SetUp() override { SetUpEnvironment(); } | 502 void SetUp() override { SetUpEnvironment(); } |
| 502 | 503 |
| 503 void TearDown() override { TearDownEnvironment(); } | 504 void TearDown() override { TearDownEnvironment(); } |
| 504 | 505 |
| 505 void set_widget_host_uses_shutdown_to_destroy(bool use) { | 506 void set_widget_host_uses_shutdown_to_destroy(bool use) { |
| 506 widget_host_uses_shutdown_to_destroy_ = use; | 507 widget_host_uses_shutdown_to_destroy_ = use; |
| 507 } | 508 } |
| (...skipping 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 // occur because all frames are visible. | 2439 // occur because all frames are visible. |
| 2439 for (size_t i = 0; i < renderer_count; ++i) { | 2440 for (size_t i = 0; i < renderer_count; ++i) { |
| 2440 views[i]->Show(); | 2441 views[i]->Show(); |
| 2441 views[i]->OnSwapCompositorFrame( | 2442 views[i]->OnSwapCompositorFrame( |
| 2442 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); | 2443 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); |
| 2443 EXPECT_TRUE(views[i]->HasFrameData()); | 2444 EXPECT_TRUE(views[i]->HasFrameData()); |
| 2444 } | 2445 } |
| 2445 | 2446 |
| 2446 // If we hide one, it should not get evicted. | 2447 // If we hide one, it should not get evicted. |
| 2447 views[0]->Hide(); | 2448 views[0]->Hide(); |
| 2448 message_loop_.RunUntilIdle(); | 2449 base::RunLoop().RunUntilIdle(); |
| 2449 EXPECT_TRUE(views[0]->HasFrameData()); | 2450 EXPECT_TRUE(views[0]->HasFrameData()); |
| 2450 // Using a lesser memory pressure event however, should evict. | 2451 // Using a lesser memory pressure event however, should evict. |
| 2451 SimulateMemoryPressure( | 2452 SimulateMemoryPressure( |
| 2452 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); | 2453 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); |
| 2453 message_loop_.RunUntilIdle(); | 2454 base::RunLoop().RunUntilIdle(); |
| 2454 EXPECT_FALSE(views[0]->HasFrameData()); | 2455 EXPECT_FALSE(views[0]->HasFrameData()); |
| 2455 | 2456 |
| 2456 // Check the same for a higher pressure event. | 2457 // Check the same for a higher pressure event. |
| 2457 views[1]->Hide(); | 2458 views[1]->Hide(); |
| 2458 message_loop_.RunUntilIdle(); | 2459 base::RunLoop().RunUntilIdle(); |
| 2459 EXPECT_TRUE(views[1]->HasFrameData()); | 2460 EXPECT_TRUE(views[1]->HasFrameData()); |
| 2460 SimulateMemoryPressure( | 2461 SimulateMemoryPressure( |
| 2461 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); | 2462 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); |
| 2462 message_loop_.RunUntilIdle(); | 2463 base::RunLoop().RunUntilIdle(); |
| 2463 EXPECT_FALSE(views[1]->HasFrameData()); | 2464 EXPECT_FALSE(views[1]->HasFrameData()); |
| 2464 | 2465 |
| 2465 for (size_t i = 0; i < renderer_count; ++i) { | 2466 for (size_t i = 0; i < renderer_count; ++i) { |
| 2466 views[i]->Destroy(); | 2467 views[i]->Destroy(); |
| 2467 delete hosts[i]; | 2468 delete hosts[i]; |
| 2468 } | 2469 } |
| 2469 } | 2470 } |
| 2470 | 2471 |
| 2471 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) { | 2472 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) { |
| 2472 gfx::Rect view_rect(100, 100); | 2473 gfx::Rect view_rect(100, 100); |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 EXPECT_EQ(0U, sink_->message_count()); | 3300 EXPECT_EQ(0U, sink_->message_count()); |
| 3300 | 3301 |
| 3301 // Let the timer for the debounce queue fire. That should release the queued | 3302 // Let the timer for the debounce queue fire. That should release the queued |
| 3302 // scroll-end event. Since overscroll has started, but there hasn't been | 3303 // scroll-end event. Since overscroll has started, but there hasn't been |
| 3303 // enough overscroll to complete the gesture, the overscroll controller | 3304 // enough overscroll to complete the gesture, the overscroll controller |
| 3304 // will reset the state. The scroll-end should therefore be dispatched to the | 3305 // will reset the state. The scroll-end should therefore be dispatched to the |
| 3305 // renderer, and the gesture-event-filter should await an ACK for it. | 3306 // renderer, and the gesture-event-filter should await an ACK for it. |
| 3306 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 3307 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3307 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3308 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3308 base::TimeDelta::FromMilliseconds(15)); | 3309 base::TimeDelta::FromMilliseconds(15)); |
| 3309 base::MessageLoop::current()->Run(); | 3310 base::RunLoop().Run(); |
| 3310 | 3311 |
| 3311 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3312 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3312 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3313 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3313 EXPECT_EQ(1U, sink_->message_count()); | 3314 EXPECT_EQ(1U, sink_->message_count()); |
| 3314 } | 3315 } |
| 3315 | 3316 |
| 3316 // Tests that when touch-events are dispatched to the renderer, the overscroll | 3317 // Tests that when touch-events are dispatched to the renderer, the overscroll |
| 3317 // gesture deals with them correctly. | 3318 // gesture deals with them correctly. |
| 3318 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { | 3319 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { |
| 3319 SetUpOverscrollEnvironmentWithDebounce(10); | 3320 SetUpOverscrollEnvironmentWithDebounce(10); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3406 ReleaseTouchPoint(0); | 3407 ReleaseTouchPoint(0); |
| 3407 SendTouchEvent(); | 3408 SendTouchEvent(); |
| 3408 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 3409 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 3409 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3410 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3410 | 3411 |
| 3411 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3412 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3412 blink::WebGestureDeviceTouchscreen); | 3413 blink::WebGestureDeviceTouchscreen); |
| 3413 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 3414 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3414 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3415 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3415 base::TimeDelta::FromMilliseconds(10)); | 3416 base::TimeDelta::FromMilliseconds(10)); |
| 3416 base::MessageLoop::current()->Run(); | 3417 base::RunLoop().Run(); |
| 3417 EXPECT_EQ(1U, sink_->message_count()); | 3418 EXPECT_EQ(1U, sink_->message_count()); |
| 3418 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3419 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3419 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3420 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3420 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3421 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3421 } | 3422 } |
| 3422 | 3423 |
| 3423 // Tests that touch-gesture end is dispatched to the renderer at the end of a | 3424 // Tests that touch-gesture end is dispatched to the renderer at the end of a |
| 3424 // touch-gesture initiated overscroll. | 3425 // touch-gesture initiated overscroll. |
| 3425 TEST_F(RenderWidgetHostViewAuraOverscrollTest, | 3426 TEST_F(RenderWidgetHostViewAuraOverscrollTest, |
| 3426 TouchGestureEndDispatchedAfterOverscrollComplete) { | 3427 TouchGestureEndDispatchedAfterOverscrollComplete) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3452 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); | 3453 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); |
| 3453 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3454 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
| 3454 | 3455 |
| 3455 // Send end event. | 3456 // Send end event. |
| 3456 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3457 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3457 blink::WebGestureDeviceTouchscreen); | 3458 blink::WebGestureDeviceTouchscreen); |
| 3458 EXPECT_EQ(0U, sink_->message_count()); | 3459 EXPECT_EQ(0U, sink_->message_count()); |
| 3459 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 3460 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3460 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3461 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3461 base::TimeDelta::FromMilliseconds(10)); | 3462 base::TimeDelta::FromMilliseconds(10)); |
| 3462 base::MessageLoop::current()->Run(); | 3463 base::RunLoop().Run(); |
| 3463 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3464 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3464 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3465 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3465 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); | 3466 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); |
| 3466 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3467 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3467 | 3468 |
| 3468 // Start scrolling. Receive ACK as it being processed. | 3469 // Start scrolling. Receive ACK as it being processed. |
| 3469 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, | 3470 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, |
| 3470 blink::WebGestureDeviceTouchscreen); | 3471 blink::WebGestureDeviceTouchscreen); |
| 3471 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 3472 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
| 3472 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3473 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3487 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); | 3488 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); |
| 3488 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); | 3489 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); |
| 3489 | 3490 |
| 3490 // Send end event. | 3491 // Send end event. |
| 3491 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, | 3492 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, |
| 3492 blink::WebGestureDeviceTouchscreen); | 3493 blink::WebGestureDeviceTouchscreen); |
| 3493 EXPECT_EQ(0U, sink_->message_count()); | 3494 EXPECT_EQ(0U, sink_->message_count()); |
| 3494 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 3495 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 3495 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 3496 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 3496 base::TimeDelta::FromMilliseconds(10)); | 3497 base::TimeDelta::FromMilliseconds(10)); |
| 3497 base::MessageLoop::current()->Run(); | 3498 base::RunLoop().Run(); |
| 3498 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); | 3499 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); |
| 3499 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); | 3500 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); |
| 3500 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); | 3501 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); |
| 3501 EXPECT_EQ(1U, sink_->message_count()); | 3502 EXPECT_EQ(1U, sink_->message_count()); |
| 3502 } | 3503 } |
| 3503 | 3504 |
| 3504 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { | 3505 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { |
| 3505 SetUpOverscrollEnvironmentWithDebounce(100); | 3506 SetUpOverscrollEnvironmentWithDebounce(100); |
| 3506 | 3507 |
| 3507 // Start scrolling. Receive ACK as it being processed. | 3508 // Start scrolling. Receive ACK as it being processed. |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4533 EXPECT_TRUE(text_input_client()->GetSelectionRange(&range_from_client)); | 4534 EXPECT_TRUE(text_input_client()->GetSelectionRange(&range_from_client)); |
| 4534 EXPECT_EQ(expected_range, range_from_client); | 4535 EXPECT_EQ(expected_range, range_from_client); |
| 4535 | 4536 |
| 4536 // Changing range to make sure that the next view has a different text | 4537 // Changing range to make sure that the next view has a different text |
| 4537 // selection. | 4538 // selection. |
| 4538 expected_range.set_end(expected_range.end() + 1U); | 4539 expected_range.set_end(expected_range.end() + 1U); |
| 4539 } | 4540 } |
| 4540 } | 4541 } |
| 4541 | 4542 |
| 4542 } // namespace content | 4543 } // namespace content |
| OLD | NEW |