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

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

Issue 9181012: Don't activate a window if screen is locked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 scoped_ptr<Window> w2( 226 scoped_ptr<Window> w2(
227 CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), NULL)); 227 CreateTestWindow(SK_ColorRED, 2, gfx::Rect(5, 5, 55, 55), NULL));
228 228
229 scoped_ptr<Window> w3( 229 scoped_ptr<Window> w3(
230 CreateTestWindowWithDelegate( 230 CreateTestWindowWithDelegate(
231 NULL, 3, gfx::Rect(200, 200, 100, 100), NULL)); 231 NULL, 3, gfx::Rect(200, 200, 100, 100), NULL));
232 scoped_ptr<Window> w31( 232 scoped_ptr<Window> w31(
233 CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get())); 233 CreateTestWindow(SK_ColorCYAN, 31, gfx::Rect(0, 0, 50, 50), w3.get()));
234 scoped_ptr<Window> w311( 234 scoped_ptr<Window> w311(
235 CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get())); 235 CreateTestWindow(SK_ColorBLUE, 311, gfx::Rect(0, 0, 10, 10), w31.get()));
236
237 // The stop-event-propagation flag shouldn't have any effect on the behavior 236 // The stop-event-propagation flag shouldn't have any effect on the behavior
238 // of this method. 237 // of this method.
239 w3->set_stops_event_propagation(true); 238 w3->set_stops_event_propagation(true);
239 w31->set_stops_event_propagation(true);
240 240
241 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0))); 241 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(0, 0)));
242 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(5, 5))); 242 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(5, 5)));
243 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(10, 10))); 243 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(10, 10)));
244 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(59, 59))); 244 EXPECT_EQ(w2.get(), root->GetTopWindowContainingPoint(gfx::Point(59, 59)));
245 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(60, 60))); 245 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(60, 60)));
246 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(109, 109))); 246 EXPECT_EQ(w1.get(), root->GetTopWindowContainingPoint(gfx::Point(109, 109)));
247 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(110, 110))); 247 EXPECT_EQ(NULL, root->GetTopWindowContainingPoint(gfx::Point(110, 110)));
248 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(200, 200))); 248 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(200, 200)));
249 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(220, 220))); 249 EXPECT_EQ(w31.get(), root->GetTopWindowContainingPoint(gfx::Point(220, 220)));
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, 650 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11,
651 gfx::Rect(0, 0, 500, 500), w1.get())); 651 gfx::Rect(0, 0, 500, 500), w1.get()));
652 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111, 652 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(&d111, 111,
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 w121->set_stops_event_propagation(true);
661
660 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10))); 662 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
661 663
662 EXPECT_TRUE(w111->CanFocus()); 664 EXPECT_TRUE(w111->CanFocus());
665 EXPECT_TRUE(w111->CanReceiveEvents());
663 w111->Focus(); 666 w111->Focus();
664 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow()); 667 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow());
665 668
666 w12->AddChild(w121.get()); 669 w12->AddChild(w121.get());
667 670
668 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10))); 671 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
669 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175))); 672 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175)));
670 673
671 // It should be possible to focus w121 since it is at or above the 674 // It should be possible to focus w121 since it is at or above the
672 // consumes_events_ window. 675 // consumes_events_ window.
673 EXPECT_TRUE(w121->CanFocus()); 676 EXPECT_TRUE(w121->CanFocus());
677 EXPECT_TRUE(w121->CanReceiveEvents());
674 w121->Focus(); 678 w121->Focus();
675 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); 679 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow());
676 680
677 // An attempt to focus 111 should be ignored and w121 should retain focus, 681 // 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. 682 // since a consumes_events_ window with a child is in the z-index above w111.
679 EXPECT_FALSE(w111->CanFocus()); 683 EXPECT_FALSE(w111->CanReceiveEvents());
680 w111->Focus(); 684 w111->Focus();
681 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow()); 685 EXPECT_EQ(w121.get(), w1->GetFocusManager()->GetFocusedWindow());
686
687 // Set the stop-event-propagation flag to false so that 111 can be
688 // focused.
689 w121->set_stops_event_propagation(false);
690 EXPECT_TRUE(w111->CanFocus());
691 EXPECT_TRUE(w111->CanReceiveEvents());
692 w111->Focus();
693 EXPECT_EQ(w111.get(), w1->GetFocusManager()->GetFocusedWindow());
682 } 694 }
683 695
684 TEST_F(WindowTest, IgnoreEventsTest) { 696 TEST_F(WindowTest, IgnoreEventsTest) {
685 TestWindowDelegate d11; 697 TestWindowDelegate d11;
686 TestWindowDelegate d12; 698 TestWindowDelegate d12;
687 TestWindowDelegate d111; 699 TestWindowDelegate d111;
688 TestWindowDelegate d121; 700 TestWindowDelegate d121;
689 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, 701 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
690 gfx::Rect(0, 0, 500, 500), NULL)); 702 gfx::Rect(0, 0, 500, 500), NULL));
691 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11, 703 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 EXPECT_EQ("name=test old=1 new=2", PropertyChangeInfoAndClear()); 1033 EXPECT_EQ("name=test old=1 new=2", PropertyChangeInfoAndClear());
1022 w1->SetProperty(key, NULL); 1034 w1->SetProperty(key, NULL);
1023 EXPECT_EQ("name=test old=2 new=0", PropertyChangeInfoAndClear()); 1035 EXPECT_EQ("name=test old=2 new=0", PropertyChangeInfoAndClear());
1024 1036
1025 // Sanity check to see if |PropertyChangeInfoAndClear| really clears. 1037 // Sanity check to see if |PropertyChangeInfoAndClear| really clears.
1026 EXPECT_EQ("name= old=0 new=0", PropertyChangeInfoAndClear()); 1038 EXPECT_EQ("name= old=0 new=0", PropertyChangeInfoAndClear());
1027 } 1039 }
1028 1040
1029 } // namespace test 1041 } // namespace test
1030 } // namespace aura 1042 } // namespace aura
OLDNEW
« chrome/browser/chromeos/login/base_login_display_host.cc ('K') | « ui/aura/window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698