| 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/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/root_window_layout_manager.h" | 10 #include "ash/wm/root_window_layout_manager.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 lock_modal_widget->Show(); | 280 lock_modal_widget->Show(); |
| 281 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | 281 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 282 lock_widget->Show(); | 282 lock_widget->Show(); |
| 283 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); | 283 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); |
| 284 lock_modal_widget->Close(); | 284 lock_modal_widget->Close(); |
| 285 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); | 285 EXPECT_TRUE(Shell::GetInstance()->IsScreenLocked()); |
| 286 lock_widget->Close(); | 286 lock_widget->Close(); |
| 287 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); | 287 EXPECT_FALSE(Shell::GetInstance()->IsScreenLocked()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 TEST_F(ShellTest, ComputeWindowMode) { | |
| 291 // By default, we use managed mode. | |
| 292 Shell* shell = Shell::GetInstance(); | |
| 293 Shell::TestApi test_api(shell); | |
| 294 CommandLine command_line_blank(CommandLine::NO_PROGRAM); | |
| 295 EXPECT_EQ(Shell::MODE_MANAGED, | |
| 296 test_api.ComputeWindowMode(&command_line_blank)); | |
| 297 | |
| 298 // Sometimes we force compact mode. | |
| 299 CommandLine command_line_force(CommandLine::NO_PROGRAM); | |
| 300 command_line_force.AppendSwitch(switches::kAuraForceCompactWindowMode); | |
| 301 EXPECT_EQ(Shell::MODE_COMPACT, | |
| 302 test_api.ComputeWindowMode(&command_line_force)); | |
| 303 | |
| 304 // The user can set compact mode. | |
| 305 CommandLine command_line_compact(CommandLine::NO_PROGRAM); | |
| 306 command_line_compact.AppendSwitchASCII(switches::kAuraWindowMode, | |
| 307 switches::kAuraWindowModeCompact); | |
| 308 EXPECT_EQ(Shell::MODE_COMPACT, | |
| 309 test_api.ComputeWindowMode(&command_line_compact)); | |
| 310 | |
| 311 // The user can set managed. | |
| 312 CommandLine command_line_managed(CommandLine::NO_PROGRAM); | |
| 313 command_line_managed.AppendSwitchASCII(switches::kAuraWindowMode, | |
| 314 switches::kAuraWindowModeManaged); | |
| 315 EXPECT_EQ(Shell::MODE_MANAGED, | |
| 316 test_api.ComputeWindowMode(&command_line_managed)); | |
| 317 } | |
| 318 | |
| 319 // Fails on Mac, see http://crbug.com/115662 | 290 // Fails on Mac, see http://crbug.com/115662 |
| 320 #if defined(OS_MACOSX) | 291 #if defined(OS_MACOSX) |
| 321 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics | 292 #define MAYBE_ManagedWindowModeBasics FAILS_ManagedWindowModeBasics |
| 322 #else | 293 #else |
| 323 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics | 294 #define MAYBE_ManagedWindowModeBasics ManagedWindowModeBasics |
| 324 #endif | 295 #endif |
| 325 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { | 296 TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) { |
| 326 Shell* shell = Shell::GetInstance(); | 297 Shell* shell = Shell::GetInstance(); |
| 327 Shell::TestApi test_api(shell); | 298 Shell::TestApi test_api(shell); |
| 328 | 299 |
| 329 // We start with the usual window containers. | 300 // We start with the usual window containers. |
| 330 ExpectAllContainers(); | 301 ExpectAllContainers(); |
| 331 // We're not in compact window mode by default. | |
| 332 EXPECT_FALSE(shell->IsWindowModeCompact()); | |
| 333 // We have a default container event filter (for window drags). | 302 // We have a default container event filter (for window drags). |
| 334 EXPECT_TRUE(GetDefaultContainer()->event_filter()); | 303 EXPECT_TRUE(GetDefaultContainer()->event_filter()); |
| 335 // Launcher is visible. | 304 // Launcher is visible. |
| 336 views::Widget* launcher_widget = shell->launcher()->widget(); | 305 views::Widget* launcher_widget = shell->launcher()->widget(); |
| 337 EXPECT_TRUE(launcher_widget->IsVisible()); | 306 EXPECT_TRUE(launcher_widget->IsVisible()); |
| 338 // Launcher is at bottom-left of screen. | 307 // Launcher is at bottom-left of screen. |
| 339 EXPECT_EQ(0, launcher_widget->GetWindowScreenBounds().x()); | 308 EXPECT_EQ(0, launcher_widget->GetWindowScreenBounds().x()); |
| 340 EXPECT_EQ(Shell::GetRootWindow()->GetHostSize().height(), | 309 EXPECT_EQ(Shell::GetRootWindow()->GetHostSize().height(), |
| 341 launcher_widget->GetWindowScreenBounds().bottom()); | 310 launcher_widget->GetWindowScreenBounds().bottom()); |
| 342 // We have a desktop background but not a bare layer. | 311 // We have a desktop background but not a bare layer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 EXPECT_FALSE(Shell::GetInstance()->shelf()->visible()); | 343 EXPECT_FALSE(Shell::GetInstance()->shelf()->visible()); |
| 375 | 344 |
| 376 // Restoring the window restores it. | 345 // Restoring the window restores it. |
| 377 widget->Restore(); | 346 widget->Restore(); |
| 378 EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); | 347 EXPECT_TRUE(Shell::GetInstance()->shelf()->visible()); |
| 379 | 348 |
| 380 // Clean up. | 349 // Clean up. |
| 381 widget->Close(); | 350 widget->Close(); |
| 382 } | 351 } |
| 383 | 352 |
| 384 // By implementing GetOverrideWindowMode we make the Shell come up in compact | |
| 385 // window mode. | |
| 386 class ShellCompactWindowModeTest : public test::AshTestBase { | |
| 387 public: | |
| 388 ShellCompactWindowModeTest() {} | |
| 389 virtual ~ShellCompactWindowModeTest() {} | |
| 390 | |
| 391 protected: | |
| 392 virtual bool GetOverrideWindowMode(Shell::WindowMode* window_mode) { | |
| 393 *window_mode = Shell::MODE_COMPACT; | |
| 394 return true; | |
| 395 } | |
| 396 | |
| 397 private: | |
| 398 DISALLOW_COPY_AND_ASSIGN(ShellCompactWindowModeTest); | |
| 399 }; | |
| 400 | |
| 401 TEST_F(ShellCompactWindowModeTest, CompactWindowModeBasics) { | |
| 402 Shell* shell = Shell::GetInstance(); | |
| 403 Shell::TestApi test_api(shell); | |
| 404 | |
| 405 EXPECT_TRUE(shell->IsWindowModeCompact()); | |
| 406 // Compact mode does not use a default container event filter. | |
| 407 EXPECT_FALSE(GetDefaultContainer()->event_filter()); | |
| 408 // We have all the usual containers. | |
| 409 ExpectAllContainers(); | |
| 410 | |
| 411 // Compact mode has no shelf. | |
| 412 EXPECT_TRUE(shell->shelf() == NULL); | |
| 413 | |
| 414 // Create a window. In compact mode, windows are created maximized. | |
| 415 views::Widget::InitParams widget_params( | |
| 416 views::Widget::InitParams::TYPE_WINDOW); | |
| 417 widget_params.bounds.SetRect(11, 22, 300, 400); | |
| 418 widget_params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
| 419 views::Widget* widget = CreateTestWindow(widget_params); | |
| 420 widget->Show(); | |
| 421 | |
| 422 // Window bounds got updated to fill the work area. | |
| 423 EXPECT_EQ(widget->GetWorkAreaBoundsInScreen(), | |
| 424 widget->GetWindowScreenBounds()); | |
| 425 // Launcher is hidden. | |
| 426 views::Widget* launcher_widget = shell->launcher()->widget(); | |
| 427 EXPECT_FALSE(launcher_widget->IsVisible()); | |
| 428 // Desktop background widget is gone but we have a layer. | |
| 429 EXPECT_FALSE(test_api.root_window_layout()->background_widget()); | |
| 430 EXPECT_TRUE(test_api.root_window_layout()->background_layer()); | |
| 431 | |
| 432 // Clean up. | |
| 433 widget->Close(); | |
| 434 } | |
| 435 | |
| 436 } // namespace ash | 353 } // namespace ash |
| OLD | NEW |