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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 widget_host_->ShutdownAndDestroyWidget(true); 505 widget_host_->ShutdownAndDestroyWidget(true);
506 else 506 else
507 delete widget_host_; 507 delete widget_host_;
508 508
509 parent_view_->Destroy(); 509 parent_view_->Destroy();
510 delete parent_host_; 510 delete parent_host_;
511 511
512 browser_context_.reset(); 512 browser_context_.reset();
513 aura_test_helper_->TearDown(); 513 aura_test_helper_->TearDown();
514 514
515 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); 515 message_loop_.task_runner()->DeleteSoon(FROM_HERE,
516 message_loop_.RunUntilIdle(); 516 browser_context_.release());
517 base::RunLoop().RunUntilIdle();
517 ImageTransportFactory::Terminate(); 518 ImageTransportFactory::Terminate();
518 } 519 }
519 520
520 void SetUp() override { SetUpEnvironment(); } 521 void SetUp() override { SetUpEnvironment(); }
521 522
522 void TearDown() override { TearDownEnvironment(); } 523 void TearDown() override { TearDownEnvironment(); }
523 524
524 void set_widget_host_uses_shutdown_to_destroy(bool use) { 525 void set_widget_host_uses_shutdown_to_destroy(bool use) {
525 widget_host_uses_shutdown_to_destroy_ = use; 526 widget_host_uses_shutdown_to_destroy_ = use;
526 } 527 }
(...skipping 1925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // occur because all frames are visible. 2453 // occur because all frames are visible.
2453 for (size_t i = 0; i < renderer_count; ++i) { 2454 for (size_t i = 0; i < renderer_count; ++i) {
2454 views[i]->Show(); 2455 views[i]->Show();
2455 views[i]->OnSwapCompositorFrame( 2456 views[i]->OnSwapCompositorFrame(
2456 1, MakeDelegatedFrame(1.f, frame_size, view_rect)); 2457 1, MakeDelegatedFrame(1.f, frame_size, view_rect));
2457 EXPECT_TRUE(views[i]->HasFrameData()); 2458 EXPECT_TRUE(views[i]->HasFrameData());
2458 } 2459 }
2459 2460
2460 // If we hide one, it should not get evicted. 2461 // If we hide one, it should not get evicted.
2461 views[0]->Hide(); 2462 views[0]->Hide();
2462 message_loop_.RunUntilIdle(); 2463 base::RunLoop().RunUntilIdle();
2463 EXPECT_TRUE(views[0]->HasFrameData()); 2464 EXPECT_TRUE(views[0]->HasFrameData());
2464 // Using a lesser memory pressure event however, should evict. 2465 // Using a lesser memory pressure event however, should evict.
2465 SimulateMemoryPressure( 2466 SimulateMemoryPressure(
2466 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE); 2467 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE);
2467 message_loop_.RunUntilIdle(); 2468 base::RunLoop().RunUntilIdle();
2468 EXPECT_FALSE(views[0]->HasFrameData()); 2469 EXPECT_FALSE(views[0]->HasFrameData());
2469 2470
2470 // Check the same for a higher pressure event. 2471 // Check the same for a higher pressure event.
2471 views[1]->Hide(); 2472 views[1]->Hide();
2472 message_loop_.RunUntilIdle(); 2473 base::RunLoop().RunUntilIdle();
2473 EXPECT_TRUE(views[1]->HasFrameData()); 2474 EXPECT_TRUE(views[1]->HasFrameData());
2474 SimulateMemoryPressure( 2475 SimulateMemoryPressure(
2475 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL); 2476 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
2476 message_loop_.RunUntilIdle(); 2477 base::RunLoop().RunUntilIdle();
2477 EXPECT_FALSE(views[1]->HasFrameData()); 2478 EXPECT_FALSE(views[1]->HasFrameData());
2478 2479
2479 for (size_t i = 0; i < renderer_count; ++i) { 2480 for (size_t i = 0; i < renderer_count; ++i) {
2480 views[i]->Destroy(); 2481 views[i]->Destroy();
2481 delete hosts[i]; 2482 delete hosts[i];
2482 } 2483 }
2483 } 2484 }
2484 2485
2485 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) { 2486 TEST_F(RenderWidgetHostViewAuraTest, SoftwareDPIChange) {
2486 gfx::Rect view_rect(100, 100); 2487 gfx::Rect view_rect(100, 100);
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
3313 EXPECT_EQ(0U, sink_->message_count()); 3314 EXPECT_EQ(0U, sink_->message_count());
3314 3315
3315 // Let the timer for the debounce queue fire. That should release the queued 3316 // Let the timer for the debounce queue fire. That should release the queued
3316 // scroll-end event. Since overscroll has started, but there hasn't been 3317 // scroll-end event. Since overscroll has started, but there hasn't been
3317 // enough overscroll to complete the gesture, the overscroll controller 3318 // enough overscroll to complete the gesture, the overscroll controller
3318 // will reset the state. The scroll-end should therefore be dispatched to the 3319 // will reset the state. The scroll-end should therefore be dispatched to the
3319 // renderer, and the gesture-event-filter should await an ACK for it. 3320 // renderer, and the gesture-event-filter should await an ACK for it.
3320 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 3321 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
3321 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 3322 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
3322 base::TimeDelta::FromMilliseconds(15)); 3323 base::TimeDelta::FromMilliseconds(15));
3323 base::MessageLoop::current()->Run(); 3324 base::RunLoop().Run();
3324 3325
3325 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3326 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3326 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3327 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3327 EXPECT_EQ(1U, sink_->message_count()); 3328 EXPECT_EQ(1U, sink_->message_count());
3328 } 3329 }
3329 3330
3330 // Tests that when touch-events are dispatched to the renderer, the overscroll 3331 // Tests that when touch-events are dispatched to the renderer, the overscroll
3331 // gesture deals with them correctly. 3332 // gesture deals with them correctly.
3332 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) { 3333 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollWithTouchEvents) {
3333 SetUpOverscrollEnvironmentWithDebounce(10); 3334 SetUpOverscrollEnvironmentWithDebounce(10);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
3420 ReleaseTouchPoint(0); 3421 ReleaseTouchPoint(0);
3421 SendTouchEvent(); 3422 SendTouchEvent();
3422 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 3423 AckLastSentInputEventIfNecessary(INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
3423 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3424 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3424 3425
3425 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 3426 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
3426 blink::WebGestureDeviceTouchscreen); 3427 blink::WebGestureDeviceTouchscreen);
3427 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 3428 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
3428 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 3429 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
3429 base::TimeDelta::FromMilliseconds(10)); 3430 base::TimeDelta::FromMilliseconds(10));
3430 base::MessageLoop::current()->Run(); 3431 base::RunLoop().Run();
3431 EXPECT_EQ(1U, sink_->message_count()); 3432 EXPECT_EQ(1U, sink_->message_count());
3432 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3433 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3433 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3434 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3434 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 3435 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
3435 } 3436 }
3436 3437
3437 // Tests that touch-gesture end is dispatched to the renderer at the end of a 3438 // Tests that touch-gesture end is dispatched to the renderer at the end of a
3438 // touch-gesture initiated overscroll. 3439 // touch-gesture initiated overscroll.
3439 TEST_F(RenderWidgetHostViewAuraOverscrollTest, 3440 TEST_F(RenderWidgetHostViewAuraOverscrollTest,
3440 TouchGestureEndDispatchedAfterOverscrollComplete) { 3441 TouchGestureEndDispatchedAfterOverscrollComplete) {
(...skipping 25 matching lines...) Expand all
3466 EXPECT_EQ(5.f, overscroll_delegate()->delta_x()); 3467 EXPECT_EQ(5.f, overscroll_delegate()->delta_x());
3467 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); 3468 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y());
3468 3469
3469 // Send end event. 3470 // Send end event.
3470 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 3471 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
3471 blink::WebGestureDeviceTouchscreen); 3472 blink::WebGestureDeviceTouchscreen);
3472 EXPECT_EQ(0U, sink_->message_count()); 3473 EXPECT_EQ(0U, sink_->message_count());
3473 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 3474 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
3474 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 3475 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
3475 base::TimeDelta::FromMilliseconds(10)); 3476 base::TimeDelta::FromMilliseconds(10));
3476 base::MessageLoop::current()->Run(); 3477 base::RunLoop().Run();
3477 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3478 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3478 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3479 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3479 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 3480 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
3480 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3481 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3481 3482
3482 // Start scrolling. Receive ACK as it being processed. 3483 // Start scrolling. Receive ACK as it being processed.
3483 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 3484 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
3484 blink::WebGestureDeviceTouchscreen); 3485 blink::WebGestureDeviceTouchscreen);
3485 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 3486 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
3486 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3487 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
(...skipping 14 matching lines...) Expand all
3501 EXPECT_EQ(185.f, overscroll_delegate()->delta_x()); 3502 EXPECT_EQ(185.f, overscroll_delegate()->delta_x());
3502 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y()); 3503 EXPECT_EQ(-5.f, overscroll_delegate()->delta_y());
3503 3504
3504 // Send end event. 3505 // Send end event.
3505 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd, 3506 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
3506 blink::WebGestureDeviceTouchscreen); 3507 blink::WebGestureDeviceTouchscreen);
3507 EXPECT_EQ(0U, sink_->message_count()); 3508 EXPECT_EQ(0U, sink_->message_count());
3508 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 3509 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
3509 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 3510 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
3510 base::TimeDelta::FromMilliseconds(10)); 3511 base::TimeDelta::FromMilliseconds(10));
3511 base::MessageLoop::current()->Run(); 3512 base::RunLoop().Run();
3512 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode()); 3513 EXPECT_EQ(OVERSCROLL_NONE, overscroll_mode());
3513 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 3514 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
3514 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 3515 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
3515 EXPECT_EQ(1U, sink_->message_count()); 3516 EXPECT_EQ(1U, sink_->message_count());
3516 } 3517 }
3517 3518
3518 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) { 3519 TEST_F(RenderWidgetHostViewAuraOverscrollTest, OverscrollDirectionChange) {
3519 SetUpOverscrollEnvironmentWithDebounce(100); 3520 SetUpOverscrollEnvironmentWithDebounce(100);
3520 3521
3521 // Start scrolling. Receive ACK as it being processed. 3522 // Start scrolling. Receive ACK as it being processed.
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
4573 4574
4574 // Retrieve the selected text from clipboard and verify it is as expected. 4575 // Retrieve the selected text from clipboard and verify it is as expected.
4575 base::string16 result_text; 4576 base::string16 result_text;
4576 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); 4577 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text);
4577 EXPECT_EQ(expected_text, result_text); 4578 EXPECT_EQ(expected_text, result_text);
4578 } 4579 }
4579 } 4580 }
4580 #endif 4581 #endif
4581 4582
4582 } // namespace content 4583 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_unittest.cc ('k') | content/browser/tracing/etw_tracing_agent_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698