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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 gfx::Rect(50, 50, 450, 450), w11.get())); | 653 gfx::Rect(50, 50, 450, 450), w11.get())); |
654 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, | 654 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12, |
655 gfx::Rect(0, 0, 500, 500), w1.get())); | 655 gfx::Rect(0, 0, 500, 500), w1.get())); |
656 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, | 656 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121, |
657 gfx::Rect(150, 150, 50, 50), NULL)); | 657 gfx::Rect(150, 150, 50, 50), NULL)); |
658 | 658 |
659 w12->set_stops_event_propagation(true); | 659 w12->set_stops_event_propagation(true); |
660 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); | 660 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); |
661 | 661 |
662 EXPECT_TRUE(w111->CanFocus()); | 662 EXPECT_TRUE(w111->CanFocus()); |
| 663 EXPECT_TRUE(w111->CanReceiveEvents()); |
663 w111->Focus(); | 664 w111->Focus(); |
664 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow()); | 665 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow()); |
665 | 666 |
666 w12->AddChild(w121.get()); | 667 w12->AddChild(w121.get()); |
667 | 668 |
668 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10))); | 669 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10))); |
669 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175))); | 670 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175))); |
670 | 671 |
671 // It should be possible to focus w121 since it is at or above the | 672 // It should be possible to focus w121 since it is at or above the |
672 // consumes_events_ window. | 673 // consumes_events_ window. |
673 EXPECT_TRUE(w121->CanFocus()); | 674 EXPECT_TRUE(w121->CanFocus()); |
| 675 EXPECT_TRUE(w121->CanReceiveEvents()); |
674 w121->Focus(); | 676 w121->Focus(); |
675 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); | 677 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); |
676 | 678 |
677 // An attempt to focus 111 should be ignored and w121 should retain focus, | 679 // An attempt to focus 111 should be ignored and w121 should retain focus, |
678 // since a consumes_events_ window with a child is in the z-index above w111. | 680 // since a consumes_events_ window with a child is in the z-index above w111. |
679 EXPECT_FALSE(w111->CanFocus()); | 681 EXPECT_FALSE(w111->CanReceiveEvents()); |
680 w111->Focus(); | 682 w111->Focus(); |
681 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); | 683 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); |
| 684 |
| 685 // Hiding w121 should make 111 focusable. |
| 686 w121->Hide(); |
| 687 EXPECT_TRUE(w111->CanFocus()); |
| 688 EXPECT_TRUE(w111->CanReceiveEvents()); |
| 689 w111->Focus(); |
| 690 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow()); |
682 } | 691 } |
683 | 692 |
684 TEST_F(WindowTest, IgnoreEventsTest) { | 693 TEST_F(WindowTest, IgnoreEventsTest) { |
685 TestWindowDelegate d11; | 694 TestWindowDelegate d11; |
686 TestWindowDelegate d12; | 695 TestWindowDelegate d12; |
687 TestWindowDelegate d111; | 696 TestWindowDelegate d111; |
688 TestWindowDelegate d121; | 697 TestWindowDelegate d121; |
689 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, | 698 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, |
690 gfx::Rect(0, 0, 500, 500), NULL)); | 699 gfx::Rect(0, 0, 500, 500), NULL)); |
691 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, | 700 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 EXPECT_EQ("name=test old=1 new=2", PropertyChangeInfoAndClear()); | 1030 EXPECT_EQ("name=test old=1 new=2", PropertyChangeInfoAndClear()); |
1022 w1->SetProperty(key, NULL); | 1031 w1->SetProperty(key, NULL); |
1023 EXPECT_EQ("name=test old=2 new=0", PropertyChangeInfoAndClear()); | 1032 EXPECT_EQ("name=test old=2 new=0", PropertyChangeInfoAndClear()); |
1024 | 1033 |
1025 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. | 1034 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. |
1026 EXPECT_EQ("name= old=0 new=0", PropertyChangeInfoAndClear()); | 1035 EXPECT_EQ("name= old=0 new=0", PropertyChangeInfoAndClear()); |
1027 } | 1036 } |
1028 | 1037 |
1029 } // namespace test | 1038 } // namespace test |
1030 } // namespace aura | 1039 } // namespace aura |
OLD | NEW |