| 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 parent_delegate.get(), 1, gfx::Rect(10, 20, 400, 500), root_window())); | 568 parent_delegate.get(), 1, gfx::Rect(10, 20, 400, 500), root_window())); |
| 569 std::unique_ptr<Window> child(CreateTestWindow( | 569 std::unique_ptr<Window> child(CreateTestWindow( |
| 570 SK_ColorRED, 2, gfx::Rect(0, 0, 390, 480), parent.get())); | 570 SK_ColorRED, 2, gfx::Rect(0, 0, 390, 480), parent.get())); |
| 571 | 571 |
| 572 // We can override ShouldDescendIntoChildForEventHandling to make the parent | 572 // We can override ShouldDescendIntoChildForEventHandling to make the parent |
| 573 // grab all events. | 573 // grab all events. |
| 574 EXPECT_EQ(parent.get(), parent->GetEventHandlerForPoint(gfx::Point(0, 0))); | 574 EXPECT_EQ(parent.get(), parent->GetEventHandlerForPoint(gfx::Point(0, 0))); |
| 575 EXPECT_EQ(parent.get(), parent->GetEventHandlerForPoint(gfx::Point(50, 50))); | 575 EXPECT_EQ(parent.get(), parent->GetEventHandlerForPoint(gfx::Point(50, 50))); |
| 576 } | 576 } |
| 577 | 577 |
| 578 TEST_P(WindowTest, GetTopWindowContainingPoint) { | |
| 579 Window* root = root_window(); | |
| 580 root->SetBounds(gfx::Rect(0, 0, 300, 300)); | |
| 581 | |
| 582 std::unique_ptr<Window> w1(CreateTestWindow( | |
| 583 SK_ColorWHITE, 1, gfx::Rect(10, 10, 100, 100), root_window())); | |
| 584 std::unique_ptr<Window> w11( | |
| 585 CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(0, 0, 120, 120), w1.get())); | |
| 586 | |
| 587 std::unique_ptr<Window> w2( | |
| 588 CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), root_window())); | |
| 589 | |
| 590 std::unique_ptr<Window> w3(CreateTestWindowWithDelegate( | |
| 591 NULL, 3, gfx::Rect(200, 200, 100, 100), root_window())); | |
| 592 std::unique_ptr<Window> w31( | |
| 593 CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get())); | |
| 594 std::unique_ptr<Window> w311( | |
| 595 CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get())); | |
| 596 | |
| 597 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0))); | |
| 598 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(5, 5))); | |
| 599 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(10, 10))); | |
| 600 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(59, 59))); | |
| 601 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(60, 60))); | |
| 602 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(109, 109))); | |
| 603 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(110, 110))); | |
| 604 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(200, 200))); | |
| 605 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(220, 220))); | |
| 606 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(260, 260))); | |
| 607 } | |
| 608 | |
| 609 TEST_P(WindowTest, GetToplevelWindow) { | 578 TEST_P(WindowTest, GetToplevelWindow) { |
| 610 const gfx::Rect kBounds(0, 0, 10, 10); | 579 const gfx::Rect kBounds(0, 0, 10, 10); |
| 611 TestWindowDelegate delegate; | 580 TestWindowDelegate delegate; |
| 612 | 581 |
| 613 std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); | 582 std::unique_ptr<Window> w1(CreateTestWindowWithId(1, root_window())); |
| 614 std::unique_ptr<Window> w11( | 583 std::unique_ptr<Window> w11( |
| 615 CreateTestWindowWithDelegate(&delegate, 11, kBounds, w1.get())); | 584 CreateTestWindowWithDelegate(&delegate, 11, kBounds, w1.get())); |
| 616 std::unique_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); | 585 std::unique_ptr<Window> w111(CreateTestWindowWithId(111, w11.get())); |
| 617 std::unique_ptr<Window> w1111( | 586 std::unique_ptr<Window> w1111( |
| 618 CreateTestWindowWithDelegate(&delegate, 1111, kBounds, w111.get())); | 587 CreateTestWindowWithDelegate(&delegate, 1111, kBounds, w111.get())); |
| (...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 ::testing::Values(BackendType::CLASSIC, | 2905 ::testing::Values(BackendType::CLASSIC, |
| 2937 BackendType::MUS)); | 2906 BackendType::MUS)); |
| 2938 | 2907 |
| 2939 INSTANTIATE_TEST_CASE_P(/* no prefix */, | 2908 INSTANTIATE_TEST_CASE_P(/* no prefix */, |
| 2940 WindowObserverTest, | 2909 WindowObserverTest, |
| 2941 ::testing::Values(BackendType::CLASSIC, | 2910 ::testing::Values(BackendType::CLASSIC, |
| 2942 BackendType::MUS)); | 2911 BackendType::MUS)); |
| 2943 | 2912 |
| 2944 } // namespace test | 2913 } // namespace test |
| 2945 } // namespace aura | 2914 } // namespace aura |
| OLD | NEW |