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

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

Issue 8120014: Add a lock screen example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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/aura_shell/aura_shell.gyp » ('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) 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // entire bounds of the container. This test verifies that 578 // entire bounds of the container. This test verifies that
579 // GetEventHandlerForPoint() skips w12 even though its bounds contain the event, 579 // GetEventHandlerForPoint() skips w12 even though its bounds contain the event,
580 // because it has no children that can handle the event and it has no delegate 580 // because it has no children that can handle the event and it has no delegate
581 // allowing it to handle the event itself. 581 // allowing it to handle the event itself.
582 TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) { 582 TEST_F(WindowTest, GetEventHandlerForPoint_NoDelegate) {
583 WindowDelegateImpl d111; 583 WindowDelegateImpl d111;
584 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1, 584 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
585 gfx::Rect(0, 0, 500, 500), NULL)); 585 gfx::Rect(0, 0, 500, 500), NULL));
586 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(NULL, 11, 586 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(NULL, 11,
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, 1, 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 // 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
599 // children. If it does not have children, event targeting works as usual.
600 TEST_F(WindowTest, ConsumesEvents) {
601 WindowDelegateImpl d11;
602 WindowDelegateImpl d121;
603 scoped_ptr<Window> w1(CreateTestWindowWithDelegate(NULL, 1,
604 gfx::Rect(0, 0, 500, 500), NULL));
605 scoped_ptr<Window> w11(CreateTestWindowWithDelegate(&d11, 11,
606 gfx::Rect(0, 0, 500, 500), w1.get()));
607 scoped_ptr<Window> w111(CreateTestWindowWithDelegate(NULL, 111,
608 gfx::Rect(50, 50, 450, 450), w11.get()));
609 scoped_ptr<Window> w12(CreateTestWindowWithDelegate(NULL, 12,
610 gfx::Rect(0, 0, 500, 500), w1.get()));
611 scoped_ptr<Window> w121(CreateTestWindowWithDelegate(&d121, 121,
612 gfx::Rect(150, 150, 50, 50), NULL));
613
614 w12->set_consumes_events(true);
615 EXPECT_EQ(w11.get(), w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
616
617 w12->AddChild(w121.get());
618
619 EXPECT_EQ(NULL, w1->GetEventHandlerForPoint(gfx::Point(10, 10)));
620 EXPECT_EQ(w121.get(), w1->GetEventHandlerForPoint(gfx::Point(175, 175)));
621 }
622
597 } // namespace internal 623 } // namespace internal
598 } // namespace aura 624 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.cc ('k') | ui/aura_shell/aura_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698