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

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

Issue 9788001: Remove stops_event_propagation from Window, since it's broken. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.cc ('k') | ui/oak/oak_aura_window_display.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), NULL)); 348 CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), NULL));
349 349
350 scoped_ptr<Window> w3( 350 scoped_ptr<Window> w3(
351 CreateTestWindowWithDelegate( 351 CreateTestWindowWithDelegate(
352 NULL, 3, gfx::Rect(200, 200, 100, 100), NULL)); 352 NULL, 3, gfx::Rect(200, 200, 100, 100), NULL));
353 scoped_ptr<Window> w31( 353 scoped_ptr<Window> w31(
354 CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get())); 354 CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get()));
355 scoped_ptr<Window> w311( 355 scoped_ptr<Window> w311(
356 CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get())); 356 CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get()));
357 357
358 // The stop-event-propagation flag shouldn't have any effect on the behavior
359 // of this method.
360 w3->set_stops_event_propagation(true);
361
362 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0))); 358 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0)));
363 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(5, 5))); 359 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(5, 5)));
364 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(10, 10))); 360 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(10, 10)));
365 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(59, 59))); 361 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(59, 59)));
366 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(60, 60))); 362 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(60, 60)));
367 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(109, 109))); 363 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(109, 109)));
368 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(110, 110))); 364 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(110, 110)));
369 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(200, 200))); 365 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(200, 200)));
370 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(220, 220))); 366 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(220, 220)));
371 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(260, 260))); 367 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(260, 260)));
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 EXPECT_FALSE(w3->IsVisible()); 797 EXPECT_FALSE(w3->IsVisible());
802 EXPECT_EQ(0, d.hidden()); 798 EXPECT_EQ(0, d.hidden());
803 EXPECT_EQ(1, d.shown()); 799 EXPECT_EQ(1, d.shown());
804 800
805 w3->Show(); 801 w3->Show();
806 EXPECT_TRUE(w1->IsVisible()); 802 EXPECT_TRUE(w1->IsVisible());
807 EXPECT_TRUE(w2->IsVisible()); 803 EXPECT_TRUE(w2->IsVisible());
808 EXPECT_TRUE(w3->IsVisible()); 804 EXPECT_TRUE(w3->IsVisible());
809 } 805 }
810 806
811 // When set_consume_events() is called with |true| for a Window, that Window
812 // should make sure that none behind it in the z-order see events if it has
813 // children. If it does not have children, event targeting works as usual.
814 TEST_F(WindowTest, StopsEventPropagation) {
815 TestWindowDelegate d11;
816 TestWindowDelegate d111;
817 TestWindowDelegate d121;
818 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
819 gfx::Rect(0, 0, 500, 500), NULL));
820 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11,
821 gfx::Rect(0, 0, 500, 500), w1.get()));
822 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111,
823 gfx::Rect(50, 50, 450, 450), w11.get()));
824 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12,
825 gfx::Rect(0, 0, 500, 500), w1.get()));
826 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121,
827 gfx::Rect(150, 150, 50, 50), NULL));
828
829 w12->set_stops_event_propagation(true);
830 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
831
832 EXPECT_TRUE(w111->CanFocus());
833 EXPECT_TRUE(w111->CanReceiveEvents());
834 w111->Focus();
835 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow());
836
837 w12->AddChild(w121.get());
838
839 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
840 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175)));
841
842 // It should be possible to focus w121 since it is at or above the
843 // consumes_events_ window.
844 EXPECT_TRUE(w121->CanFocus());
845 EXPECT_TRUE(w121->CanReceiveEvents());
846 w121->Focus();
847 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow());
848
849 // An attempt to focus 111 should be ignored and w121 should retain focus,
850 // since a consumes_events_ window with a child is in the z-index above w111.
851 EXPECT_FALSE(w111->CanReceiveEvents());
852 w111->Focus();
853 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow());
854
855 // Hiding w121 should make 111 focusable.
856 w121->Hide();
857 EXPECT_TRUE(w111->CanFocus());
858 EXPECT_TRUE(w111->CanReceiveEvents());
859 w111->Focus();
860 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow());
861 }
862
863 TEST_F(WindowTest, IgnoreEventsTest) { 807 TEST_F(WindowTest, IgnoreEventsTest) {
864 TestWindowDelegate d11; 808 TestWindowDelegate d11;
865 TestWindowDelegate d12; 809 TestWindowDelegate d12;
866 TestWindowDelegate d111; 810 TestWindowDelegate d111;
867 TestWindowDelegate d121; 811 TestWindowDelegate d121;
868 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, 812 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
869 gfx::Rect(0, 0, 500, 500), NULL)); 813 gfx::Rect(0, 0, 500, 500), NULL));
870 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, 814 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11,
871 gfx::Rect(0, 0, 500, 500), w1.get())); 815 gfx::Rect(0, 0, 500, 500), w1.get()));
872 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, 816 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111,
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 1773
1830 w1.reset(); // Deletes w11 and w111. 1774 w1.reset(); // Deletes w11 and w111.
1831 w11 = NULL; 1775 w11 = NULL;
1832 w111 = NULL; 1776 w111 = NULL;
1833 EXPECT_EQ(2, observer.added_count()); 1777 EXPECT_EQ(2, observer.added_count());
1834 EXPECT_EQ(2, observer.removed_count()); 1778 EXPECT_EQ(2, observer.removed_count());
1835 } 1779 }
1836 1780
1837 } // namespace test 1781 } // namespace test
1838 } // namespace aura 1782 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/oak/oak_aura_window_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698