| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/session/session_state_delegate.h" | 5 #include "ash/session/session_state_delegate.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "ash/shell_window_ids.h" | 7 #include "ash/shell_window_ids.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/test/ash_test_helper.h" | 9 #include "ash/test/ash_test_helper.h" |
| 10 #include "ash/test/test_session_state_delegate.h" | 10 #include "ash/test/test_session_state_delegate.h" |
| 11 #include "ash/test/test_shell_delegate.h" | 11 #include "ash/test/test_shell_delegate.h" |
| 12 #include "ash/wm/lock_state_controller.h" | 12 #include "ash/wm/lock_state_controller.h" |
| 13 #include "ash/wm/window_state.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/client/window_tree_client.h" | 16 #include "ui/aura/client/window_tree_client.h" |
| 17 #include "ui/views/test/widget_test.h" |
| 17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 18 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 namespace test { | 22 namespace test { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Defines a |SessionStateDelegate| that is used to create and destroy the | 26 // Defines a |SessionStateDelegate| that is used to create and destroy the |
| 26 // test lock screen widget. | 27 // test lock screen widget. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 180 |
| 180 EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked()); | 181 EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked()); |
| 181 EXPECT_FALSE(normal_window_state->IsMinimized()); | 182 EXPECT_FALSE(normal_window_state->IsMinimized()); |
| 182 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); | 183 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); |
| 183 EXPECT_TRUE(normal_window_state->CanActivate()); | 184 EXPECT_TRUE(normal_window_state->CanActivate()); |
| 184 EXPECT_TRUE(always_on_top_window_state->CanActivate()); | 185 EXPECT_TRUE(always_on_top_window_state->CanActivate()); |
| 185 EXPECT_FALSE(always_on_top_window->HasFocus()); | 186 EXPECT_FALSE(always_on_top_window->HasFocus()); |
| 186 EXPECT_TRUE(normal_window->HasFocus()); | 187 EXPECT_TRUE(normal_window->HasFocus()); |
| 187 } | 188 } |
| 188 | 189 |
| 190 // Tests that if a widget has a view which should be initially focused, this |
| 191 // view doesn't get focused if the widget shows behind the lock screen. |
| 192 TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) { |
| 193 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); |
| 194 EXPECT_TRUE(shell()->session_state_delegate()->IsScreenLocked()); |
| 195 |
| 196 views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext()); |
| 197 EXPECT_FALSE(delegate.view()->HasFocus()); |
| 198 delegate.GetWidget()->Show(); |
| 199 EXPECT_FALSE(delegate.GetWidget()->IsActive()); |
| 200 EXPECT_FALSE(delegate.view()->HasFocus()); |
| 201 |
| 202 UnblockUserSession(); |
| 203 EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked()); |
| 204 EXPECT_TRUE(delegate.GetWidget()->IsActive()); |
| 205 EXPECT_TRUE(delegate.view()->HasFocus()); |
| 206 } |
| 207 |
| 189 } // namespace test | 208 } // namespace test |
| 190 } // namespace ash | 209 } // namespace ash |
| OLD | NEW |