OLD | NEW |
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/test/test_window_delegate.h" |
| 6 #include "ui/aura/test/test_windows.h" |
| 7 #include "ui/aura/window.h" |
5 #include "ui/aura_shell/shell.h" | 8 #include "ui/aura_shell/shell.h" |
6 #include "ui/aura_shell/shell_accelerator_controller.h" | 9 #include "ui/aura_shell/shell_accelerator_controller.h" |
| 10 #include "ui/aura_shell/shell_window_ids.h" |
7 #include "ui/aura_shell/test/aura_shell_test_base.h" | 11 #include "ui/aura_shell/test/aura_shell_test_base.h" |
8 | 12 |
9 namespace aura_shell { | 13 namespace aura_shell { |
10 namespace test { | 14 namespace test { |
11 | 15 |
12 namespace { | 16 namespace { |
13 class TestTarget : public ui::AcceleratorTarget { | 17 class TestTarget : public ui::AcceleratorTarget { |
14 public: | 18 public: |
15 TestTarget() : accelerator_pressed_(false) {}; | 19 TestTarget() : accelerator_pressed_(false) {}; |
16 virtual ~TestTarget() {}; | 20 virtual ~TestTarget() {}; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 EXPECT_TRUE(GetController()->Process( | 162 EXPECT_TRUE(GetController()->Process( |
159 ui::Accelerator(ui::VKEY_HOME, false, true, false))); | 163 ui::Accelerator(ui::VKEY_HOME, false, true, false))); |
160 #if !defined(OS_LINUX) | 164 #if !defined(OS_LINUX) |
161 // ToggleDesktopFullScreen (not implemented yet on Linux) | 165 // ToggleDesktopFullScreen (not implemented yet on Linux) |
162 EXPECT_TRUE(GetController()->Process( | 166 EXPECT_TRUE(GetController()->Process( |
163 ui::Accelerator(ui::VKEY_F11, false, true, false))); | 167 ui::Accelerator(ui::VKEY_F11, false, true, false))); |
164 #endif | 168 #endif |
165 #endif | 169 #endif |
166 } | 170 } |
167 | 171 |
| 172 TEST_F(ShellAcceleratorControllerTest, HandleCycleWindow) { |
| 173 aura::Window* default_container = |
| 174 aura_shell::Shell::GetInstance()->GetContainer( |
| 175 internal::kShellWindowId_DefaultContainer); |
| 176 aura::Window* window0 = aura::test::CreateTestWindowWithDelegate( |
| 177 new aura::test::TestWindowDelegate, |
| 178 -1, |
| 179 gfx::Rect(), |
| 180 default_container); |
| 181 aura::Window* window1 = aura::test::CreateTestWindowWithDelegate( |
| 182 new aura::test::TestWindowDelegate, |
| 183 -1, |
| 184 gfx::Rect(), |
| 185 default_container); |
| 186 aura::Window* window2 = aura::test::CreateTestWindowWithDelegate( |
| 187 new aura::test::TestWindowDelegate, |
| 188 -1, |
| 189 gfx::Rect(), |
| 190 default_container); |
| 191 window0->Activate(); |
| 192 EXPECT_TRUE(window0->IsActive()); |
| 193 |
| 194 ui::Accelerator cycle_forward(ui::VKEY_TAB, false, false, true); |
| 195 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 196 EXPECT_TRUE(window1->IsActive()); |
| 197 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 198 EXPECT_TRUE(window2->IsActive()); |
| 199 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 200 EXPECT_TRUE(window0->IsActive()); |
| 201 |
| 202 ui::Accelerator cycle_backward(ui::VKEY_TAB, true, false, true); |
| 203 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 204 EXPECT_TRUE(window2->IsActive()); |
| 205 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 206 EXPECT_TRUE(window1->IsActive()); |
| 207 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 208 EXPECT_TRUE(window0->IsActive()); |
| 209 |
| 210 aura::Window* modal_container = |
| 211 aura_shell::Shell::GetInstance()->GetContainer( |
| 212 internal::kShellWindowId_AlwaysOnTopContainer); |
| 213 aura::Window* modal_window = aura::test::CreateTestWindowWithDelegate( |
| 214 new aura::test::TestWindowDelegate, |
| 215 -1, |
| 216 gfx::Rect(), |
| 217 modal_container); |
| 218 |
| 219 // When the modal window is active, cycling window does not take effect. |
| 220 modal_window->Activate(); |
| 221 EXPECT_TRUE(modal_window->IsActive()); |
| 222 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
| 223 EXPECT_TRUE(modal_window->IsActive()); |
| 224 EXPECT_FALSE(window0->IsActive()); |
| 225 EXPECT_FALSE(window1->IsActive()); |
| 226 EXPECT_FALSE(window2->IsActive()); |
| 227 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
| 228 EXPECT_TRUE(modal_window->IsActive()); |
| 229 EXPECT_FALSE(window0->IsActive()); |
| 230 EXPECT_FALSE(window1->IsActive()); |
| 231 EXPECT_FALSE(window2->IsActive()); |
| 232 |
| 233 // The modal window is not activated by cycling window. |
| 234 window0->Activate(); |
| 235 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 236 EXPECT_FALSE(modal_window->IsActive()); |
| 237 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 238 EXPECT_FALSE(modal_window->IsActive()); |
| 239 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 240 EXPECT_FALSE(modal_window->IsActive()); |
| 241 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 242 EXPECT_FALSE(modal_window->IsActive()); |
| 243 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 244 EXPECT_FALSE(modal_window->IsActive()); |
| 245 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 246 EXPECT_FALSE(modal_window->IsActive()); |
| 247 |
| 248 // When a screen lock window is visible, cycling window does not take effect. |
| 249 aura::Window* lock_screen_container = |
| 250 aura_shell::Shell::GetInstance()->GetContainer( |
| 251 internal::kShellWindowId_LockScreenContainer); |
| 252 aura::Window* lock_screen_window = aura::test::CreateTestWindowWithDelegate( |
| 253 new aura::test::TestWindowDelegate, |
| 254 -1, |
| 255 gfx::Rect(), |
| 256 lock_screen_container); |
| 257 |
| 258 lock_screen_window->Show(); |
| 259 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
| 260 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
| 261 lock_screen_window->Hide(); |
| 262 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 263 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 264 |
| 265 aura::Window* lock_modal_container = |
| 266 aura_shell::Shell::GetInstance()->GetContainer( |
| 267 internal::kShellWindowId_LockModalContainer); |
| 268 aura::Window* lock_modal_window = aura::test::CreateTestWindowWithDelegate( |
| 269 new aura::test::TestWindowDelegate, |
| 270 -1, |
| 271 gfx::Rect(), |
| 272 lock_modal_container); |
| 273 |
| 274 lock_modal_window->Show(); |
| 275 EXPECT_FALSE(GetController()->Process(cycle_forward)); |
| 276 EXPECT_FALSE(GetController()->Process(cycle_backward)); |
| 277 lock_modal_window->Hide(); |
| 278 EXPECT_TRUE(GetController()->Process(cycle_forward)); |
| 279 EXPECT_TRUE(GetController()->Process(cycle_backward)); |
| 280 } |
| 281 |
168 } // namespace test | 282 } // namespace test |
169 } // namespace aura_shell | 283 } // namespace aura_shell |
OLD | NEW |