summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 04:28:37 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-16 04:28:37 +0000
commit932cf113991a891486faaba65f2d266afa023906 (patch)
tree414e932123fb1ba19e287f1c404c1a2562e1c3e6 /ash
parentff5692ed360a1e71ca3ba7d3be29a930f7e25dec (diff)
downloadchromium_src-932cf113991a891486faaba65f2d266afa023906.zip
chromium_src-932cf113991a891486faaba65f2d266afa023906.tar.gz
chromium_src-932cf113991a891486faaba65f2d266afa023906.tar.bz2
Prepare a bunch of ash tests for workspace2. With Workspace2 you can't
add to the default container, instead you need to go through the StackingClient. BUG=137342 TEST=none R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10857021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/accelerator_filter_unittest.cc5
-rw-r--r--ash/accelerators/nested_dispatcher_controller_unittest.cc12
-rw-r--r--ash/focus_cycler_unittest.cc30
-rw-r--r--ash/launcher/launcher_context_menu_unittest.cc1
-rw-r--r--ash/shell_unittest.cc23
-rw-r--r--ash/wm/activation_controller_unittest.cc14
-rw-r--r--ash/wm/frame_painter.cc6
-rw-r--r--ash/wm/frame_painter_unittest.cc10
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc8
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc8
-rw-r--r--ash/wm/window_animations_unittest.cc30
-rw-r--r--ash/wm/window_cycle_controller_unittest.cc98
-rw-r--r--ash/wm/workspace/multi_window_resize_controller_unittest.cc2
-rw-r--r--ash/wm/workspace/workspace_event_filter.cc17
-rw-r--r--ash/wm/workspace/workspace_event_filter.h3
-rw-r--r--ash/wm/workspace/workspace_event_filter_unittest.cc7
-rw-r--r--ash/wm/workspace/workspace_manager.cc4
-rw-r--r--ash/wm/workspace/workspace_manager.h2
-rw-r--r--ash/wm/workspace/workspace_manager_unittest.cc4
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc9
-rw-r--r--ash/wm/workspace_controller.cc2
-rw-r--r--ash/wm/workspace_controller_test_helper.cc7
-rw-r--r--ash/wm/workspace_controller_test_helper.h6
23 files changed, 126 insertions, 182 deletions
diff --git a/ash/accelerators/accelerator_filter_unittest.cc b/ash/accelerators/accelerator_filter_unittest.cc
index a918c5c..210b849 100644
--- a/ash/accelerators/accelerator_filter_unittest.cc
+++ b/ash/accelerators/accelerator_filter_unittest.cc
@@ -79,15 +79,12 @@ TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) {
// Tests if AcceleratorFilter works as expected with a focused window.
TEST_F(AcceleratorFilterTest, TestFilterWithFocus) {
- aura::Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
aura::test::TestWindowDelegate test_delegate;
scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
&test_delegate,
-1,
gfx::Rect(),
- default_container));
+ NULL));
wm::ActivateWindow(window.get());
DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
diff --git a/ash/accelerators/nested_dispatcher_controller_unittest.cc b/ash/accelerators/nested_dispatcher_controller_unittest.cc
index 3837ff8..03cbcd4 100644
--- a/ash/accelerators/nested_dispatcher_controller_unittest.cc
+++ b/ash/accelerators/nested_dispatcher_controller_unittest.cc
@@ -106,11 +106,8 @@ typedef AshTestBase NestedDispatcherTest;
// Aura window below lock screen in z order.
TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
MockDispatcher inner_dispatcher;
- aura::Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId(
- 0, default_container));
+ 0, NULL));
Shell::GetInstance()->delegate()->LockScreen();
DispatchKeyReleaseA();
@@ -127,14 +124,11 @@ TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) {
MockDispatcher inner_dispatcher;
- aura::Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window>mock_lock_container(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
aura::test::CreateTestWindowWithId(0, mock_lock_container.get());
scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId(
- 0, default_container));
+ 0, NULL));
EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(),
mock_lock_container.get()));
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc
index d0377a2..19166a0 100644
--- a/ash/focus_cycler_unittest.cc
+++ b/ash/focus_cycler_unittest.cc
@@ -48,10 +48,7 @@ TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
// Create a single test window.
- Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -78,10 +75,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
launcher->SetFocusCycler(focus_cycler.get());
// Create a single test window.
- Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -116,10 +110,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
launcher->SetFocusCycler(focus_cycler.get());
// Create a single test window.
- Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -154,10 +145,7 @@ TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
launcher->SetFocusCycler(focus_cycler.get());
// Create a single test window.
- Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -274,10 +262,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
launcher->SetFocusCycler(focus_cycler.get());
// Create a single test window.
- Window* default_container = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -308,10 +293,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
launcher->SetFocusCycler(focus_cycler.get());
// Create a single test window.
- Window* default_container = Shell::GetInstance()->GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
diff --git a/ash/launcher/launcher_context_menu_unittest.cc b/ash/launcher/launcher_context_menu_unittest.cc
index 04462d2..29faa9e 100644
--- a/ash/launcher/launcher_context_menu_unittest.cc
+++ b/ash/launcher/launcher_context_menu_unittest.cc
@@ -26,6 +26,7 @@ TEST_F(LauncherContextMenuTest, ToggleAutoHide) {
window->Init(ui::LAYER_TEXTURED);
window->SetParent(NULL);
window->Show();
+ wm::ActivateWindow(window.get());
Shell* shell = Shell::GetInstance();
// If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index dce879c..d6b0d59 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -85,7 +85,8 @@ void TestCreateWindow(views::Widget::InitParams::Type type,
views::Widget* widget = CreateTestWindow(widget_params);
widget->Show();
- EXPECT_EQ(expected_container, widget->GetNativeWindow()->parent()) <<
+ EXPECT_TRUE(expected_container->Contains(
+ widget->GetNativeWindow()->parent())) <<
"TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top;
widget->Close();
@@ -145,7 +146,8 @@ TEST_F(ShellTest, ChangeAlwaysOnTop) {
widget->Show();
// It should be in default container.
- EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+ EXPECT_TRUE(GetDefaultContainer()->Contains(
+ widget->GetNativeWindow()->parent()));
// Flip always-on-top flag.
widget->SetAlwaysOnTop(true);
@@ -155,12 +157,14 @@ TEST_F(ShellTest, ChangeAlwaysOnTop) {
// Flip always-on-top flag.
widget->SetAlwaysOnTop(false);
// It should go back to default container.
- EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+ EXPECT_TRUE(GetDefaultContainer()->Contains(
+ widget->GetNativeWindow()->parent()));
// Set the same always-on-top flag again.
widget->SetAlwaysOnTop(false);
// Should have no effect and we are still in the default container.
- EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+ EXPECT_TRUE(GetDefaultContainer()->Contains(
+ widget->GetNativeWindow()->parent()));
widget->Close();
}
@@ -174,7 +178,8 @@ TEST_F(ShellTest, CreateModalWindow) {
widget->Show();
// It should be in default container.
- EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+ EXPECT_TRUE(GetDefaultContainer()->Contains(
+ widget->GetNativeWindow()->parent()));
// Create a modal window.
views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
@@ -200,7 +205,8 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
widget->Show();
// It should be in default container.
- EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
+ EXPECT_TRUE(GetDefaultContainer()->Contains(
+ widget->GetNativeWindow()->parent()));
// Create a LockScreen window.
views::Widget* lock_widget = CreateTestWindow(widget_params);
@@ -264,8 +270,6 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
// We start with the usual window containers.
ExpectAllContainers();
- // We have a default container event filter (for window drags).
- EXPECT_TRUE(GetDefaultContainer()->event_filter());
// Launcher is visible.
views::Widget* launcher_widget = shell->launcher()->widget();
EXPECT_TRUE(launcher_widget->IsVisible());
@@ -290,6 +294,9 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
widget->Show();
EXPECT_FALSE(widget->IsMaximized());
+ // We have a default container event filter (for window drags).
+ EXPECT_TRUE(widget->GetNativeWindow()->parent()->event_filter());
+
// Clean up.
widget->Close();
}
diff --git a/ash/wm/activation_controller_unittest.cc b/ash/wm/activation_controller_unittest.cc
index 98f5195..28e6976 100644
--- a/ash/wm/activation_controller_unittest.cc
+++ b/ash/wm/activation_controller_unittest.cc
@@ -27,7 +27,7 @@
namespace {
// Containers used for the tests.
-const int c1 = ash::internal::kShellWindowId_DefaultContainer;
+const int kDefaultContainerID = -1; // Used to identify the default container.
const int c2 = ash::internal::kShellWindowId_AlwaysOnTopContainer;
const int c3 = ash::internal::kShellWindowId_LockScreenContainer;
@@ -72,10 +72,10 @@ class GetTopmostWindowToActivateTest : public ActivationControllerTest {
void CreateWindows() {
// Create four windows, the first and third are not activatable, the second
// and fourth are.
- w1_.reset(CreateWindow(1, &ad_1_, c1));
- w2_.reset(CreateWindow(2, &ad_2_, c1));
- w3_.reset(CreateWindow(3, &ad_3_, c1));
- w4_.reset(CreateWindow(4, &ad_4_, c1));
+ w1_.reset(CreateWindow(1, &ad_1_, kDefaultContainerID));
+ w2_.reset(CreateWindow(2, &ad_2_, kDefaultContainerID));
+ w3_.reset(CreateWindow(3, &ad_3_, kDefaultContainerID));
+ w4_.reset(CreateWindow(4, &ad_4_, kDefaultContainerID));
w5_.reset(CreateWindow(5, &ad_5_, c2));
w6_.reset(CreateWindow(6, &ad_6_, c2));
w7_.reset(CreateWindow(7, &ad_7_, c3));
@@ -84,11 +84,13 @@ class GetTopmostWindowToActivateTest : public ActivationControllerTest {
aura::Window* CreateWindow(int id,
TestActivationDelegate* delegate,
int container_id) {
+ aura::Window* parent = container_id == kDefaultContainerID ? NULL :
+ Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id);
aura::Window* window = aura::test::CreateTestWindowWithDelegate(
&delegate_,
id,
gfx::Rect(),
- Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id));
+ parent);
delegate->SetWindow(window);
return window;
}
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc
index 5050906..6241711 100644
--- a/ash/wm/frame_painter.cc
+++ b/ash/wm/frame_painter.cc
@@ -592,6 +592,9 @@ int FramePainter::GetHeaderOpacity(HeaderMode header_mode,
// static
bool FramePainter::UseSoloWindowHeader() {
+ if (!instances_)
+ return false; // Return value shouldn't matter.
+
int window_count = 0;
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
it != instances_->end();
@@ -610,6 +613,9 @@ bool FramePainter::UseSoloWindowHeader() {
// static
void FramePainter::SchedulePaintForSoloWindow() {
+ if (!instances_)
+ return;
+
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
it != instances_->end();
++it) {
diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc
index 62e98dc..c918f23 100644
--- a/ash/wm/frame_painter_unittest.cc
+++ b/ash/wm/frame_painter_unittest.cc
@@ -19,19 +19,11 @@ using views::ImageButton;
namespace {
-aura::Window* GetDefaultContainer() {
- return ash::Shell::GetContainer(
- ash::Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_DefaultContainer);
-}
-
// Creates a test widget that owns its native widget.
Widget* CreateTestWidget() {
Widget* widget = new Widget;
Widget::InitParams params;
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.parent = GetDefaultContainer();
- params.child = true;
widget->Init(params);
return widget;
}
@@ -40,8 +32,6 @@ Widget* CreateAlwaysOnTopWidget() {
Widget* widget = new Widget;
Widget::InitParams params;
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.parent = GetDefaultContainer();
- params.child = true;
params.keep_on_top = true;
widget->Init(params);
return widget;
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index 8717628..b0c8a68 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -12,6 +12,7 @@
#include "ash/shell_window_ids.h"
#include "ash/system/tray/system_tray.h"
#include "ash/test/ash_test_base.h"
+#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/display_manager.h"
@@ -64,10 +65,7 @@ class ShelfLayoutManagerTest : public ash::test::AshTestBase {
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_TEXTURED);
- aura::Window* parent = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- window->SetParent(parent);
+ window->SetParent(NULL);
return window;
}
@@ -440,6 +438,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
window->Show();
+ wm::ActivateWindow(window);
EXPECT_FALSE(shell->GetAppListTargetVisibility());
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
@@ -473,6 +472,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
window->SetBounds(gfx::Rect(0, 0, 100, 100));
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
window->Show();
+ wm::ActivateWindow(window);
// App list and shelf is not shown.
EXPECT_FALSE(shell->GetAppListTargetVisibility());
diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc
index 8784853..33397e6 100644
--- a/ash/wm/system_modal_container_layout_manager_unittest.cc
+++ b/ash/wm/system_modal_container_layout_manager_unittest.cc
@@ -29,12 +29,6 @@ aura::Window* GetModalContainer() {
ash::internal::kShellWindowId_SystemModalContainer);
}
-aura::Window* GetDefaultContainer() {
- return Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- ash::internal::kShellWindowId_DefaultContainer);
-}
-
class TestWindow : public views::WidgetDelegateView {
public:
explicit TestWindow(bool modal) : modal_(modal) {}
@@ -121,7 +115,7 @@ TEST_F(SystemModalContainerLayoutManagerTest, NonModalTransient) {
transient->AddObserver(&destruction_observer);
EXPECT_EQ(parent.get(), transient->transient_parent());
- EXPECT_EQ(GetDefaultContainer(), transient->parent());
+ EXPECT_EQ(parent->parent(), transient->parent());
// The transient should be destroyed with its parent.
parent.reset();
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index 7768b18..0a5f625 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -22,12 +22,8 @@ namespace internal {
typedef ash::test::AshTestBase WindowAnimationsTest;
TEST_F(WindowAnimationsTest, HideShow) {
- aura::Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
window->Show();
EXPECT_TRUE(window->layer()->visible());
// Hiding.
@@ -60,12 +56,8 @@ TEST_F(WindowAnimationsTest, HideShow) {
}
TEST_F(WindowAnimationsTest, ShowHide) {
- aura::Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
window->Show();
EXPECT_TRUE(window->layer()->visible());
// Showing -- should be a no-op.
@@ -98,12 +90,8 @@ TEST_F(WindowAnimationsTest, ShowHide) {
}
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
- aura::Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
window->Show();
EXPECT_TRUE(window->layer()->visible());
@@ -139,12 +127,8 @@ TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
}
TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
- aura::Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<aura::Window> window(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
// Layer target visibility changes according to Show/Hide.
window->Show();
@@ -158,12 +142,8 @@ TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
internal::SetDelayedOldLayerDeletionInCrossFadeForTest(true);
- Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
scoped_ptr<Window> window(
- aura::test::CreateTestWindowWithId(0, default_container));
+ aura::test::CreateTestWindowWithId(0, NULL));
window->SetBounds(gfx::Rect(5, 10, 320, 240));
window->Show();
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index 17128a6..6962816 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -15,10 +15,12 @@
#include "ash/wm/window_cycle_list.h"
#include "ash/wm/window_util.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/screen.h"
namespace ash {
@@ -38,11 +40,7 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
// Create a single test window.
- Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -58,11 +56,7 @@ TEST_F(WindowCycleControllerTest, SingleWindowNotActive) {
Shell::GetInstance()->window_cycle_controller();
// Create a single test window.
- Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
@@ -82,13 +76,9 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
// Set up several windows to use to test cycling. Create them in reverse
// order so they are stacked 0 over 1 over 2.
- Window* default_container =
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
+ scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
wm::ActivateWindow(window0.get());
// Simulate pressing and releasing Alt-tab.
@@ -192,12 +182,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
// Cycles between a maximized and normal window.
TEST_F(WindowCycleControllerTest, MaximizedWindow) {
// Create a couple of test windows.
- Window* default_container =
- ash::Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
wm::MaximizeWindow(window1.get());
wm::ActivateWindow(window1.get());
@@ -217,12 +203,8 @@ TEST_F(WindowCycleControllerTest, MaximizedWindow) {
// Cycles to a minimized window.
TEST_F(WindowCycleControllerTest, Minimized) {
// Create a couple of test windows.
- Window* default_container =
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
wm::MinimizeWindow(window1.get());
wm::ActivateWindow(window0.get());
@@ -245,12 +227,8 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
Shell::GetInstance()->window_cycle_controller();
// Set up several windows to use to test cycling.
- Window* default_container =
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
Window* top_container =
Shell::GetContainer(
@@ -293,12 +271,8 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) {
Shell::GetInstance()->window_cycle_controller();
// Set up several windows to use to test cycling.
- Window* default_container =
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
Window* top_container =
Shell::GetContainer(
@@ -347,41 +321,43 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) {
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
ASSERT_EQ(2U, root_windows.size());
- // Move the active root window to the secondary.
- Shell::GetInstance()->set_active_root_window(root_windows[1]);
-
WindowCycleController* controller =
Shell::GetInstance()->window_cycle_controller();
- // Set up several windows to use to test cycling.
- Window* default_container0 =
- Shell::GetContainer(
- root_windows[0],
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container0));
+ Shell::GetInstance()->set_active_root_window(root_windows[0]);
+ // Create two windows in the primary root.
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ EXPECT_EQ(root_windows[0], window0->GetRootWindow());
Window* top_container0 =
Shell::GetContainer(
root_windows[0],
internal::kShellWindowId_AlwaysOnTopContainer);
scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
+ EXPECT_EQ(root_windows[0], window1->GetRootWindow());
- // Set up several windows to use to test cycling.
- Window* default_container1 =
- Shell::GetContainer(
- root_windows[1],
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container1));
+ // And two on the secondary root.
+ Shell::GetInstance()->set_active_root_window(root_windows[1]);
+ scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
+ EXPECT_EQ(root_windows[1], window2->GetRootWindow());
Window* top_container1 =
Shell::GetContainer(
root_windows[1],
internal::kShellWindowId_AlwaysOnTopContainer);
scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1));
+ EXPECT_EQ(root_windows[1], window3->GetRootWindow());
+ // Move the active root window to the secondary.
+ Shell::GetInstance()->set_active_root_window(root_windows[1]);
wm::ActivateWindow(window2.get());
+ EXPECT_EQ(root_windows[0], window0->GetRootWindow());
+ EXPECT_EQ(root_windows[0], window1->GetRootWindow());
+ EXPECT_EQ(root_windows[1], window2->GetRootWindow());
+ EXPECT_EQ(root_windows[1], window3->GetRootWindow());
+
// Simulate pressing and releasing Alt-tab.
EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
@@ -420,13 +396,9 @@ TEST_F(WindowCycleControllerTest, MostRecentlyUsed) {
Shell::GetInstance()->window_cycle_controller();
// Set up several windows to use to test cycling.
- Window* container =
- Shell::GetContainer(
- Shell::GetPrimaryRootWindow(),
- internal::kShellWindowId_DefaultContainer);
- scoped_ptr<Window> window0(CreateTestWindowWithId(0, container));
- scoped_ptr<Window> window1(CreateTestWindowWithId(1, container));
- scoped_ptr<Window> window2(CreateTestWindowWithId(2, container));
+ scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
+ scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
+ scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
wm::ActivateWindow(window0.get());
diff --git a/ash/wm/workspace/multi_window_resize_controller_unittest.cc b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
index 6b29d6532..9cd4cba 100644
--- a/ash/wm/workspace/multi_window_resize_controller_unittest.cc
+++ b/ash/wm/workspace/multi_window_resize_controller_unittest.cc
@@ -32,7 +32,7 @@ class MultiWindowResizeControllerTest : public test::AshTestBase {
ash::Shell::TestApi(Shell::GetInstance()).workspace_controller();
wc->SetGridSize(0);
WorkspaceEventFilter* event_filter =
- WorkspaceControllerTestHelper(wc).filter();
+ WorkspaceControllerTestHelper(wc).GetFilter();
resize_controller_ = WorkspaceEventFilterTestHelper(event_filter).
resize_controller();
}
diff --git a/ash/wm/workspace/workspace_event_filter.cc b/ash/wm/workspace/workspace_event_filter.cc
index 8c9cb3c..8b64a62 100644
--- a/ash/wm/workspace/workspace_event_filter.cc
+++ b/ash/wm/workspace/workspace_event_filter.cc
@@ -8,7 +8,6 @@
#include "ash/wm/property_util.h"
#include "ash/wm/window_frame.h"
#include "ash/wm/window_util.h"
-#include "ash/wm/workspace/workspace_layout_manager.h"
#include "ash/wm/workspace/workspace_window_resizer.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
@@ -69,10 +68,13 @@ namespace internal {
WorkspaceEventFilter::WorkspaceEventFilter(aura::Window* owner)
: ToplevelWindowEventFilter(owner),
- hovered_window_(NULL) {
+ hovered_window_(NULL),
+ destroyed_(NULL) {
}
WorkspaceEventFilter::~WorkspaceEventFilter() {
+ if (destroyed_)
+ *destroyed_ = true;
if (hovered_window_)
hovered_window_->RemoveObserver(this);
}
@@ -95,14 +97,21 @@ bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target,
case ui::ET_MOUSE_EXITED:
UpdateHoveredWindow(NULL);
break;
- case ui::ET_MOUSE_PRESSED:
+ case ui::ET_MOUSE_PRESSED: {
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
target->delegate()->GetNonClientComponent(event->location()) ==
- HTCAPTION)
+ HTCAPTION) {
+ bool destroyed = false;
+ destroyed_ = &destroyed;
ToggleMaximizedState(target);
+ if (destroyed)
+ return false;
+ destroyed_ = NULL;
+ }
multi_window_resize_controller_.Hide();
HandleVerticalResizeDoubleClick(target, event);
break;
+ }
default:
break;
}
diff --git a/ash/wm/workspace/workspace_event_filter.h b/ash/wm/workspace/workspace_event_filter.h
index 75479df..98244b6e 100644
--- a/ash/wm/workspace/workspace_event_filter.h
+++ b/ash/wm/workspace/workspace_event_filter.h
@@ -57,6 +57,9 @@ class WorkspaceEventFilter : public ToplevelWindowEventFilter,
MultiWindowResizeController multi_window_resize_controller_;
+ // If non-NULL, set to true in the destructor.
+ bool* destroyed_;
+
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilter);
};
diff --git a/ash/wm/workspace/workspace_event_filter_unittest.cc b/ash/wm/workspace/workspace_event_filter_unittest.cc
index 9aafb1f..ff9b659 100644
--- a/ash/wm/workspace/workspace_event_filter_unittest.cc
+++ b/ash/wm/workspace/workspace_event_filter_unittest.cc
@@ -41,10 +41,7 @@ class WorkspaceEventFilterTest : public test::AshTestBase {
};
TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
- WorkspaceControllerTestHelper workspace_helper(
- Shell::TestApi(Shell::GetInstance()).workspace_controller());
- WorkspaceManager* manager = workspace_helper.workspace_manager();
- manager->set_grid_size(0);
+ Shell::TestApi(Shell::GetInstance()).workspace_controller()->SetGridSize(0);
// Double clicking the vertical resize edge of a window should maximize it
// vertically.
@@ -52,6 +49,8 @@ TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
aura::test::TestWindowDelegate wd;
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
+ wm::ActivateWindow(window.get());
+
gfx::Rect work_area =
gfx::Screen::GetDisplayNearestWindow(window.get()).work_area();
diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc
index aac67bc..db799c4 100644
--- a/ash/wm/workspace/workspace_manager.cc
+++ b/ash/wm/workspace/workspace_manager.cc
@@ -134,6 +134,10 @@ void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
workspace->Activate();
}
+void WorkspaceManager::SetGridSize(int grid_size) {
+ grid_size_ = grid_size;
+}
+
void WorkspaceManager::UpdateShelfVisibility() {
if (shelf_)
shelf_->UpdateVisibilityState();
diff --git a/ash/wm/workspace/workspace_manager.h b/ash/wm/workspace/workspace_manager.h
index bb685b8..67a6068 100644
--- a/ash/wm/workspace/workspace_manager.h
+++ b/ash/wm/workspace/workspace_manager.h
@@ -66,7 +66,7 @@ class ASH_EXPORT WorkspaceManager {
// Sets the size of the grid. Newly added windows are forced to align to the
// size of the grid.
- void set_grid_size(int size) { grid_size_ = size; }
+ void SetGridSize(int grid_size);
int grid_size() const { return grid_size_; }
void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; }
diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc
index 7c858d7..bcd845e 100644
--- a/ash/wm/workspace/workspace_manager_unittest.cc
+++ b/ash/wm/workspace/workspace_manager_unittest.cc
@@ -78,7 +78,7 @@ class WorkspaceManagerTest : public test::AshTestBase {
WorkspaceControllerTestHelper workspace_helper(
Shell::TestApi(Shell::GetInstance()).workspace_controller());
manager_ = workspace_helper.workspace_manager();
- manager_->set_grid_size(0);
+ manager_->SetGridSize(0);
}
virtual void TearDown() OVERRIDE {
manager_ = NULL;
@@ -303,7 +303,7 @@ TEST_F(WorkspaceManagerTest, ChangeBoundsOfNormalWindow) {
// Assertions around grid size.
TEST_F(WorkspaceManagerTest, SnapToGrid) {
- manager_->set_grid_size(8);
+ manager_->SetGridSize(8);
// Verify snap to grid when bounds are set before parented.
scoped_ptr<Window> w1(CreateTestWindowUnparented());
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 369ad8a..ad2a645 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -57,28 +57,25 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
root->SetHostSize(gfx::Size(800, kRootHeight));
- aura::Window* default_container =
- Shell::GetContainer(root, kShellWindowId_DefaultContainer);
-
gfx::Rect root_bounds(root->bounds());
EXPECT_EQ(kRootHeight, root_bounds.height());
Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
window_.reset(new aura::Window(&delegate_));
window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window_->Init(ui::LAYER_NOT_DRAWN);
- window_->SetParent(default_container);
+ window_->SetParent(NULL);
window_->set_id(1);
window2_.reset(new aura::Window(&delegate2_));
window2_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window2_->Init(ui::LAYER_NOT_DRAWN);
- window2_->SetParent(default_container);
+ window2_->SetParent(NULL);
window2_->set_id(2);
window3_.reset(new aura::Window(&delegate3_));
window3_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window3_->Init(ui::LAYER_NOT_DRAWN);
- window3_->SetParent(default_container);
+ window3_->SetParent(NULL);
window3_->set_id(3);
}
diff --git a/ash/wm/workspace_controller.cc b/ash/wm/workspace_controller.cc
index ea2262c..765daeb 100644
--- a/ash/wm/workspace_controller.cc
+++ b/ash/wm/workspace_controller.cc
@@ -51,7 +51,7 @@ bool WorkspaceController::IsInMaximizedMode() const {
}
void WorkspaceController::SetGridSize(int grid_size) {
- workspace_manager_->set_grid_size(grid_size);
+ workspace_manager_->SetGridSize(grid_size);
event_filter_->set_grid_size(grid_size);
}
diff --git a/ash/wm/workspace_controller_test_helper.cc b/ash/wm/workspace_controller_test_helper.cc
index db32844..75177ef 100644
--- a/ash/wm/workspace_controller_test_helper.cc
+++ b/ash/wm/workspace_controller_test_helper.cc
@@ -6,6 +6,7 @@
#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace/workspace_event_filter_test_helper.h"
+#include "ui/aura/window.h"
namespace ash {
namespace internal {
@@ -18,9 +19,13 @@ WorkspaceControllerTestHelper::WorkspaceControllerTestHelper(
WorkspaceControllerTestHelper::~WorkspaceControllerTestHelper() {
}
+WorkspaceEventFilter* WorkspaceControllerTestHelper::GetFilter() {
+ return controller_->event_filter_;
+}
+
MultiWindowResizeController*
WorkspaceControllerTestHelper::GetMultiWindowResizeController() {
- return WorkspaceEventFilterTestHelper(filter()).resize_controller();
+ return WorkspaceEventFilterTestHelper(GetFilter()).resize_controller();
}
} // namespace internal
diff --git a/ash/wm/workspace_controller_test_helper.h b/ash/wm/workspace_controller_test_helper.h
index 04b1943..c48f096 100644
--- a/ash/wm/workspace_controller_test_helper.h
+++ b/ash/wm/workspace_controller_test_helper.h
@@ -6,6 +6,7 @@
#define ASH_WM_WORKSPACE_CONTROLLER_TEST_HELPER_H_
#include "ash/wm/workspace_controller.h"
+#include "ash/wm/workspace/workspace_manager.h"
namespace ash {
namespace internal {
@@ -18,10 +19,11 @@ class WorkspaceControllerTestHelper {
explicit WorkspaceControllerTestHelper(WorkspaceController* controller);
~WorkspaceControllerTestHelper();
- WorkspaceEventFilter* filter() { return controller_->event_filter_; }
+ WorkspaceEventFilter* GetFilter();
MultiWindowResizeController* GetMultiWindowResizeController();
WorkspaceManager* workspace_manager() {
- return controller_->workspace_manager_.get();
+ return static_cast<WorkspaceManager*>(
+ controller_->workspace_manager_.get());
}
private: