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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2692663002: Gut ash::MaterialDesignController, and remove the about:flags entry. (Closed)
Patch Set: yet another rebase Created 3 years, 10 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
« no previous file with comments | « ash/mus/window_manager_application.cc ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_controller.h" 9 #include "ash/common/session/session_controller.h"
11 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 11 #include "ash/common/system/tray/system_tray_delegate.h"
13 #include "ash/common/wm/system_modal_container_layout_manager.h" 12 #include "ash/common/wm/system_modal_container_layout_manager.h"
14 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
15 #include "ash/common/wm_lookup.h" 14 #include "ash/common/wm_lookup.h"
16 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
17 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
18 #include "ash/public/cpp/shell_window_ids.h" 17 #include "ash/public/cpp/shell_window_ids.h"
19 #include "ash/shell.h" 18 #include "ash/shell.h"
20 #include "ash/test/ash_md_test_base.h"
21 #include "ash/test/ash_test_base.h" 19 #include "ash/test/ash_test_base.h"
22 #include "ash/wm/window_properties.h" 20 #include "ash/wm/window_properties.h"
23 #include "ash/wm/window_state_aura.h" 21 #include "ash/wm/window_state_aura.h"
24 #include "ash/wm/window_util.h" 22 #include "ash/wm/window_util.h"
25 #include "base/command_line.h" 23 #include "base/command_line.h"
26 #include "ui/aura/client/focus_change_observer.h" 24 #include "ui/aura/client/focus_change_observer.h"
27 #include "ui/aura/client/focus_client.h" 25 #include "ui/aura/client/focus_client.h"
28 #include "ui/aura/client/window_parenting_client.h" 26 #include "ui/aura/client/window_parenting_client.h"
29 #include "ui/aura/env.h" 27 #include "ui/aura/env.h"
30 #include "ui/aura/test/test_window_delegate.h" 28 #include "ui/aura/test/test_window_delegate.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }; 97 };
100 98
101 WmLayoutManager* GetLayoutManager(RootWindowController* controller, int id) { 99 WmLayoutManager* GetLayoutManager(RootWindowController* controller, int id) {
102 return WmWindow::Get(controller->GetContainer(id))->GetLayoutManager(); 100 return WmWindow::Get(controller->GetContainer(id))->GetLayoutManager();
103 } 101 }
104 102
105 } // namespace 103 } // namespace
106 104
107 namespace test { 105 namespace test {
108 106
109 class RootWindowControllerTest : public AshMDTestBase { 107 class RootWindowControllerTest : public AshTestBase {
110 public: 108 public:
111 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { 109 views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
112 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 110 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
113 NULL, CurrentContext(), bounds); 111 NULL, CurrentContext(), bounds);
114 widget->Show(); 112 widget->Show();
115 return widget; 113 return widget;
116 } 114 }
117 115
118 views::Widget* CreateModalWidget(const gfx::Rect& bounds) { 116 views::Widget* CreateModalWidget(const gfx::Rect& bounds) {
119 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( 117 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
120 new TestDelegate(true), CurrentContext(), bounds); 118 new TestDelegate(true), CurrentContext(), bounds);
121 widget->Show(); 119 widget->Show();
122 return widget; 120 return widget;
123 } 121 }
124 122
125 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, 123 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds,
126 gfx::NativeWindow parent) { 124 gfx::NativeWindow parent) {
127 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds( 125 views::Widget* widget = views::Widget::CreateWindowWithParentAndBounds(
128 new TestDelegate(true), parent, bounds); 126 new TestDelegate(true), parent, bounds);
129 widget->Show(); 127 widget->Show();
130 return widget; 128 return widget;
131 } 129 }
132 130
133 aura::Window* GetModalContainer(aura::Window* root_window) { 131 aura::Window* GetModalContainer(aura::Window* root_window) {
134 return Shell::GetContainer(root_window, 132 return Shell::GetContainer(root_window,
135 kShellWindowId_SystemModalContainer); 133 kShellWindowId_SystemModalContainer);
136 } 134 }
137 }; 135 };
138 136
139 INSTANTIATE_TEST_CASE_P( 137 TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
140 /* prefix intentionally left blank due to only one parameterization */,
141 RootWindowControllerTest,
142 testing::Values(MaterialDesignController::NON_MATERIAL,
143 MaterialDesignController::MATERIAL_NORMAL,
144 MaterialDesignController::MATERIAL_EXPERIMENTAL));
145
146 TEST_P(RootWindowControllerTest, MoveWindows_Basic) {
147 const int height_offset = GetMdMaximizedWindowHeightOffset();
148
149 // Windows origin should be doubled when moved to the 1st display. 138 // Windows origin should be doubled when moved to the 1st display.
150 UpdateDisplay("600x600,300x300"); 139 UpdateDisplay("600x600,300x300");
151 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 140 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
152 141
153 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); 142 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
154 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); 143 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
155 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); 144 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString());
156 EXPECT_EQ("50,10 100x100", 145 EXPECT_EQ("50,10 100x100",
157 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); 146 normal->GetNativeView()->GetBoundsInRootWindow().ToString());
158 147
159 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); 148 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100));
160 maximized->Maximize(); 149 maximized->Maximize();
161 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); 150 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow());
162 EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(), 151 EXPECT_EQ(gfx::Rect(600, 0, 300, 252).ToString(),
163 maximized->GetWindowBoundsInScreen().ToString()); 152 maximized->GetWindowBoundsInScreen().ToString());
164 EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(), 153 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(),
165 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 154 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
166 155
167 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); 156 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
168 minimized->Minimize(); 157 minimized->Minimize();
169 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); 158 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow());
170 EXPECT_EQ("800,10 100x100", minimized->GetWindowBoundsInScreen().ToString()); 159 EXPECT_EQ("800,10 100x100", minimized->GetWindowBoundsInScreen().ToString());
171 160
172 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); 161 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100));
173 fullscreen->SetFullscreen(true); 162 fullscreen->SetFullscreen(true);
174 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); 163 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 EXPECT_EQ("100,20 100x100", 202 EXPECT_EQ("100,20 100x100",
214 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); 203 normal->GetNativeView()->GetBoundsInRootWindow().ToString());
215 204
216 // Maximized area on primary display has 47px for non-md and 48px for md 205 // Maximized area on primary display has 47px for non-md and 48px for md
217 // (defined in SHELF_SIZE) inset at the bottom. 206 // (defined in SHELF_SIZE) inset at the bottom.
218 207
219 // First clear fullscreen status, since both fullscreen and maximized windows 208 // First clear fullscreen status, since both fullscreen and maximized windows
220 // share the same desktop workspace, which cancels the shelf status. 209 // share the same desktop workspace, which cancels the shelf status.
221 fullscreen->SetFullscreen(false); 210 fullscreen->SetFullscreen(false);
222 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); 211 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
223 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 212 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(),
224 maximized->GetWindowBoundsInScreen().ToString()); 213 maximized->GetWindowBoundsInScreen().ToString());
225 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 214 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(),
226 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 215 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
227 216
228 // Set fullscreen to true, but maximized window's size won't change because 217 // Set fullscreen to true, but maximized window's size won't change because
229 // it's not visible. see crbug.com/504299. 218 // it's not visible. see crbug.com/504299.
230 fullscreen->SetFullscreen(true); 219 fullscreen->SetFullscreen(true);
231 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); 220 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
232 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 221 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(),
233 maximized->GetWindowBoundsInScreen().ToString()); 222 maximized->GetWindowBoundsInScreen().ToString());
234 EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(), 223 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(),
235 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); 224 maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
236 225
237 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); 226 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow());
238 EXPECT_EQ("400,20 100x100", minimized->GetWindowBoundsInScreen().ToString()); 227 EXPECT_EQ("400,20 100x100", minimized->GetWindowBoundsInScreen().ToString());
239 228
240 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); 229 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow());
241 EXPECT_TRUE(fullscreen->IsFullscreen()); 230 EXPECT_TRUE(fullscreen->IsFullscreen());
242 EXPECT_EQ("0,0 600x600", fullscreen->GetWindowBoundsInScreen().ToString()); 231 EXPECT_EQ("0,0 600x600", fullscreen->GetWindowBoundsInScreen().ToString());
243 EXPECT_EQ("0,0 600x600", 232 EXPECT_EQ("0,0 600x600",
244 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); 233 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
(...skipping 13 matching lines...) Expand all
258 EXPECT_EQ(root_windows[0], 247 EXPECT_EQ(root_windows[0],
259 unparented_control->GetNativeView()->GetRootWindow()); 248 unparented_control->GetNativeView()->GetRootWindow());
260 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, 249 EXPECT_EQ(kShellWindowId_UnparentedControlContainer,
261 unparented_control->GetNativeView()->parent()->id()); 250 unparented_control->GetNativeView()->parent()->id());
262 251
263 // Test if the panel has moved. 252 // Test if the panel has moved.
264 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); 253 EXPECT_EQ(root_windows[0], panel->GetRootWindow());
265 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); 254 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id());
266 } 255 }
267 256
268 TEST_P(RootWindowControllerTest, MoveWindows_Modal) { 257 TEST_F(RootWindowControllerTest, MoveWindows_Modal) {
269 UpdateDisplay("500x500,500x500"); 258 UpdateDisplay("500x500,500x500");
270 259
271 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 260 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
272 // Emulate virtual screen coordinate system. 261 // Emulate virtual screen coordinate system.
273 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); 262 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500));
274 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); 263 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500));
275 264
276 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); 265 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100));
277 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); 266 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow());
278 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); 267 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView()));
279 268
280 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); 269 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100));
281 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); 270 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow());
282 EXPECT_TRUE( 271 EXPECT_TRUE(
283 GetModalContainer(root_windows[1])->Contains(modal->GetNativeView())); 272 GetModalContainer(root_windows[1])->Contains(modal->GetNativeView()));
284 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 273 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
285 274
286 ui::test::EventGenerator generator_1st(root_windows[0]); 275 ui::test::EventGenerator generator_1st(root_windows[0]);
287 generator_1st.ClickLeftButton(); 276 generator_1st.ClickLeftButton();
288 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 277 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
289 278
290 UpdateDisplay("500x500"); 279 UpdateDisplay("500x500");
291 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); 280 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow());
292 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 281 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
293 generator_1st.ClickLeftButton(); 282 generator_1st.ClickLeftButton();
294 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 283 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
295 } 284 }
296 285
297 // Make sure lock related windows moves. 286 // Make sure lock related windows moves.
298 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { 287 TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
299 display_manager()->SetUnifiedDesktopEnabled(true); 288 display_manager()->SetUnifiedDesktopEnabled(true);
300 289
301 UpdateDisplay("500x500"); 290 UpdateDisplay("500x500");
302 const int kLockScreenWindowId = 1000; 291 const int kLockScreenWindowId = 1000;
303 const int kLockWallpaperWindowId = 1001; 292 const int kLockWallpaperWindowId = 1001;
304 293
305 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 294 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
306 295
307 aura::Window* lock_container = 296 aura::Window* lock_container =
308 controller->GetContainer(kShellWindowId_LockScreenContainer); 297 controller->GetContainer(kShellWindowId_LockScreenContainer);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 355
367 controller = Shell::GetPrimaryRootWindowController(); 356 controller = Shell::GetPrimaryRootWindowController();
368 357
369 ASSERT_EQ(lock_screen->GetNativeWindow(), 358 ASSERT_EQ(lock_screen->GetNativeWindow(),
370 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 359 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
371 ASSERT_EQ(lock_wallpaper->GetNativeWindow(), 360 ASSERT_EQ(lock_wallpaper->GetNativeWindow(),
372 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId)); 361 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId));
373 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); 362 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
374 } 363 }
375 364
376 TEST_P(RootWindowControllerTest, ModalContainer) { 365 TEST_F(RootWindowControllerTest, ModalContainer) {
377 UpdateDisplay("600x600"); 366 UpdateDisplay("600x600");
378 WmShell* wm_shell = WmShell::Get(); 367 WmShell* wm_shell = WmShell::Get();
379 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController(); 368 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController();
380 EXPECT_EQ(LoginStatus::USER, 369 EXPECT_EQ(LoginStatus::USER,
381 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 370 wm_shell->system_tray_delegate()->GetUserLoginStatus());
382 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 371 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
383 controller->GetSystemModalLayoutManager(NULL)); 372 controller->GetSystemModalLayoutManager(NULL));
384 373
385 views::Widget* session_modal_widget = 374 views::Widget* session_modal_widget =
386 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 375 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
(...skipping 16 matching lines...) Expand all
403 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 392 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
404 controller->GetSystemModalLayoutManager( 393 controller->GetSystemModalLayoutManager(
405 WmLookup::Get()->GetWindowForWidget(lock_modal_widget))); 394 WmLookup::Get()->GetWindowForWidget(lock_modal_widget)));
406 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 395 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
407 controller->GetSystemModalLayoutManager( 396 controller->GetSystemModalLayoutManager(
408 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 397 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
409 398
410 wm_shell->GetSessionStateDelegate()->UnlockScreen(); 399 wm_shell->GetSessionStateDelegate()->UnlockScreen();
411 } 400 }
412 401
413 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 402 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
414 UpdateDisplay("600x600"); 403 UpdateDisplay("600x600");
415 404
416 // Configure login screen environment. 405 // Configure login screen environment.
417 SessionStateDelegate* session_state_delegate = 406 SessionStateDelegate* session_state_delegate =
418 WmShell::Get()->GetSessionStateDelegate(); 407 WmShell::Get()->GetSessionStateDelegate();
419 SetUserLoggedIn(false); 408 SetUserLoggedIn(false);
420 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 409 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
421 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 410 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
422 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers()); 411 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers());
423 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted()); 412 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted());
(...skipping 24 matching lines...) Expand all
448 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 437 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
449 controller->GetSystemModalLayoutManager(NULL)); 438 controller->GetSystemModalLayoutManager(NULL));
450 439
451 views::Widget* session_modal_widget = 440 views::Widget* session_modal_widget =
452 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 441 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
453 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 442 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
454 controller->GetSystemModalLayoutManager( 443 controller->GetSystemModalLayoutManager(
455 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 444 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
456 } 445 }
457 446
458 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { 447 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
459 UpdateDisplay("600x600"); 448 UpdateDisplay("600x600");
460 RootWindowController* controller = 449 RootWindowController* controller =
461 WmShell::Get()->GetPrimaryRootWindowController(); 450 WmShell::Get()->GetPrimaryRootWindowController();
462 aura::Window* lock_container = 451 aura::Window* lock_container =
463 controller->GetContainer(kShellWindowId_LockScreenContainer); 452 controller->GetContainer(kShellWindowId_LockScreenContainer);
464 for (int block_reason = FIRST_BLOCK_REASON; 453 for (int block_reason = FIRST_BLOCK_REASON;
465 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { 454 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
466 views::Widget* session_modal_widget = 455 views::Widget* session_modal_widget =
467 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 456 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
468 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 457 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
(...skipping 20 matching lines...) Expand all
489 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 478 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
490 controller->GetSystemModalLayoutManager( 479 controller->GetSystemModalLayoutManager(
491 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 480 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
492 session_modal_widget->Close(); 481 session_modal_widget->Close();
493 482
494 lock_modal_widget->Close(); 483 lock_modal_widget->Close();
495 UnblockUserSession(); 484 UnblockUserSession();
496 } 485 }
497 } 486 }
498 487
499 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { 488 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) {
500 UpdateDisplay("600x600"); 489 UpdateDisplay("600x600");
501 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 490 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
502 491
503 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 492 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
504 w1->Maximize(); 493 w1->Maximize();
505 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 494 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
506 w2->SetFullscreen(true); 495 w2->SetFullscreen(true);
507 // |w3| is a transient child of |w2|. 496 // |w3| is a transient child of |w2|.
508 Widget* w3 = Widget::CreateWindowWithParentAndBounds( 497 Widget* w3 = Widget::CreateWindowWithParentAndBounds(
509 NULL, w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); 498 NULL, w2->GetNativeWindow(), gfx::Rect(0, 0, 100, 100));
(...skipping 10 matching lines...) Expand all
520 w3->Close(); 509 w3->Close();
521 510
522 // Only w2 remains, if minimized GetWindowForFullscreenMode should return 511 // Only w2 remains, if minimized GetWindowForFullscreenMode should return
523 // NULL. 512 // NULL.
524 w2->Activate(); 513 w2->Activate();
525 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); 514 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode());
526 w2->Minimize(); 515 w2->Minimize();
527 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); 516 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode());
528 } 517 }
529 518
530 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { 519 TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) {
531 UpdateDisplay("600x600,600x600"); 520 UpdateDisplay("600x600,600x600");
532 Shell::RootWindowControllerList controllers = 521 Shell::RootWindowControllerList controllers =
533 Shell::GetInstance()->GetAllRootWindowControllers(); 522 Shell::GetInstance()->GetAllRootWindowControllers();
534 523
535 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 524 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
536 w1->Maximize(); 525 w1->Maximize();
537 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 526 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
538 w2->SetFullscreen(true); 527 w2->SetFullscreen(true);
539 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 528 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
540 529
(...skipping 16 matching lines...) Expand all
557 // Verify that the first root window controller remains in fullscreen mode 546 // Verify that the first root window controller remains in fullscreen mode
558 // when a window on the other display is activated. 547 // when a window on the other display is activated.
559 w3->Activate(); 548 w3->Activate();
560 EXPECT_EQ(w2->GetNativeWindow(), 549 EXPECT_EQ(w2->GetNativeWindow(),
561 controllers[0]->GetWindowForFullscreenMode()); 550 controllers[0]->GetWindowForFullscreenMode());
562 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); 551 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode());
563 } 552 }
564 553
565 // Test that GetRootWindowController() works with multiple displays and 554 // Test that GetRootWindowController() works with multiple displays and
566 // child widgets. 555 // child widgets.
567 TEST_P(RootWindowControllerTest, GetRootWindowController) { 556 TEST_F(RootWindowControllerTest, GetRootWindowController) {
568 UpdateDisplay("600x600,600x600"); 557 UpdateDisplay("600x600,600x600");
569 Shell::RootWindowControllerList controllers = 558 Shell::RootWindowControllerList controllers =
570 Shell::GetInstance()->GetAllRootWindowControllers(); 559 Shell::GetInstance()->GetAllRootWindowControllers();
571 ASSERT_EQ(2u, controllers.size()); 560 ASSERT_EQ(2u, controllers.size());
572 561
573 // Test null. 562 // Test null.
574 EXPECT_FALSE(GetRootWindowController(nullptr)); 563 EXPECT_FALSE(GetRootWindowController(nullptr));
575 564
576 // Test a widget on the first display. 565 // Test a widget on the first display.
577 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 566 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
578 EXPECT_EQ(controllers[0], 567 EXPECT_EQ(controllers[0],
579 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow())); 568 GetRootWindowController(w1->GetNativeWindow()->GetRootWindow()));
580 569
581 // Test a child widget. 570 // Test a child widget.
582 Widget* w2 = Widget::CreateWindowWithParentAndBounds( 571 Widget* w2 = Widget::CreateWindowWithParentAndBounds(
583 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100)); 572 nullptr, w1->GetNativeWindow(), gfx::Rect(0, 0, 100, 100));
584 EXPECT_EQ(controllers[0], 573 EXPECT_EQ(controllers[0],
585 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow())); 574 GetRootWindowController(w2->GetNativeWindow()->GetRootWindow()));
586 575
587 // Test a widget on the second display. 576 // Test a widget on the second display.
588 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 577 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
589 EXPECT_EQ(controllers[1], 578 EXPECT_EQ(controllers[1],
590 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow())); 579 GetRootWindowController(w3->GetNativeWindow()->GetRootWindow()));
591 } 580 }
592 581
593 // Test that user session window can't be focused if user session blocked by 582 // Test that user session window can't be focused if user session blocked by
594 // some overlapping UI. 583 // some overlapping UI.
595 TEST_P(RootWindowControllerTest, FocusBlockedWindow) { 584 TEST_F(RootWindowControllerTest, FocusBlockedWindow) {
596 UpdateDisplay("600x600"); 585 UpdateDisplay("600x600");
597 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 586 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
598 aura::Window* lock_container = 587 aura::Window* lock_container =
599 controller->GetContainer(kShellWindowId_LockScreenContainer); 588 controller->GetContainer(kShellWindowId_LockScreenContainer);
600 aura::Window* lock_window = 589 aura::Window* lock_window =
601 Widget::CreateWindowWithParentAndBounds(NULL, lock_container, 590 Widget::CreateWindowWithParentAndBounds(NULL, lock_container,
602 gfx::Rect(0, 0, 100, 100)) 591 gfx::Rect(0, 0, 100, 100))
603 ->GetNativeView(); 592 ->GetNativeView();
604 lock_window->Show(); 593 lock_window->Show();
605 aura::Window* session_window = 594 aura::Window* session_window =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 window_ = NULL; 633 window_ = NULL;
645 } 634 }
646 635
647 bool destroyed_; 636 bool destroyed_;
648 Window* window_; 637 Window* window_;
649 638
650 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver); 639 DISALLOW_COPY_AND_ASSIGN(DestroyedWindowObserver);
651 }; 640 };
652 641
653 // Verifies shutdown doesn't delete windows that are not owned by the parent. 642 // Verifies shutdown doesn't delete windows that are not owned by the parent.
654 TEST_P(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) { 643 TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) {
655 DestroyedWindowObserver observer1; 644 DestroyedWindowObserver observer1;
656 aura::test::TestWindowDelegate delegate1; 645 aura::test::TestWindowDelegate delegate1;
657 aura::Window* window1 = new aura::Window(&delegate1); 646 aura::Window* window1 = new aura::Window(&delegate1);
658 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL); 647 window1->SetType(ui::wm::WINDOW_TYPE_CONTROL);
659 window1->set_owned_by_parent(false); 648 window1->set_owned_by_parent(false);
660 observer1.SetWindow(window1); 649 observer1.SetWindow(window1);
661 window1->Init(ui::LAYER_NOT_DRAWN); 650 window1->Init(ui::LAYER_NOT_DRAWN);
662 aura::client::ParentWindowWithContext( 651 aura::client::ParentWindowWithContext(
663 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect()); 652 window1, Shell::GetInstance()->GetPrimaryRootWindow(), gfx::Rect());
664 653
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1204 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1216 gfx::Rect(0, 400, 800, 200)); 1205 gfx::Rect(0, 400, 800, 200));
1217 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1206 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1218 1207
1219 UpdateDisplay("600x800"); 1208 UpdateDisplay("600x800");
1220 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1209 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1221 } 1210 }
1222 1211
1223 } // namespace test 1212 } // namespace test
1224 } // namespace ash 1213 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager_application.cc ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698