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

Side by Side Diff: ui/aura_shell/stacking_controller_unittest.cc

Issue 8536027: Add test to verify that the stacking controller picks the correct activatable window for menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 1 month 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/test/test_windows.cc ('k') | no next file » | 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 "ui/aura_shell/stacking_controller.h" 5 #include "ui/aura_shell/stacking_controller.h"
6 6
7 #include "ui/aura/desktop.h" 7 #include "ui/aura/desktop.h"
8 #include "ui/aura/test/event_generator.h"
8 #include "ui/aura/test/test_windows.h" 9 #include "ui/aura/test/test_windows.h"
9 #include "ui/aura/test/test_window_delegate.h" 10 #include "ui/aura/test/test_window_delegate.h"
10 #include "ui/aura_shell/test/aura_shell_test_base.h" 11 #include "ui/aura_shell/test/aura_shell_test_base.h"
11 12
12 namespace aura_shell { 13 namespace aura_shell {
13 namespace test { 14 namespace test {
14 15
15 typedef aura_shell::test::AuraShellTestBase StackingControllerTest; 16 typedef aura_shell::test::AuraShellTestBase StackingControllerTest;
16 17
17 TEST_F(StackingControllerTest, GetTopmostWindowToActivate) { 18 TEST_F(StackingControllerTest, GetTopmostWindowToActivate) {
18 aura::test::ActivateWindowDelegate activate; 19 aura::test::ActivateWindowDelegate activate;
19 aura::test::ActivateWindowDelegate non_activate(false); 20 aura::test::ActivateWindowDelegate non_activate(false);
20 21
21 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( 22 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
22 &non_activate, 1, gfx::Rect(), NULL)); 23 &non_activate, 1, gfx::Rect(), NULL));
23 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( 24 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate(
24 &activate, 2, gfx::Rect(), NULL)); 25 &activate, 2, gfx::Rect(), NULL));
25 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate( 26 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate(
26 &non_activate, 3, gfx::Rect(), NULL)); 27 &non_activate, 3, gfx::Rect(), NULL));
27 EXPECT_EQ(w2.get(), aura::Desktop::GetInstance()->stacking_client()-> 28 EXPECT_EQ(w2.get(), aura::Desktop::GetInstance()->stacking_client()->
28 GetTopmostWindowToActivate(NULL)); 29 GetTopmostWindowToActivate(NULL));
29 } 30 }
30 31
32 // Test if the clicking on a menu picks the transient parent as activatable
33 // window.
34 TEST_F(StackingControllerTest, ClickOnMenu) {
35 aura::test::ActivateWindowDelegate activate;
36 aura::test::ActivateWindowDelegate non_activate(false);
37
38 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(
39 &activate, 1, gfx::Rect(100, 100), NULL));
40 EXPECT_EQ(NULL, aura::Desktop::GetInstance()->active_window());
41
42 // Clicking on an activatable window activtes the window.
43 aura::test::EventGenerator generator(w1.get());
44 generator.ClickLeftButton();
45 EXPECT_EQ(w1.get(), aura::Desktop::GetInstance()->active_window());
46
47 // Creates a menu that covers the transient parent.
48 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType(
49 &non_activate, aura::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL));
50 w1->AddTransientChild(menu.get());
51
52 // Clicking on a menu whose transient parent is active window shouldn't
53 // change the active window.
54 generator.ClickLeftButton();
55 EXPECT_EQ(w1.get(), aura::Desktop::GetInstance()->active_window());
56 }
57
31 } // namespace test 58 } // namespace test
32 } // namespace aura_shell 59 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura/test/test_windows.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698