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

Side by Side Diff: ash/wm/window_cycle_controller_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) 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 "ash/wm/window_cycle_controller.h" 5 #include "ash/wm/window_cycle_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 26 matching lines...) Expand all
37 37
38 // Cycling doesn't crash if there are no windows. 38 // Cycling doesn't crash if there are no windows.
39 EXPECT_TRUE(Shell::GetInstance()->delegate()->GetCycleWindowList().empty()); 39 EXPECT_TRUE(Shell::GetInstance()->delegate()->GetCycleWindowList().empty());
40 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 40 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
41 41
42 // Create a single test window. 42 // Create a single test window.
43 Window* default_container = 43 Window* default_container =
44 ash::Shell::GetInstance()->GetContainer( 44 ash::Shell::GetInstance()->GetContainer(
45 internal::kShellWindowId_DefaultContainer); 45 internal::kShellWindowId_DefaultContainer);
46 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); 46 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
47 window0->Show();
47 ActivateWindow(window0.get()); 48 ActivateWindow(window0.get());
48 EXPECT_TRUE(IsActiveWindow(window0.get())); 49 EXPECT_TRUE(IsActiveWindow(window0.get()));
49 50
50 // Cycling works for a single window, even though nothing changes. 51 // Cycling works for a single window, even though nothing changes.
51 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 52 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
52 EXPECT_TRUE(IsActiveWindow(window0.get())); 53 EXPECT_TRUE(IsActiveWindow(window0.get()));
53 } 54 }
54 55
55 TEST_F(WindowCycleControllerTest, HandleCycleWindow) { 56 TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
56 WindowCycleController* controller = 57 WindowCycleController* controller =
57 Shell::GetInstance()->window_cycle_controller(); 58 Shell::GetInstance()->window_cycle_controller();
58 59
59 // Set up several windows to use to test cycling. Create them in reverse 60 // Set up several windows to use to test cycling. Create them in reverse
60 // order so they are stacked 0 over 1 over 2. 61 // order so they are stacked 0 over 1 over 2.
61 Window* default_container = 62 Window* default_container =
62 Shell::GetInstance()->GetContainer( 63 Shell::GetInstance()->GetContainer(
63 internal::kShellWindowId_DefaultContainer); 64 internal::kShellWindowId_DefaultContainer);
64 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container)); 65 scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container));
65 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container)); 66 scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
66 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container)); 67 scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
68 window0->Show();
69 window1->Show();
70 window2->Show();
67 ActivateWindow(window0.get()); 71 ActivateWindow(window0.get());
68 72
69 // Window lists should return the topmost window in front. 73 // Window lists should return the topmost window in front.
70 std::vector<Window*> windows = 74 std::vector<Window*> windows =
71 Shell::GetInstance()->delegate()->GetCycleWindowList(); 75 Shell::GetInstance()->delegate()->GetCycleWindowList();
72 ASSERT_EQ(3u, windows.size()); 76 ASSERT_EQ(3u, windows.size());
73 ASSERT_EQ(window0.get(), windows[0]); 77 ASSERT_EQ(window0.get(), windows[0]);
74 ASSERT_EQ(window1.get(), windows[1]); 78 ASSERT_EQ(window1.get(), windows[1]);
75 ASSERT_EQ(window2.get(), windows[2]); 79 ASSERT_EQ(window2.get(), windows[2]);
76 80
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Passing false for is_alt_down does not start a cycle gesture. 126 // Passing false for is_alt_down does not start a cycle gesture.
123 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 127 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
124 EXPECT_FALSE(controller->IsCycling()); 128 EXPECT_FALSE(controller->IsCycling());
125 EXPECT_TRUE(IsActiveWindow(window1.get())); 129 EXPECT_TRUE(IsActiveWindow(window1.get()));
126 130
127 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 131 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
128 EXPECT_FALSE(controller->IsCycling()); 132 EXPECT_FALSE(controller->IsCycling());
129 EXPECT_TRUE(IsActiveWindow(window0.get())); 133 EXPECT_TRUE(IsActiveWindow(window0.get()));
130 134
131 // When a screen lock window is visible, cycling window does not take effect. 135 // When a screen lock window is visible, cycling window does not take effect.
132 aura::Window* lock_screen_container =
133 Shell::GetInstance()->GetContainer(
134 internal::kShellWindowId_LockScreenContainer);
135 scoped_ptr<Window> lock_screen_window( 136 scoped_ptr<Window> lock_screen_window(
136 CreateTestWindowWithId(-1, lock_screen_container)); 137 CreateTestWindowWithId(-1, default_container));
138 lock_screen_window->set_stops_event_propagation(true);
139 lock_screen_window->SetParent(NULL);
137 lock_screen_window->Show(); 140 lock_screen_window->Show();
138 EXPECT_TRUE(IsActiveWindow(window0.get())); 141 EXPECT_TRUE(IsActiveWindow(window0.get()));
139 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 142 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
140 EXPECT_TRUE(IsActiveWindow(window0.get())); 143 EXPECT_TRUE(IsActiveWindow(window0.get()));
141 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); 144 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
142 EXPECT_TRUE(IsActiveWindow(window0.get())); 145 EXPECT_TRUE(IsActiveWindow(window0.get()));
143 146
144 // Hiding the lock screen is equivalent to not being locked. 147 // Hiding the lock screen is equivalent to not being locked.
145 lock_screen_window->Hide(); 148 lock_screen_window->Hide();
146 EXPECT_TRUE(IsActiveWindow(window0.get())); 149 EXPECT_TRUE(IsActiveWindow(window0.get()));
147 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 150 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
148 EXPECT_TRUE(IsActiveWindow(window1.get())); 151 EXPECT_TRUE(IsActiveWindow(window1.get()));
149 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 152 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
150 EXPECT_TRUE(IsActiveWindow(window0.get())); 153 EXPECT_TRUE(IsActiveWindow(window0.get()));
151 154
152 // When a modal window is active, cycling window does not take effect. 155 // When a modal window is active, cycling window does not take effect.
153 aura::Window* modal_container = 156 aura::Window* modal_container =
154 ash::Shell::GetInstance()->GetContainer( 157 ash::Shell::GetInstance()->GetContainer(
155 internal::kShellWindowId_AlwaysOnTopContainer); 158 internal::kShellWindowId_AlwaysOnTopContainer);
156 scoped_ptr<Window> modal_window( 159 scoped_ptr<Window> modal_window(
157 CreateTestWindowWithId(-2, modal_container)); 160 CreateTestWindowWithId(-2, modal_container));
161 modal_window->Show();
158 ActivateWindow(modal_window.get()); 162 ActivateWindow(modal_window.get());
159 EXPECT_TRUE(IsActiveWindow(modal_window.get())); 163 EXPECT_TRUE(IsActiveWindow(modal_window.get()));
160 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); 164 controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
161 EXPECT_TRUE(IsActiveWindow(modal_window.get())); 165 EXPECT_TRUE(IsActiveWindow(modal_window.get()));
162 EXPECT_FALSE(IsActiveWindow(window0.get())); 166 EXPECT_FALSE(IsActiveWindow(window0.get()));
163 EXPECT_FALSE(IsActiveWindow(window1.get())); 167 EXPECT_FALSE(IsActiveWindow(window1.get()));
164 EXPECT_FALSE(IsActiveWindow(window2.get())); 168 EXPECT_FALSE(IsActiveWindow(window2.get()));
165 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); 169 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
166 EXPECT_TRUE(IsActiveWindow(modal_window.get())); 170 EXPECT_TRUE(IsActiveWindow(modal_window.get()));
167 EXPECT_FALSE(IsActiveWindow(window0.get())); 171 EXPECT_FALSE(IsActiveWindow(window0.get()));
168 EXPECT_FALSE(IsActiveWindow(window1.get())); 172 EXPECT_FALSE(IsActiveWindow(window1.get()));
169 EXPECT_FALSE(IsActiveWindow(window2.get())); 173 EXPECT_FALSE(IsActiveWindow(window2.get()));
170 } 174 }
171 175
172 } // namespace ash 176 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698