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/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/session/session_controller.h" | 10 #include "ash/common/session/session_controller.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void LockScreenAndVerifyMenuClosed() { | 157 void LockScreenAndVerifyMenuClosed() { |
158 // Verify a menu is open before locking. | 158 // Verify a menu is open before locking. |
159 views::MenuController* menu_controller = | 159 views::MenuController* menu_controller = |
160 views::MenuController::GetActiveInstance(); | 160 views::MenuController::GetActiveInstance(); |
161 DCHECK(menu_controller); | 161 DCHECK(menu_controller); |
162 EXPECT_EQ(views::MenuController::EXIT_NONE, menu_controller->exit_type()); | 162 EXPECT_EQ(views::MenuController::EXIT_NONE, menu_controller->exit_type()); |
163 | 163 |
164 // Create a LockScreen window. | 164 // Create a LockScreen window. |
165 views::Widget::InitParams widget_params( | 165 views::Widget::InitParams widget_params( |
166 views::Widget::InitParams::TYPE_WINDOW); | 166 views::Widget::InitParams::TYPE_WINDOW); |
167 SessionController* controller = WmShell::Get()->session_controller(); | 167 SessionController* controller = Shell::Get()->session_controller(); |
168 controller->LockScreenAndFlushForTest(); | 168 controller->LockScreenAndFlushForTest(); |
169 views::Widget* lock_widget = CreateTestWindow(widget_params); | 169 views::Widget* lock_widget = CreateTestWindow(widget_params); |
170 Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 170 Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
171 kShellWindowId_LockScreenContainer) | 171 kShellWindowId_LockScreenContainer) |
172 ->AddChild(lock_widget->GetNativeView()); | 172 ->AddChild(lock_widget->GetNativeView()); |
173 lock_widget->Show(); | 173 lock_widget->Show(); |
174 EXPECT_TRUE(controller->IsScreenLocked()); | 174 EXPECT_TRUE(controller->IsScreenLocked()); |
175 EXPECT_TRUE(lock_widget->GetNativeView()->HasFocus()); | 175 EXPECT_TRUE(lock_widget->GetNativeView()->HasFocus()); |
176 | 176 |
177 // Verify menu is closed. | 177 // Verify menu is closed. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 // Create a normal window. | 272 // Create a normal window. |
273 views::Widget* widget = CreateTestWindow(widget_params); | 273 views::Widget* widget = CreateTestWindow(widget_params); |
274 widget->Show(); | 274 widget->Show(); |
275 EXPECT_TRUE(widget->GetNativeView()->HasFocus()); | 275 EXPECT_TRUE(widget->GetNativeView()->HasFocus()); |
276 | 276 |
277 // It should be in default container. | 277 // It should be in default container. |
278 EXPECT_TRUE( | 278 EXPECT_TRUE( |
279 GetDefaultContainer()->Contains(widget->GetNativeWindow()->parent())); | 279 GetDefaultContainer()->Contains(widget->GetNativeWindow()->parent())); |
280 | 280 |
281 WmShell::Get()->session_controller()->LockScreenAndFlushForTest(); | 281 Shell::Get()->session_controller()->LockScreenAndFlushForTest(); |
282 // Create a LockScreen window. | 282 // Create a LockScreen window. |
283 views::Widget* lock_widget = CreateTestWindow(widget_params); | 283 views::Widget* lock_widget = CreateTestWindow(widget_params); |
284 Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 284 Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
285 kShellWindowId_LockScreenContainer) | 285 kShellWindowId_LockScreenContainer) |
286 ->AddChild(lock_widget->GetNativeView()); | 286 ->AddChild(lock_widget->GetNativeView()); |
287 lock_widget->Show(); | 287 lock_widget->Show(); |
288 EXPECT_TRUE(lock_widget->GetNativeView()->HasFocus()); | 288 EXPECT_TRUE(lock_widget->GetNativeView()->HasFocus()); |
289 | 289 |
290 // It should be in LockScreen container. | 290 // It should be in LockScreen container. |
291 aura::Window* lock_screen = Shell::GetContainer( | 291 aura::Window* lock_screen = Shell::GetContainer( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 modal_dialog->Close(); | 329 modal_dialog->Close(); |
330 modal_widget->Close(); | 330 modal_widget->Close(); |
331 modal_widget->Close(); | 331 modal_widget->Close(); |
332 lock_modal_widget->Close(); | 332 lock_modal_widget->Close(); |
333 lock_widget->Close(); | 333 lock_widget->Close(); |
334 widget->Close(); | 334 widget->Close(); |
335 } | 335 } |
336 | 336 |
337 TEST_F(ShellTest, IsScreenLocked) { | 337 TEST_F(ShellTest, IsScreenLocked) { |
338 SessionController* controller = WmShell::Get()->session_controller(); | 338 SessionController* controller = Shell::Get()->session_controller(); |
339 controller->LockScreenAndFlushForTest(); | 339 controller->LockScreenAndFlushForTest(); |
340 EXPECT_TRUE(controller->IsScreenLocked()); | 340 EXPECT_TRUE(controller->IsScreenLocked()); |
341 GetSessionControllerClient()->UnlockScreen(); | 341 GetSessionControllerClient()->UnlockScreen(); |
342 EXPECT_FALSE(controller->IsScreenLocked()); | 342 EXPECT_FALSE(controller->IsScreenLocked()); |
343 } | 343 } |
344 | 344 |
345 TEST_F(ShellTest, LockScreenClosesActiveMenu) { | 345 TEST_F(ShellTest, LockScreenClosesActiveMenu) { |
346 SimpleMenuDelegate menu_delegate; | 346 SimpleMenuDelegate menu_delegate; |
347 std::unique_ptr<ui::SimpleMenuModel> menu_model( | 347 std::unique_ptr<ui::SimpleMenuModel> menu_model( |
348 new ui::SimpleMenuModel(&menu_delegate)); | 348 new ui::SimpleMenuModel(&menu_delegate)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // the case with classic-ash where embedders can separately create | 511 // the case with classic-ash where embedders can separately create |
512 // aura::Windows. | 512 // aura::Windows. |
513 if (WmShell::Get()->IsRunningInMash()) | 513 if (WmShell::Get()->IsRunningInMash()) |
514 return; | 514 return; |
515 | 515 |
516 window_.reset(new aura::Window(NULL)); | 516 window_.reset(new aura::Window(NULL)); |
517 window_->Init(ui::LAYER_NOT_DRAWN); | 517 window_->Init(ui::LAYER_NOT_DRAWN); |
518 } | 518 } |
519 | 519 |
520 } // namespace ash | 520 } // namespace ash |
OLD | NEW |