| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 10 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 gfx::Rect(0, 0, 500, 500), w1.get())); | 587 gfx::Rect(0, 0, 500, 500), w1.get())); |
| 588 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, | 588 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, |
| 589 gfx::Rect(50, 50, 450, 450), w11.get())); | 589 gfx::Rect(50, 50, 450, 450), w11.get())); |
| 590 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, | 590 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, |
| 591 gfx::Rect(0, 0, 500, 500), w1.get())); | 591 gfx::Rect(0, 0, 500, 500), w1.get())); |
| 592 | 592 |
| 593 gfx::Point target_point = w111->bounds().CenterPoint(); | 593 gfx::Point target_point = w111->bounds().CenterPoint(); |
| 594 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point)); | 594 EXPECT_EQ(w111.get(), w1->GetEventHandlerForPoint(target_point)); |
| 595 } | 595 } |
| 596 | 596 |
| 597 // Verifies show/hide propagate correctly to children and the layer. |
| 598 TEST_F(WindowTest, Visibility) { |
| 599 scoped_ptr<Window> w1(CreateTestWindowWithId(1, NULL)); |
| 600 scoped_ptr<Window> w2(CreateTestWindowWithId(2, w1.get())); |
| 601 scoped_ptr<Window> w3(CreateTestWindowWithId(3, w2.get())); |
| 602 |
| 603 // Create shows all the windows. |
| 604 EXPECT_TRUE(w1->IsVisible()); |
| 605 EXPECT_TRUE(w2->IsVisible()); |
| 606 EXPECT_TRUE(w3->IsVisible()); |
| 607 |
| 608 w1->Hide(); |
| 609 EXPECT_FALSE(w1->IsVisible()); |
| 610 EXPECT_FALSE(w2->IsVisible()); |
| 611 EXPECT_FALSE(w3->IsVisible()); |
| 612 |
| 613 w2->Show(); |
| 614 EXPECT_FALSE(w1->IsVisible()); |
| 615 EXPECT_FALSE(w2->IsVisible()); |
| 616 EXPECT_FALSE(w3->IsVisible()); |
| 617 |
| 618 w3->Hide(); |
| 619 EXPECT_FALSE(w1->IsVisible()); |
| 620 EXPECT_FALSE(w2->IsVisible()); |
| 621 EXPECT_FALSE(w3->IsVisible()); |
| 622 |
| 623 w1->Show(); |
| 624 EXPECT_TRUE(w1->IsVisible()); |
| 625 EXPECT_TRUE(w2->IsVisible()); |
| 626 EXPECT_FALSE(w3->IsVisible()); |
| 627 |
| 628 w3->Show(); |
| 629 EXPECT_TRUE(w1->IsVisible()); |
| 630 EXPECT_TRUE(w2->IsVisible()); |
| 631 EXPECT_TRUE(w3->IsVisible()); |
| 632 } |
| 633 |
| 597 // When set_consume_events() is called with |true| for a Window, that Window | 634 // When set_consume_events() is called with |true| for a Window, that Window |
| 598 // should make sure that none behind it in the z-order see events if it has | 635 // should make sure that none behind it in the z-order see events if it has |
| 599 // children. If it does not have children, event targeting works as usual. | 636 // children. If it does not have children, event targeting works as usual. |
| 600 TEST_F(WindowTest, ConsumesEvents) { | 637 TEST_F(WindowTest, ConsumesEvents) { |
| 601 WindowDelegateImpl d11; | 638 WindowDelegateImpl d11; |
| 602 WindowDelegateImpl d121; | 639 WindowDelegateImpl d121; |
| 603 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, | 640 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, |
| 604 gfx::Rect(0, 0, 500, 500), NULL)); | 641 gfx::Rect(0, 0, 500, 500), NULL)); |
| 605 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, | 642 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, |
| 606 gfx::Rect(0, 0, 500, 500), w1.get())); | 643 gfx::Rect(0, 0, 500, 500), w1.get())); |
| 607 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(NULL, 111, | 644 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(NULL, 111, |
| 608 gfx::Rect(50, 50, 450, 450), w11.get())); | 645 gfx::Rect(50, 50, 450, 450), w11.get())); |
| 609 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, | 646 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, |
| 610 gfx::Rect(0, 0, 500, 500), w1.get())); | 647 gfx::Rect(0, 0, 500, 500), w1.get())); |
| 611 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, | 648 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, |
| 612 gfx::Rect(150, 150, 50, 50), NULL)); | 649 gfx::Rect(150, 150, 50, 50), NULL)); |
| 613 | 650 |
| 614 w12->set_consumes_events(true); | 651 w12->set_consumes_events(true); |
| 615 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); | 652 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); |
| 616 | 653 |
| 617 w12->AddChild(w121.get()); | 654 w12->AddChild(w121.get()); |
| 618 | 655 |
| 619 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10))); | 656 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10))); |
| 620 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175))); | 657 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175))); |
| 621 } | 658 } |
| 622 | 659 |
| 623 } // namespace internal | 660 } // namespace internal |
| 624 } // namespace aura | 661 } // namespace aura |
| OLD | NEW |