| OLD | NEW |
| 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/ash_switches.h" | 5 #include "ash/ash_switches.h" |
| 6 #include "ash/launcher/launcher.h" | 6 #include "ash/launcher/launcher.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/aura_shell_test_base.h" | 9 #include "ash/test/aura_shell_test_base.h" |
| 10 #include "ash/wm/root_window_layout_manager.h" | 10 #include "ash/wm/root_window_layout_manager.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 TEST_F(ShellTest, ComputeWindowMode) { | 296 TEST_F(ShellTest, ComputeWindowMode) { |
| 297 // We only change default window mode with full-screen host windows. | 297 // We only change default window mode with full-screen host windows. |
| 298 AutoResetUseFullscreenHostWindow use_fullscreen_host_window(true); | 298 AutoResetUseFullscreenHostWindow use_fullscreen_host_window(true); |
| 299 | 299 |
| 300 // Wide screens use normal window mode. | 300 // Wide screens use normal window mode. |
| 301 Shell* shell = Shell::GetInstance(); | 301 Shell* shell = Shell::GetInstance(); |
| 302 gfx::Size monitor_size(1440, 900); | 302 gfx::Size monitor_size(1440, 900); |
| 303 CommandLine command_line(CommandLine::NO_PROGRAM); | 303 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 304 EXPECT_EQ(Shell::NORMAL_MODE, | 304 EXPECT_EQ(Shell::MODE_OVERLAPPING, |
| 305 shell->ComputeWindowMode(monitor_size, &command_line)); | 305 shell->ComputeWindowMode(monitor_size, &command_line)); |
| 306 | 306 |
| 307 // Alex-sized screens need compact mode. | 307 // Alex-sized screens need compact mode. |
| 308 monitor_size.SetSize(1280, 800); | 308 monitor_size.SetSize(1280, 800); |
| 309 EXPECT_EQ(Shell::COMPACT_MODE, | 309 EXPECT_EQ(Shell::MODE_COMPACT, |
| 310 shell->ComputeWindowMode(monitor_size, &command_line)); | 310 shell->ComputeWindowMode(monitor_size, &command_line)); |
| 311 | 311 |
| 312 // ZGB-sized screens need compact mode. | 312 // ZGB-sized screens need compact mode. |
| 313 monitor_size.SetSize(1366, 768); | 313 monitor_size.SetSize(1366, 768); |
| 314 EXPECT_EQ(Shell::COMPACT_MODE, | 314 EXPECT_EQ(Shell::MODE_COMPACT, |
| 315 shell->ComputeWindowMode(monitor_size, &command_line)); | 315 shell->ComputeWindowMode(monitor_size, &command_line)); |
| 316 | 316 |
| 317 // Even for a small screen, the user can force normal mode. | 317 // Even for a small screen, the user can force overlapping mode. |
| 318 monitor_size.SetSize(800, 600); | 318 monitor_size.SetSize(800, 600); |
| 319 command_line.AppendSwitchASCII(ash::switches::kAuraWindowMode, | 319 command_line.AppendSwitchASCII(ash::switches::kAuraWindowMode, |
| 320 ash::switches::kAuraWindowModeNormal); | 320 ash::switches::kAuraWindowModeOverlapping); |
| 321 EXPECT_EQ(Shell::NORMAL_MODE, | 321 EXPECT_EQ(Shell::MODE_OVERLAPPING, |
| 322 shell->ComputeWindowMode(monitor_size, &command_line)); | 322 shell->ComputeWindowMode(monitor_size, &command_line)); |
| 323 | 323 |
| 324 // Even for a large screen, the user can force compact mode. | 324 // Even for a large screen, the user can force compact mode. |
| 325 monitor_size.SetSize(1920, 1080); | 325 monitor_size.SetSize(1920, 1080); |
| 326 CommandLine command_line2(CommandLine::NO_PROGRAM); | 326 CommandLine command_line2(CommandLine::NO_PROGRAM); |
| 327 command_line2.AppendSwitchASCII(ash::switches::kAuraWindowMode, | 327 command_line2.AppendSwitchASCII(ash::switches::kAuraWindowMode, |
| 328 ash::switches::kAuraWindowModeCompact); | 328 ash::switches::kAuraWindowModeCompact); |
| 329 EXPECT_EQ(Shell::COMPACT_MODE, | 329 EXPECT_EQ(Shell::MODE_COMPACT, |
| 330 shell->ComputeWindowMode(monitor_size, &command_line2)); | 330 shell->ComputeWindowMode(monitor_size, &command_line2)); |
| 331 } | 331 } |
| 332 | 332 |
| 333 TEST_F(ShellTest, ChangeWindowMode) { | 333 TEST_F(ShellTest, ChangeWindowMode) { |
| 334 // We start with the usual window containers. | 334 // We start with the usual window containers. |
| 335 ExpectAllContainers(); | 335 ExpectAllContainers(); |
| 336 // We're not in compact window mode by default. | 336 // We're not in compact window mode by default. |
| 337 Shell* shell = Shell::GetInstance(); | 337 Shell* shell = Shell::GetInstance(); |
| 338 EXPECT_FALSE(shell->IsWindowModeCompact()); | 338 EXPECT_FALSE(shell->IsWindowModeCompact()); |
| 339 // We have a default container event filter (for window drags). | 339 // We have a default container event filter (for window drags). |
| 340 EXPECT_TRUE(GetDefaultContainer()->event_filter()); | 340 EXPECT_TRUE(GetDefaultContainer()->event_filter()); |
| 341 // We have a launcher. | 341 // We have a launcher. |
| 342 EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); | 342 EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); |
| 343 // We have a desktop background. | 343 // We have a desktop background. |
| 344 EXPECT_TRUE(shell->root_window_layout_->background_widget()); | 344 EXPECT_TRUE(shell->root_window_layout_->background_widget()); |
| 345 | 345 |
| 346 // Create a normal window. It is not maximized. | 346 // Create a normal window. It is not maximized. |
| 347 views::Widget::InitParams widget_params( | 347 views::Widget::InitParams widget_params( |
| 348 views::Widget::InitParams::TYPE_WINDOW); | 348 views::Widget::InitParams::TYPE_WINDOW); |
| 349 widget_params.bounds.SetRect(11, 22, 300, 400); | 349 widget_params.bounds.SetRect(11, 22, 300, 400); |
| 350 views::Widget* widget = CreateTestWindow(widget_params); | 350 views::Widget* widget = CreateTestWindow(widget_params); |
| 351 widget->Show(); | 351 widget->Show(); |
| 352 EXPECT_FALSE(widget->IsMaximized()); | 352 EXPECT_FALSE(widget->IsMaximized()); |
| 353 | 353 |
| 354 // Set our new mode. | 354 // Set our new mode. |
| 355 shell->ChangeWindowMode(Shell::COMPACT_MODE); | 355 shell->ChangeWindowMode(Shell::MODE_COMPACT); |
| 356 EXPECT_TRUE(shell->IsWindowModeCompact()); | 356 EXPECT_TRUE(shell->IsWindowModeCompact()); |
| 357 // Compact mode does not use a default container event filter. | 357 // Compact mode does not use a default container event filter. |
| 358 EXPECT_FALSE(GetDefaultContainer()->event_filter()); | 358 EXPECT_FALSE(GetDefaultContainer()->event_filter()); |
| 359 // We still have all the usual containers. | 359 // We still have all the usual containers. |
| 360 ExpectAllContainers(); | 360 ExpectAllContainers(); |
| 361 | 361 |
| 362 // In compact window mode, all windows are maximized. | 362 // In compact window mode, all windows are maximized. |
| 363 EXPECT_TRUE(widget->IsMaximized()); | 363 EXPECT_TRUE(widget->IsMaximized()); |
| 364 // Window bounds got updated to fill the work area. | 364 // Window bounds got updated to fill the work area. |
| 365 EXPECT_EQ(widget->GetWorkAreaBoundsInScreen(), | 365 EXPECT_EQ(widget->GetWorkAreaBoundsInScreen(), |
| 366 widget->GetWindowScreenBounds()); | 366 widget->GetWindowScreenBounds()); |
| 367 // Launcher is hidden. | 367 // Launcher is hidden. |
| 368 EXPECT_FALSE(shell->launcher()->widget()->IsVisible()); | 368 EXPECT_FALSE(shell->launcher()->widget()->IsVisible()); |
| 369 // Desktop background is gone. | 369 // Desktop background is gone. |
| 370 EXPECT_FALSE(shell->root_window_layout_->background_widget()); | 370 EXPECT_FALSE(shell->root_window_layout_->background_widget()); |
| 371 | 371 |
| 372 // Switch back to normal mode. | 372 // Switch back to overlapping mode. |
| 373 shell->ChangeWindowMode(Shell::NORMAL_MODE); | 373 shell->ChangeWindowMode(Shell::MODE_OVERLAPPING); |
| 374 EXPECT_FALSE(shell->IsWindowModeCompact()); | 374 EXPECT_FALSE(shell->IsWindowModeCompact()); |
| 375 // Event filter came back. | 375 // Event filter came back. |
| 376 EXPECT_TRUE(GetDefaultContainer()->event_filter()); | 376 EXPECT_TRUE(GetDefaultContainer()->event_filter()); |
| 377 // Launcher is visible again. | 377 // Launcher is visible again. |
| 378 EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); | 378 EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); |
| 379 // Desktop background is back. | 379 // Desktop background is back. |
| 380 EXPECT_TRUE(shell->root_window_layout_->background_widget()); | 380 EXPECT_TRUE(shell->root_window_layout_->background_widget()); |
| 381 | 381 |
| 382 // Clean up. | 382 // Clean up. |
| 383 widget->Close(); | 383 widget->Close(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace ash | 386 } // namespace ash |
| OLD | NEW |