diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 20:13:38 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 20:13:38 +0000 |
commit | b0079a9450486ad44b398a645f8dcde68f5dbf75 (patch) | |
tree | 4db099ce97b661110cc69539649c2e91b4df53dc /ash/shell_unittest.cc | |
parent | ccb0698a16b4a1fdcdec7e83b568bae4442009c0 (diff) | |
download | chromium_src-b0079a9450486ad44b398a645f8dcde68f5dbf75.zip chromium_src-b0079a9450486ad44b398a645f8dcde68f5dbf75.tar.gz chromium_src-b0079a9450486ad44b398a645f8dcde68f5dbf75.tar.bz2 |
Aura: Allow compact window mode to be turned on/off at runtime
* In debug builds, Ctrl-Alt-A shows/hides it
* Added test coverage for switching modes
* Refactored Shell initialization to support this
BUG=110174
TEST=aura_shell_unittests ShellTest.ChangeWindowMode, manual toggling
Review URL: https://chromiumcodereview.appspot.com/9289008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shell_unittest.cc')
-rw-r--r-- | ash/shell_unittest.cc | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc index 42de843..264d7e6 100644 --- a/ash/shell_unittest.cc +++ b/ash/shell_unittest.cc @@ -3,9 +3,11 @@ // found in the LICENSE file. #include "ash/ash_switches.h" +#include "ash/launcher/launcher.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/aura_shell_test_base.h" +#include "ash/wm/root_window_layout_manager.h" #include "base/command_line.h" #include "base/utf_string_conversions.h" #include "ui/aura/test/aura_test_base.h" @@ -35,6 +37,33 @@ aura::Window* GetAlwaysOnTopContainer() { ash::internal::kShellWindowId_AlwaysOnTopContainer); } +// Expect ALL the containers! +void ExpectAllContainers() { + Shell* shell = Shell::GetInstance(); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_DefaultContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_AlwaysOnTopContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_PanelContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_LauncherContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_SystemModalContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_LockScreenContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_LockSystemModalContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_StatusContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_MenuAndTooltipContainer)); + EXPECT_TRUE( + shell->GetContainer(internal::kShellWindowId_SettingBubbleContainer)); +} + void TestCreateWindow(views::Widget::InitParams::Type type, bool always_on_top, aura::Window* expected_container) { @@ -301,4 +330,57 @@ TEST_F(ShellTest, ComputeWindowMode) { shell->ComputeWindowMode(monitor_size, &command_line2)); } +TEST_F(ShellTest, ChangeWindowMode) { + // We start with the usual window containers. + ExpectAllContainers(); + // We're not in compact window mode by default. + Shell* shell = Shell::GetInstance(); + EXPECT_FALSE(shell->IsWindowModeCompact()); + // We have a default container event filter (for window drags). + EXPECT_TRUE(GetDefaultContainer()->event_filter()); + // We have a launcher. + EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); + // We have a desktop background. + EXPECT_TRUE(shell->root_window_layout_->background_widget()); + + // Create a normal window. It is not maximized. + views::Widget::InitParams widget_params( + views::Widget::InitParams::TYPE_WINDOW); + widget_params.bounds.SetRect(11, 22, 300, 400); + views::Widget* widget = CreateTestWindow(widget_params); + widget->Show(); + EXPECT_FALSE(widget->IsMaximized()); + + // Set our new mode. + shell->ChangeWindowMode(Shell::COMPACT_MODE); + EXPECT_TRUE(shell->IsWindowModeCompact()); + // Compact mode does not use a default container event filter. + EXPECT_FALSE(GetDefaultContainer()->event_filter()); + // We still have all the usual containers. + ExpectAllContainers(); + + // In compact window mode, all windows are maximized. + EXPECT_TRUE(widget->IsMaximized()); + // Window bounds got updated to fill the work area. + EXPECT_EQ(widget->GetWorkAreaBoundsInScreen(), + widget->GetWindowScreenBounds()); + // Launcher is hidden. + EXPECT_FALSE(shell->launcher()->widget()->IsVisible()); + // Desktop background is gone. + EXPECT_FALSE(shell->root_window_layout_->background_widget()); + + // Switch back to normal mode. + shell->ChangeWindowMode(Shell::NORMAL_MODE); + EXPECT_FALSE(shell->IsWindowModeCompact()); + // Event filter came back. + EXPECT_TRUE(GetDefaultContainer()->event_filter()); + // Launcher is visible again. + EXPECT_TRUE(shell->launcher()->widget()->IsVisible()); + // Desktop background is back. + EXPECT_TRUE(shell->root_window_layout_->background_widget()); + + // Clean up. + widget->Close(); +} + } // namespace ash |