Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Side by Side Diff: ash/wm/ash_focus_rules_unittest.cc

Issue 2111443002: mash: Migrate SessionStateDelegate access to WmShell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_state_delegate.h" 5 #include "ash/common/session/session_state_delegate.h"
6 #include "ash/common/shell_window_ids.h" 6 #include "ash/common/shell_window_ids.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/shell.h" 9 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
10 #include "ash/test/ash_test_helper.h" 11 #include "ash/test/ash_test_helper.h"
11 #include "ash/test/test_session_state_delegate.h" 12 #include "ash/test/test_session_state_delegate.h"
12 #include "ash/test/test_shell_delegate.h" 13 #include "ash/test/test_shell_delegate.h"
13 #include "ash/wm/lock_state_controller.h" 14 #include "ash/wm/lock_state_controller.h"
14 #include "ash/wm/window_state_aura.h" 15 #include "ash/wm/window_state_aura.h"
15 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
16 #include "ui/aura/client/aura_constants.h" 17 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/client/window_tree_client.h" 18 #include "ui/aura/client/window_tree_client.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return CreateWindowInContainer(kShellWindowId_DefaultContainer); 112 return CreateWindowInContainer(kShellWindowId_DefaultContainer);
112 } 113 }
113 114
114 aura::Window* CreateWindowInAlwaysOnTopContainer() { 115 aura::Window* CreateWindowInAlwaysOnTopContainer() {
115 aura::Window* window = 116 aura::Window* window =
116 CreateWindowInContainer(kShellWindowId_AlwaysOnTopContainer); 117 CreateWindowInContainer(kShellWindowId_AlwaysOnTopContainer);
117 window->SetProperty(aura::client::kAlwaysOnTopKey, true); 118 window->SetProperty(aura::client::kAlwaysOnTopKey, true);
118 return window; 119 return window;
119 } 120 }
120 121
121 Shell* shell() const { return Shell::GetInstance(); }
122
123 private: 122 private:
124 aura::Window* CreateWindowInContainer(int container_id) { 123 aura::Window* CreateWindowInContainer(int container_id) {
125 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 124 aura::Window* root_window = Shell::GetPrimaryRootWindow();
126 aura::Window* container = Shell::GetContainer(root_window, container_id); 125 aura::Window* container = Shell::GetContainer(root_window, container_id);
127 aura::Window* window = new aura::Window(nullptr); 126 aura::Window* window = new aura::Window(nullptr);
128 window->set_id(0); 127 window->set_id(0);
129 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 128 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
130 window->Init(ui::LAYER_TEXTURED); 129 window->Init(ui::LAYER_TEXTURED);
131 window->Show(); 130 window->Show();
132 131
(...skipping 29 matching lines...) Expand all
162 wm::WindowState* normal_window_state = 161 wm::WindowState* normal_window_state =
163 wm::GetWindowState(normal_window.get()); 162 wm::GetWindowState(normal_window.get());
164 wm::WindowState* always_on_top_window_state = 163 wm::WindowState* always_on_top_window_state =
165 wm::GetWindowState(always_on_top_window.get()); 164 wm::GetWindowState(always_on_top_window.get());
166 165
167 EXPECT_TRUE(normal_window_state->CanActivate()); 166 EXPECT_TRUE(normal_window_state->CanActivate());
168 EXPECT_TRUE(always_on_top_window_state->CanActivate()); 167 EXPECT_TRUE(always_on_top_window_state->CanActivate());
169 168
170 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); 169 BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
171 170
172 EXPECT_TRUE(shell()->session_state_delegate()->IsScreenLocked()); 171 EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
173 EXPECT_FALSE(normal_window->HasFocus()); 172 EXPECT_FALSE(normal_window->HasFocus());
174 EXPECT_FALSE(always_on_top_window->HasFocus()); 173 EXPECT_FALSE(always_on_top_window->HasFocus());
175 EXPECT_FALSE(normal_window_state->IsMinimized()); 174 EXPECT_FALSE(normal_window_state->IsMinimized());
176 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); 175 EXPECT_FALSE(always_on_top_window_state->IsMinimized());
177 EXPECT_FALSE(normal_window_state->CanActivate()); 176 EXPECT_FALSE(normal_window_state->CanActivate());
178 EXPECT_FALSE(always_on_top_window_state->CanActivate()); 177 EXPECT_FALSE(always_on_top_window_state->CanActivate());
179 178
180 UnblockUserSession(); 179 UnblockUserSession();
181 180
182 EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked()); 181 EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
183 EXPECT_FALSE(normal_window_state->IsMinimized()); 182 EXPECT_FALSE(normal_window_state->IsMinimized());
184 EXPECT_FALSE(always_on_top_window_state->IsMinimized()); 183 EXPECT_FALSE(always_on_top_window_state->IsMinimized());
185 EXPECT_TRUE(normal_window_state->CanActivate()); 184 EXPECT_TRUE(normal_window_state->CanActivate());
186 EXPECT_TRUE(always_on_top_window_state->CanActivate()); 185 EXPECT_TRUE(always_on_top_window_state->CanActivate());
187 EXPECT_FALSE(always_on_top_window->HasFocus()); 186 EXPECT_FALSE(always_on_top_window->HasFocus());
188 EXPECT_TRUE(normal_window->HasFocus()); 187 EXPECT_TRUE(normal_window->HasFocus());
189 } 188 }
190 189
191 // Tests that if a widget has a view which should be initially focused, this 190 // Tests that if a widget has a view which should be initially focused, this
192 // view doesn't get focused if the widget shows behind the lock screen. 191 // view doesn't get focused if the widget shows behind the lock screen.
193 TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) { 192 TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) {
194 BlockUserSession(BLOCKED_BY_LOCK_SCREEN); 193 BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
195 EXPECT_TRUE(shell()->session_state_delegate()->IsScreenLocked()); 194 EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
196 195
197 views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext()); 196 views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext());
198 EXPECT_FALSE(delegate.view()->HasFocus()); 197 EXPECT_FALSE(delegate.view()->HasFocus());
199 delegate.GetWidget()->Show(); 198 delegate.GetWidget()->Show();
200 EXPECT_FALSE(delegate.GetWidget()->IsActive()); 199 EXPECT_FALSE(delegate.GetWidget()->IsActive());
201 EXPECT_FALSE(delegate.view()->HasFocus()); 200 EXPECT_FALSE(delegate.view()->HasFocus());
202 201
203 UnblockUserSession(); 202 UnblockUserSession();
204 EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked()); 203 EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
205 EXPECT_TRUE(delegate.GetWidget()->IsActive()); 204 EXPECT_TRUE(delegate.GetWidget()->IsActive());
206 EXPECT_TRUE(delegate.view()->HasFocus()); 205 EXPECT_TRUE(delegate.view()->HasFocus());
207 } 206 }
208 207
209 } // namespace test 208 } // namespace test
210 } // namespace ash 209 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698