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

Side by Side Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 2567293004: Makes WindowTreeHost::InitHost() not Show the window (Closed)
Patch Set: WTF::Show shows window Created 4 years 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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 EventTypesToString(w1_filter.events())); 1616 EventTypesToString(w1_filter.events()));
1617 } 1617 }
1618 1618
1619 // Tests the case where the event dispatcher is deleted during the pre-dispatch 1619 // Tests the case where the event dispatcher is deleted during the pre-dispatch
1620 // phase of dispatching and event. 1620 // phase of dispatching and event.
1621 TEST_P(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) { 1621 TEST_P(WindowEventDispatcherTest, DeleteDispatcherDuringPreDispatch) {
1622 // Create a host for the window hierarchy. This host will be destroyed later 1622 // Create a host for the window hierarchy. This host will be destroyed later
1623 // on. 1623 // on.
1624 WindowTreeHost* host = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); 1624 WindowTreeHost* host = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100));
1625 host->InitHost(); 1625 host->InitHost();
1626 host->window()->Show();
1626 1627
1627 // Create two windows. 1628 // Create two windows.
1628 Window* w1 = CreateNormalWindow(1, host->window(), nullptr); 1629 Window* w1 = CreateNormalWindow(1, host->window(), nullptr);
1629 w1->SetBounds(gfx::Rect(20, 20, 60, 60)); 1630 w1->SetBounds(gfx::Rect(20, 20, 60, 60));
1630 Window* w2 = CreateNormalWindow(2, host->window(), nullptr); 1631 Window* w2 = CreateNormalWindow(2, host->window(), nullptr);
1631 w2->SetBounds(gfx::Rect(80, 20, 120, 60)); 1632 w2->SetBounds(gfx::Rect(80, 20, 120, 60));
1632 EXPECT_EQ(nullptr, host->dispatcher()->mouse_moved_handler()); 1633 EXPECT_EQ(nullptr, host->dispatcher()->mouse_moved_handler());
1633 1634
1634 ui::test::EventGenerator generator(host->window(), w1); 1635 ui::test::EventGenerator generator(host->window(), w1);
1635 1636
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 // Verifies GetRootWindow() from ~Window returns a valid root. 1694 // Verifies GetRootWindow() from ~Window returns a valid root.
1694 TEST_P(WindowEventDispatcherTest, ValidRootDuringDestruction) { 1695 TEST_P(WindowEventDispatcherTest, ValidRootDuringDestruction) {
1695 bool got_destroying = false; 1696 bool got_destroying = false;
1696 bool has_valid_root = false; 1697 bool has_valid_root = false;
1697 ValidRootDuringDestructionWindowObserver observer(&got_destroying, 1698 ValidRootDuringDestructionWindowObserver observer(&got_destroying,
1698 &has_valid_root); 1699 &has_valid_root);
1699 { 1700 {
1700 std::unique_ptr<WindowTreeHost> host( 1701 std::unique_ptr<WindowTreeHost> host(
1701 WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100))); 1702 WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)));
1702 host->InitHost(); 1703 host->InitHost();
1704 host->window()->Show();
1703 // Owned by WindowEventDispatcher. 1705 // Owned by WindowEventDispatcher.
1704 Window* w1 = CreateNormalWindow(1, host->window(), NULL); 1706 Window* w1 = CreateNormalWindow(1, host->window(), NULL);
1705 w1->AddObserver(&observer); 1707 w1->AddObserver(&observer);
1706 } 1708 }
1707 EXPECT_TRUE(got_destroying); 1709 EXPECT_TRUE(got_destroying);
1708 EXPECT_TRUE(has_valid_root); 1710 EXPECT_TRUE(has_valid_root);
1709 } 1711 }
1710 1712
1711 namespace { 1713 namespace {
1712 1714
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 }; 1801 };
1800 1802
1801 } // namespace 1803 } // namespace
1802 1804
1803 // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event 1805 // Verifies if a WindowTreeHost is deleted from dispatching a held mouse event
1804 // we don't crash. 1806 // we don't crash.
1805 TEST_P(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) { 1807 TEST_P(WindowEventDispatcherTest, DeleteHostFromHeldMouseEvent) {
1806 // Should be deleted by |delegate|. 1808 // Should be deleted by |delegate|.
1807 WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100)); 1809 WindowTreeHost* h2 = WindowTreeHost::Create(gfx::Rect(0, 0, 100, 100));
1808 h2->InitHost(); 1810 h2->InitHost();
1811 h2->window()->Show();
1809 DeleteHostFromHeldMouseEventDelegate delegate(h2); 1812 DeleteHostFromHeldMouseEventDelegate delegate(h2);
1810 // Owned by |h2|. 1813 // Owned by |h2|.
1811 Window* w1 = CreateNormalWindow(1, h2->window(), &delegate); 1814 Window* w1 = CreateNormalWindow(1, h2->window(), &delegate);
1812 w1->SetBounds(gfx::Rect(0, 0, 40, 40)); 1815 w1->SetBounds(gfx::Rect(0, 0, 40, 40));
1813 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10), 1816 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, gfx::Point(10, 10),
1814 gfx::Point(10, 10), ui::EventTimeForNow(), 1817 gfx::Point(10, 10), ui::EventTimeForNow(),
1815 ui::EF_SHIFT_DOWN, 0); 1818 ui::EF_SHIFT_DOWN, 0);
1816 h2->dispatcher()->RepostEvent(&pressed); 1819 h2->dispatcher()->RepostEvent(&pressed);
1817 // RunAllPendingInMessageLoop() to make sure the |pressed| is run. 1820 // RunAllPendingInMessageLoop() to make sure the |pressed| is run.
1818 RunAllPendingInMessageLoop(); 1821 RunAllPendingInMessageLoop();
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler); 2393 DISALLOW_COPY_AND_ASSIGN(MoveWindowHandler);
2391 }; 2394 };
2392 2395
2393 // Tests that nested event dispatch works correctly if the target of the older 2396 // Tests that nested event dispatch works correctly if the target of the older
2394 // event being dispatched is moved to a different dispatcher in response to an 2397 // event being dispatched is moved to a different dispatcher in response to an
2395 // event in the inner loop. 2398 // event in the inner loop.
2396 TEST_P(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) { 2399 TEST_P(WindowEventDispatcherTest, NestedEventDispatchTargetMoved) {
2397 std::unique_ptr<WindowTreeHost> second_host( 2400 std::unique_ptr<WindowTreeHost> second_host(
2398 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); 2401 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
2399 second_host->InitHost(); 2402 second_host->InitHost();
2403 second_host->window()->Show();
2400 Window* second_root = second_host->window(); 2404 Window* second_root = second_host->window();
2401 2405
2402 // Create two windows parented to |root_window()|. 2406 // Create two windows parented to |root_window()|.
2403 test::TestWindowDelegate delegate; 2407 test::TestWindowDelegate delegate;
2404 std::unique_ptr<Window> first(CreateTestWindowWithDelegate( 2408 std::unique_ptr<Window> first(CreateTestWindowWithDelegate(
2405 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); 2409 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window()));
2406 std::unique_ptr<Window> second(CreateTestWindowWithDelegate( 2410 std::unique_ptr<Window> second(CreateTestWindowWithDelegate(
2407 &delegate, 234, gfx::Rect(40, 10, 50, 20), root_window())); 2411 &delegate, 234, gfx::Rect(40, 10, 50, 20), root_window()));
2408 2412
2409 // Setup a handler on |first| so that it dispatches an event to |second| when 2413 // Setup a handler on |first| so that it dispatches an event to |second| when
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 TEST_P(WindowEventDispatcherTest, 2456 TEST_P(WindowEventDispatcherTest,
2453 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) { 2457 CursorVisibilityChangedWhileCaptureWindowInAnotherDispatcher) {
2454 test::EventCountDelegate delegate; 2458 test::EventCountDelegate delegate;
2455 std::unique_ptr<Window> window(CreateTestWindowWithDelegate( 2459 std::unique_ptr<Window> window(CreateTestWindowWithDelegate(
2456 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); 2460 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window()));
2457 window->Show(); 2461 window->Show();
2458 2462
2459 std::unique_ptr<WindowTreeHost> second_host( 2463 std::unique_ptr<WindowTreeHost> second_host(
2460 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); 2464 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
2461 second_host->InitHost(); 2465 second_host->InitHost();
2466 second_host->window()->Show();
2462 WindowEventDispatcher* second_dispatcher = second_host->dispatcher(); 2467 WindowEventDispatcher* second_dispatcher = second_host->dispatcher();
2463 2468
2464 // Install an InputStateLookup on the Env that always claims that a 2469 // Install an InputStateLookup on the Env that always claims that a
2465 // mouse-button is down. 2470 // mouse-button is down.
2466 test::EnvTestHelper(Env::GetInstance()) 2471 test::EnvTestHelper(Env::GetInstance())
2467 .SetInputStateLookup(std::unique_ptr<InputStateLookup>( 2472 .SetInputStateLookup(std::unique_ptr<InputStateLookup>(
2468 new AlwaysMouseDownInputStateLookup())); 2473 new AlwaysMouseDownInputStateLookup()));
2469 2474
2470 window->SetCapture(); 2475 window->SetCapture();
2471 2476
(...skipping 20 matching lines...) Expand all
2492 host()->OnCursorVisibilityChanged(false); 2497 host()->OnCursorVisibilityChanged(false);
2493 second_host->OnCursorVisibilityChanged(false); 2498 second_host->OnCursorVisibilityChanged(false);
2494 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); 2499 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset());
2495 } 2500 }
2496 2501
2497 TEST_P(WindowEventDispatcherTest, 2502 TEST_P(WindowEventDispatcherTest,
2498 RedirectedEventToDifferentDispatcherLocation) { 2503 RedirectedEventToDifferentDispatcherLocation) {
2499 std::unique_ptr<WindowTreeHost> second_host( 2504 std::unique_ptr<WindowTreeHost> second_host(
2500 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50))); 2505 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
2501 second_host->InitHost(); 2506 second_host->InitHost();
2507 second_host->window()->Show();
2502 client::SetCaptureClient(second_host->window(), 2508 client::SetCaptureClient(second_host->window(),
2503 client::GetCaptureClient(root_window())); 2509 client::GetCaptureClient(root_window()));
2504 2510
2505 test::EventCountDelegate delegate; 2511 test::EventCountDelegate delegate;
2506 std::unique_ptr<Window> window_first(CreateTestWindowWithDelegate( 2512 std::unique_ptr<Window> window_first(CreateTestWindowWithDelegate(
2507 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window())); 2513 &delegate, 123, gfx::Rect(20, 10, 10, 20), root_window()));
2508 window_first->Show(); 2514 window_first->Show();
2509 2515
2510 std::unique_ptr<Window> window_second(CreateTestWindowWithDelegate( 2516 std::unique_ptr<Window> window_second(CreateTestWindowWithDelegate(
2511 &delegate, 12, gfx::Rect(10, 10, 20, 30), second_host->window())); 2517 &delegate, 12, gfx::Rect(10, 10, 20, 30), second_host->window()));
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2678 WindowEventDispatcherTestWithMessageLoop, 2684 WindowEventDispatcherTestWithMessageLoop,
2679 ::testing::Values(test::BackendType::CLASSIC, 2685 ::testing::Values(test::BackendType::CLASSIC,
2680 test::BackendType::MUS)); 2686 test::BackendType::MUS));
2681 2687
2682 INSTANTIATE_TEST_CASE_P(/* no prefix */, 2688 INSTANTIATE_TEST_CASE_P(/* no prefix */,
2683 WindowEventDispatcherTestInHighDPI, 2689 WindowEventDispatcherTestInHighDPI,
2684 ::testing::Values(test::BackendType::CLASSIC, 2690 ::testing::Values(test::BackendType::CLASSIC,
2685 test::BackendType::MUS)); 2691 test::BackendType::MUS));
2686 2692
2687 } // namespace aura 2693 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698