| 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/common/session/session_controller.h" | 5 #include "ash/common/session/session_controller.h" |
| 6 #include "ash/common/test/test_session_controller_client.h" | 6 #include "ash/common/test/test_session_controller_client.h" |
| 7 #include "ash/common/wm/window_state.h" | 7 #include "ash/common/wm/window_state.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // |AshFocusRules| when locking and unlocking the screen. | 87 // |AshFocusRules| when locking and unlocking the screen. |
| 88 class LockScreenAshFocusRulesTest : public AshTestBase { | 88 class LockScreenAshFocusRulesTest : public AshTestBase { |
| 89 public: | 89 public: |
| 90 LockScreenAshFocusRulesTest() {} | 90 LockScreenAshFocusRulesTest() {} |
| 91 ~LockScreenAshFocusRulesTest() override {} | 91 ~LockScreenAshFocusRulesTest() override {} |
| 92 | 92 |
| 93 void SetUp() override { | 93 void SetUp() override { |
| 94 AshTestBase::SetUp(); | 94 AshTestBase::SetUp(); |
| 95 ash_test_helper()->set_test_session_controller_client( | 95 ash_test_helper()->set_test_session_controller_client( |
| 96 base::MakeUnique<LockScreenSessionControllerClient>( | 96 base::MakeUnique<LockScreenSessionControllerClient>( |
| 97 WmShell::Get()->session_controller())); | 97 Shell::Get()->session_controller())); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void TearDown() override { AshTestBase::TearDown(); } | 100 void TearDown() override { AshTestBase::TearDown(); } |
| 101 | 101 |
| 102 aura::Window* CreateWindowInDefaultContainer() { | 102 aura::Window* CreateWindowInDefaultContainer() { |
| 103 return CreateWindowInContainer(kShellWindowId_DefaultContainer); | 103 return CreateWindowInContainer(kShellWindowId_DefaultContainer); |
| 104 } | 104 } |
| 105 | 105 |
| 106 aura::Window* CreateWindowInAlwaysOnTopContainer() { | 106 aura::Window* CreateWindowInAlwaysOnTopContainer() { |
| 107 aura::Window* window = | 107 aura::Window* window = |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 wm::WindowState* normal_window_state = | 156 wm::WindowState* normal_window_state = |
| 157 wm::GetWindowState(normal_window.get()); | 157 wm::GetWindowState(normal_window.get()); |
| 158 wm::WindowState* always_on_top_window_state = | 158 wm::WindowState* always_on_top_window_state = |
| 159 wm::GetWindowState(always_on_top_window.get()); | 159 wm::GetWindowState(always_on_top_window.get()); |
| 160 | 160 |
| 161 EXPECT_TRUE(normal_window_state->CanActivate()); | 161 EXPECT_TRUE(normal_window_state->CanActivate()); |
| 162 EXPECT_TRUE(always_on_top_window_state->CanActivate()); | 162 EXPECT_TRUE(always_on_top_window_state->CanActivate()); |
| 163 | 163 |
| 164 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); | 164 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); |
| 165 | 165 |
| 166 EXPECT_TRUE(WmShell::Get()->session_controller()->IsScreenLocked()); | 166 EXPECT_TRUE(Shell::Get()->session_controller()->IsScreenLocked()); |
| 167 EXPECT_FALSE(normal_window->HasFocus()); | 167 EXPECT_FALSE(normal_window->HasFocus()); |
| 168 EXPECT_FALSE(always_on_top_window->HasFocus()); | 168 EXPECT_FALSE(always_on_top_window->HasFocus()); |
| 169 EXPECT_FALSE(normal_window_state->IsMinimized()); | 169 EXPECT_FALSE(normal_window_state->IsMinimized()); |
| 170 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); | 170 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); |
| 171 EXPECT_FALSE(normal_window_state->CanActivate()); | 171 EXPECT_FALSE(normal_window_state->CanActivate()); |
| 172 EXPECT_FALSE(always_on_top_window_state->CanActivate()); | 172 EXPECT_FALSE(always_on_top_window_state->CanActivate()); |
| 173 | 173 |
| 174 UnblockUserSession(); | 174 UnblockUserSession(); |
| 175 | 175 |
| 176 EXPECT_FALSE(WmShell::Get()->session_controller()->IsScreenLocked()); | 176 EXPECT_FALSE(Shell::Get()->session_controller()->IsScreenLocked()); |
| 177 EXPECT_FALSE(normal_window_state->IsMinimized()); | 177 EXPECT_FALSE(normal_window_state->IsMinimized()); |
| 178 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); | 178 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); |
| 179 EXPECT_TRUE(normal_window_state->CanActivate()); | 179 EXPECT_TRUE(normal_window_state->CanActivate()); |
| 180 EXPECT_TRUE(always_on_top_window_state->CanActivate()); | 180 EXPECT_TRUE(always_on_top_window_state->CanActivate()); |
| 181 EXPECT_FALSE(always_on_top_window->HasFocus()); | 181 EXPECT_FALSE(always_on_top_window->HasFocus()); |
| 182 EXPECT_TRUE(normal_window->HasFocus()); | 182 EXPECT_TRUE(normal_window->HasFocus()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Tests that if a widget has a view which should be initially focused, this | 185 // Tests that if a widget has a view which should be initially focused, this |
| 186 // view doesn't get focused if the widget shows behind the lock screen. | 186 // view doesn't get focused if the widget shows behind the lock screen. |
| 187 TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) { | 187 TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) { |
| 188 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); | 188 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); |
| 189 EXPECT_TRUE(WmShell::Get()->session_controller()->IsScreenLocked()); | 189 EXPECT_TRUE(Shell::Get()->session_controller()->IsScreenLocked()); |
| 190 | 190 |
| 191 views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext()); | 191 views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext()); |
| 192 EXPECT_FALSE(delegate.view()->HasFocus()); | 192 EXPECT_FALSE(delegate.view()->HasFocus()); |
| 193 delegate.GetWidget()->Show(); | 193 delegate.GetWidget()->Show(); |
| 194 EXPECT_FALSE(delegate.GetWidget()->IsActive()); | 194 EXPECT_FALSE(delegate.GetWidget()->IsActive()); |
| 195 EXPECT_FALSE(delegate.view()->HasFocus()); | 195 EXPECT_FALSE(delegate.view()->HasFocus()); |
| 196 | 196 |
| 197 UnblockUserSession(); | 197 UnblockUserSession(); |
| 198 EXPECT_FALSE(WmShell::Get()->session_controller()->IsScreenLocked()); | 198 EXPECT_FALSE(Shell::Get()->session_controller()->IsScreenLocked()); |
| 199 EXPECT_TRUE(delegate.GetWidget()->IsActive()); | 199 EXPECT_TRUE(delegate.GetWidget()->IsActive()); |
| 200 EXPECT_TRUE(delegate.view()->HasFocus()); | 200 EXPECT_TRUE(delegate.view()->HasFocus()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace test | 203 } // namespace test |
| 204 } // namespace ash | 204 } // namespace ash |
| OLD | NEW |