| 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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "ui/aura/test/aura_test_base.h" | 6 #include "ui/aura/test/aura_test_base.h" |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura_shell/shell.h" | 8 #include "ui/aura_shell/shell.h" |
| 9 #include "ui/aura_shell/shell_window_ids.h" | 9 #include "ui/aura_shell/shell_window_ids.h" |
| 10 #include "ui/aura_shell/test/aura_shell_test_base.h" | 10 #include "ui/aura_shell/test/aura_shell_test_base.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 aura::Window* modal_container = Shell::GetInstance()->GetContainer( | 196 aura::Window* modal_container = Shell::GetInstance()->GetContainer( |
| 197 aura_shell::internal::kShellWindowId_ModalContainer); | 197 aura_shell::internal::kShellWindowId_ModalContainer); |
| 198 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); | 198 EXPECT_EQ(modal_container, modal_widget->GetNativeWindow()->parent()); |
| 199 | 199 |
| 200 modal_widget->Close(); | 200 modal_widget->Close(); |
| 201 lock_modal_widget->Close(); | 201 lock_modal_widget->Close(); |
| 202 lock_widget->Close(); | 202 lock_widget->Close(); |
| 203 widget->Close(); | 203 widget->Close(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 TEST_F(ShellTest, IsScreenLocked) { |
| 207 views::Widget::InitParams widget_params( |
| 208 views::Widget::InitParams::TYPE_WINDOW); |
| 209 |
| 210 // A normal window does not lock the screen. |
| 211 views::Widget* widget = CreateTestWindow(widget_params); |
| 212 widget->Show(); |
| 213 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 214 widget->Hide(); |
| 215 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 216 |
| 217 // A modal window with a normal window as parent does not locks the screen. |
| 218 views::Widget* modal_widget = views::Widget::CreateWindowWithParent( |
| 219 new ModalWindow(), widget->GetNativeView()); |
| 220 modal_widget->Show(); |
| 221 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 222 modal_widget->Close(); |
| 223 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 224 widget->Close(); |
| 225 |
| 226 // A lock screen window locks the screen. |
| 227 views::Widget* lock_widget = CreateTestWindow(widget_params); |
| 228 aura_shell::Shell::GetInstance()->GetContainer( |
| 229 aura_shell::internal::kShellWindowId_LockScreenContainer)-> |
| 230 AddChild(lock_widget->GetNativeView()); |
| 231 lock_widget->Show(); |
| 232 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); |
| 233 lock_widget->Hide(); |
| 234 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 235 |
| 236 // A modal window with a lock window as parent locks the screen. |
| 237 views::Widget* lock_modal_widget = views::Widget::CreateWindowWithParent( |
| 238 new ModalWindow(), lock_widget->GetNativeView()); |
| 239 lock_modal_widget->Show(); |
| 240 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); |
| 241 lock_modal_widget->Close(); |
| 242 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 243 lock_widget->Close(); |
| 244 } |
| 245 |
| 206 } // namespace test | 246 } // namespace test |
| 207 } // namespace aura_shell | 247 } // namespace aura_shell |
| OLD | NEW |