| OLD | NEW |
| 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/ash_switches.h" | 5 #include "ash/ash_switches.h" |
| 6 #include "ash/launcher/launcher.h" | 6 #include "ash/launcher/launcher.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" |
| 8 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/root_window_layout_manager.h" | 11 #include "ash/wm/root_window_layout_manager.h" |
| 11 #include "ash/wm/shelf_layout_manager.h" | 12 #include "ash/wm/shelf_layout_manager.h" |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 15 #include "ui/aura/test/aura_test_base.h" | 16 #include "ui/aura/test/aura_test_base.h" |
| 16 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 ash::internal::kShellWindowId_SystemModalContainer); | 238 ash::internal::kShellWindowId_SystemModalContainer); |
| 238 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); | 239 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); |
| 239 | 240 |
| 240 modal_widget->Close(); | 241 modal_widget->Close(); |
| 241 lock_modal_widget->Close(); | 242 lock_modal_widget->Close(); |
| 242 lock_widget->Close(); | 243 lock_widget->Close(); |
| 243 widget->Close(); | 244 widget->Close(); |
| 244 } | 245 } |
| 245 | 246 |
| 246 TEST_F(ShellTest, IsScreenLocked) { | 247 TEST_F(ShellTest, IsScreenLocked) { |
| 247 views::Widget::InitParams widget_params( | 248 ash::Shell::GetInstance()->delegate()->LockScreen(); |
| 248 views::Widget::InitParams::TYPE_WINDOW); | |
| 249 | |
| 250 // A normal window does not lock the screen. | |
| 251 views::Widget* widget = CreateTestWindow(widget_params); | |
| 252 widget->Show(); | |
| 253 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 254 widget->Hide(); | |
| 255 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 256 | |
| 257 // A modal window with a normal window as parent does not locks the screen. | |
| 258 views::Widget* modal_widget = views::Widget::CreateWindowWithParent( | |
| 259 new ModalWindow(), widget->GetNativeView()); | |
| 260 modal_widget->Show(); | |
| 261 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 262 modal_widget->Close(); | |
| 263 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 264 widget->Close(); | |
| 265 | |
| 266 // A lock screen window locks the screen. | |
| 267 views::Widget* lock_widget = CreateTestWindow(widget_params); | |
| 268 ash::Shell::GetInstance()->GetContainer( | |
| 269 ash::internal::kShellWindowId_LockScreenContainer)-> | |
| 270 AddChild(lock_widget->GetNativeView()); | |
| 271 lock_widget->Show(); | |
| 272 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); | 249 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); |
| 273 lock_widget->Hide(); | 250 ash::Shell::GetInstance()->delegate()->UnlockScreen(); |
| 274 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 275 | |
| 276 // A modal window with a lock window as parent does not lock the screen. The | |
| 277 // screen is locked only when a lock window is visible. | |
| 278 views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent( | |
| 279 new ModalWindow(), lock_widget->GetNativeView()); | |
| 280 lock_modal_widget->Show(); | |
| 281 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | |
| 282 lock_widget->Show(); | |
| 283 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); | |
| 284 lock_modal_widget->Close(); | |
| 285 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); | |
| 286 lock_widget->Close(); | |
| 287 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | 251 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 288 } | 252 } |
| 289 | 253 |
| 290 // Fails on Mac, see http://crbug.com/115662 | 254 // Fails on Mac, see http://crbug.com/115662 |
| 291 #if defined(OS_MACOSX) | 255 #if defined(OS_MACOSX) |
| 292 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics | 256 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics |
| 293 #else | 257 #else |
| 294 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics | 258 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics |
| 295 #endif | 259 #endif |
| 296 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { | 260 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // Restoring the window restores it. | 311 // Restoring the window restores it. |
| 348 widget->Restore(); | 312 widget->Restore(); |
| 349 EXPECT_EQ(internal::ShelfLayoutManager::VISIBLE, | 313 EXPECT_EQ(internal::ShelfLayoutManager::VISIBLE, |
| 350 Shell::GetInstance()->shelf()->visibility_state()); | 314 Shell::GetInstance()->shelf()->visibility_state()); |
| 351 | 315 |
| 352 // Clean up. | 316 // Clean up. |
| 353 widget->Close(); | 317 widget->Close(); |
| 354 } | 318 } |
| 355 | 319 |
| 356 } // namespace ash | 320 } // namespace ash |
| OLD | NEW |