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
This commit is contained in:
ash
accelerators
focus_cycler_unittest.cclauncher
shell_unittest.ccwm
activation_controller_unittest.ccframe_painter.ccframe_painter_unittest.ccshelf_layout_manager_unittest.ccsystem_modal_container_layout_manager_unittest.ccwindow_animations_unittest.ccwindow_cycle_controller_unittest.cc
workspace
multi_window_resize_controller_unittest.ccworkspace_event_filter.ccworkspace_event_filter.hworkspace_event_filter_unittest.ccworkspace_manager.ccworkspace_manager.hworkspace_manager_unittest.ccworkspace_window_resizer_unittest.cc
workspace_controller.ccworkspace_controller_test_helper.ccworkspace_controller_test_helper.hui/aura/client
@@ -79,15 +79,12 @@ TEST_F(AcceleratorFilterTest, TestFilterWithoutFocus) {
|
|||||||
|
|
||||||
// Tests if AcceleratorFilter works as expected with a focused window.
|
// Tests if AcceleratorFilter works as expected with a focused window.
|
||||||
TEST_F(AcceleratorFilterTest, TestFilterWithFocus) {
|
TEST_F(AcceleratorFilterTest, TestFilterWithFocus) {
|
||||||
aura::Window* default_container = Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
aura::test::TestWindowDelegate test_delegate;
|
aura::test::TestWindowDelegate test_delegate;
|
||||||
scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
|
scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
|
||||||
&test_delegate,
|
&test_delegate,
|
||||||
-1,
|
-1,
|
||||||
gfx::Rect(),
|
gfx::Rect(),
|
||||||
default_container));
|
NULL));
|
||||||
wm::ActivateWindow(window.get());
|
wm::ActivateWindow(window.get());
|
||||||
|
|
||||||
DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
|
DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate;
|
||||||
|
@@ -106,11 +106,8 @@ typedef AshTestBase NestedDispatcherTest;
|
|||||||
// Aura window below lock screen in z order.
|
// Aura window below lock screen in z order.
|
||||||
TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
|
TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
|
||||||
MockDispatcher inner_dispatcher;
|
MockDispatcher inner_dispatcher;
|
||||||
aura::Window* default_container = Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId(
|
scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId(
|
||||||
0, default_container));
|
0, NULL));
|
||||||
|
|
||||||
Shell::GetInstance()->delegate()->LockScreen();
|
Shell::GetInstance()->delegate()->LockScreen();
|
||||||
DispatchKeyReleaseA();
|
DispatchKeyReleaseA();
|
||||||
@@ -127,14 +124,11 @@ TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) {
|
|||||||
TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) {
|
TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) {
|
||||||
MockDispatcher inner_dispatcher;
|
MockDispatcher inner_dispatcher;
|
||||||
|
|
||||||
aura::Window* default_container = Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window>mock_lock_container(
|
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());
|
aura::test::CreateTestWindowWithId(0, mock_lock_container.get());
|
||||||
scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId(
|
scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId(
|
||||||
0, default_container));
|
0, NULL));
|
||||||
EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(),
|
EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(),
|
||||||
mock_lock_container.get()));
|
mock_lock_container.get()));
|
||||||
|
|
||||||
|
@@ -48,10 +48,7 @@ TEST_F(FocusCyclerTest, CycleFocusBrowserOnly) {
|
|||||||
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
|
scoped_ptr<FocusCycler> focus_cycler(new FocusCycler());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -78,10 +75,7 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
|
|||||||
launcher->SetFocusCycler(focus_cycler.get());
|
launcher->SetFocusCycler(focus_cycler.get());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -116,10 +110,7 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
|
|||||||
launcher->SetFocusCycler(focus_cycler.get());
|
launcher->SetFocusCycler(focus_cycler.get());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -154,10 +145,7 @@ TEST_F(FocusCyclerTest, CycleFocusForwardBackward) {
|
|||||||
launcher->SetFocusCycler(focus_cycler.get());
|
launcher->SetFocusCycler(focus_cycler.get());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -274,10 +262,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
|
|||||||
launcher->SetFocusCycler(focus_cycler.get());
|
launcher->SetFocusCycler(focus_cycler.get());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -308,10 +293,7 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
|
|||||||
launcher->SetFocusCycler(focus_cycler.get());
|
launcher->SetFocusCycler(focus_cycler.get());
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container = Shell::GetInstance()->GetContainer(
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ TEST_F(LauncherContextMenuTest, ToggleAutoHide) {
|
|||||||
window->Init(ui::LAYER_TEXTURED);
|
window->Init(ui::LAYER_TEXTURED);
|
||||||
window->SetParent(NULL);
|
window->SetParent(NULL);
|
||||||
window->Show();
|
window->Show();
|
||||||
|
wm::ActivateWindow(window.get());
|
||||||
|
|
||||||
Shell* shell = Shell::GetInstance();
|
Shell* shell = Shell::GetInstance();
|
||||||
// If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make
|
// If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make
|
||||||
|
@@ -85,7 +85,8 @@ void TestCreateWindow(views::Widget::InitParams::Type type,
|
|||||||
views::Widget* widget = CreateTestWindow(widget_params);
|
views::Widget* widget = CreateTestWindow(widget_params);
|
||||||
widget->Show();
|
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;
|
"TestCreateWindow: type=" << type << ", always_on_top=" << always_on_top;
|
||||||
|
|
||||||
widget->Close();
|
widget->Close();
|
||||||
@@ -145,7 +146,8 @@ TEST_F(ShellTest, ChangeAlwaysOnTop) {
|
|||||||
widget->Show();
|
widget->Show();
|
||||||
|
|
||||||
// It should be in default container.
|
// It should be in default container.
|
||||||
EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
|
EXPECT_TRUE(GetDefaultContainer()->Contains(
|
||||||
|
widget->GetNativeWindow()->parent()));
|
||||||
|
|
||||||
// Flip always-on-top flag.
|
// Flip always-on-top flag.
|
||||||
widget->SetAlwaysOnTop(true);
|
widget->SetAlwaysOnTop(true);
|
||||||
@@ -155,12 +157,14 @@ TEST_F(ShellTest, ChangeAlwaysOnTop) {
|
|||||||
// Flip always-on-top flag.
|
// Flip always-on-top flag.
|
||||||
widget->SetAlwaysOnTop(false);
|
widget->SetAlwaysOnTop(false);
|
||||||
// It should go back to default container.
|
// 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.
|
// Set the same always-on-top flag again.
|
||||||
widget->SetAlwaysOnTop(false);
|
widget->SetAlwaysOnTop(false);
|
||||||
// Should have no effect and we are still in the default container.
|
// 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();
|
widget->Close();
|
||||||
}
|
}
|
||||||
@@ -174,7 +178,8 @@ TEST_F(ShellTest, CreateModalWindow) {
|
|||||||
widget->Show();
|
widget->Show();
|
||||||
|
|
||||||
// It should be in default container.
|
// It should be in default container.
|
||||||
EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
|
EXPECT_TRUE(GetDefaultContainer()->Contains(
|
||||||
|
widget->GetNativeWindow()->parent()));
|
||||||
|
|
||||||
// Create a modal window.
|
// Create a modal window.
|
||||||
views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
|
views::Widget* modal_widget = views::Widget::CreateWindowWithParent(
|
||||||
@@ -200,7 +205,8 @@ TEST_F(ShellTest, CreateLockScreenModalWindow) {
|
|||||||
widget->Show();
|
widget->Show();
|
||||||
|
|
||||||
// It should be in default container.
|
// It should be in default container.
|
||||||
EXPECT_EQ(GetDefaultContainer(), widget->GetNativeWindow()->parent());
|
EXPECT_TRUE(GetDefaultContainer()->Contains(
|
||||||
|
widget->GetNativeWindow()->parent()));
|
||||||
|
|
||||||
// Create a LockScreen window.
|
// Create a LockScreen window.
|
||||||
views::Widget* lock_widget = CreateTestWindow(widget_params);
|
views::Widget* lock_widget = CreateTestWindow(widget_params);
|
||||||
@@ -264,8 +270,6 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
|
|||||||
|
|
||||||
// We start with the usual window containers.
|
// We start with the usual window containers.
|
||||||
ExpectAllContainers();
|
ExpectAllContainers();
|
||||||
// We have a default container event filter (for window drags).
|
|
||||||
EXPECT_TRUE(GetDefaultContainer()->event_filter());
|
|
||||||
// Launcher is visible.
|
// Launcher is visible.
|
||||||
views::Widget* launcher_widget = shell->launcher()->widget();
|
views::Widget* launcher_widget = shell->launcher()->widget();
|
||||||
EXPECT_TRUE(launcher_widget->IsVisible());
|
EXPECT_TRUE(launcher_widget->IsVisible());
|
||||||
@@ -290,6 +294,9 @@ TEST_F(ShellTest, MAYBE_ManagedWindowModeBasics) {
|
|||||||
widget->Show();
|
widget->Show();
|
||||||
EXPECT_FALSE(widget->IsMaximized());
|
EXPECT_FALSE(widget->IsMaximized());
|
||||||
|
|
||||||
|
// We have a default container event filter (for window drags).
|
||||||
|
EXPECT_TRUE(widget->GetNativeWindow()->parent()->event_filter());
|
||||||
|
|
||||||
// Clean up.
|
// Clean up.
|
||||||
widget->Close();
|
widget->Close();
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Containers used for the tests.
|
// 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 c2 = ash::internal::kShellWindowId_AlwaysOnTopContainer;
|
||||||
const int c3 = ash::internal::kShellWindowId_LockScreenContainer;
|
const int c3 = ash::internal::kShellWindowId_LockScreenContainer;
|
||||||
|
|
||||||
@@ -72,10 +72,10 @@ class GetTopmostWindowToActivateTest : public ActivationControllerTest {
|
|||||||
void CreateWindows() {
|
void CreateWindows() {
|
||||||
// Create four windows, the first and third are not activatable, the second
|
// Create four windows, the first and third are not activatable, the second
|
||||||
// and fourth are.
|
// and fourth are.
|
||||||
w1_.reset(CreateWindow(1, &ad_1_, c1));
|
w1_.reset(CreateWindow(1, &ad_1_, kDefaultContainerID));
|
||||||
w2_.reset(CreateWindow(2, &ad_2_, c1));
|
w2_.reset(CreateWindow(2, &ad_2_, kDefaultContainerID));
|
||||||
w3_.reset(CreateWindow(3, &ad_3_, c1));
|
w3_.reset(CreateWindow(3, &ad_3_, kDefaultContainerID));
|
||||||
w4_.reset(CreateWindow(4, &ad_4_, c1));
|
w4_.reset(CreateWindow(4, &ad_4_, kDefaultContainerID));
|
||||||
w5_.reset(CreateWindow(5, &ad_5_, c2));
|
w5_.reset(CreateWindow(5, &ad_5_, c2));
|
||||||
w6_.reset(CreateWindow(6, &ad_6_, c2));
|
w6_.reset(CreateWindow(6, &ad_6_, c2));
|
||||||
w7_.reset(CreateWindow(7, &ad_7_, c3));
|
w7_.reset(CreateWindow(7, &ad_7_, c3));
|
||||||
@@ -84,11 +84,13 @@ class GetTopmostWindowToActivateTest : public ActivationControllerTest {
|
|||||||
aura::Window* CreateWindow(int id,
|
aura::Window* CreateWindow(int id,
|
||||||
TestActivationDelegate* delegate,
|
TestActivationDelegate* delegate,
|
||||||
int container_id) {
|
int container_id) {
|
||||||
|
aura::Window* parent = container_id == kDefaultContainerID ? NULL :
|
||||||
|
Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id);
|
||||||
aura::Window* window = aura::test::CreateTestWindowWithDelegate(
|
aura::Window* window = aura::test::CreateTestWindowWithDelegate(
|
||||||
&delegate_,
|
&delegate_,
|
||||||
id,
|
id,
|
||||||
gfx::Rect(),
|
gfx::Rect(),
|
||||||
Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id));
|
parent);
|
||||||
delegate->SetWindow(window);
|
delegate->SetWindow(window);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
@@ -592,6 +592,9 @@ int FramePainter::GetHeaderOpacity(HeaderMode header_mode,
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool FramePainter::UseSoloWindowHeader() {
|
bool FramePainter::UseSoloWindowHeader() {
|
||||||
|
if (!instances_)
|
||||||
|
return false; // Return value shouldn't matter.
|
||||||
|
|
||||||
int window_count = 0;
|
int window_count = 0;
|
||||||
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
|
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
|
||||||
it != instances_->end();
|
it != instances_->end();
|
||||||
@@ -610,6 +613,9 @@ bool FramePainter::UseSoloWindowHeader() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
void FramePainter::SchedulePaintForSoloWindow() {
|
void FramePainter::SchedulePaintForSoloWindow() {
|
||||||
|
if (!instances_)
|
||||||
|
return;
|
||||||
|
|
||||||
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
|
for (std::set<FramePainter*>::const_iterator it = instances_->begin();
|
||||||
it != instances_->end();
|
it != instances_->end();
|
||||||
++it) {
|
++it) {
|
||||||
|
@@ -19,19 +19,11 @@ using views::ImageButton;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
aura::Window* GetDefaultContainer() {
|
|
||||||
return ash::Shell::GetContainer(
|
|
||||||
ash::Shell::GetPrimaryRootWindow(),
|
|
||||||
ash::internal::kShellWindowId_DefaultContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a test widget that owns its native widget.
|
// Creates a test widget that owns its native widget.
|
||||||
Widget* CreateTestWidget() {
|
Widget* CreateTestWidget() {
|
||||||
Widget* widget = new Widget;
|
Widget* widget = new Widget;
|
||||||
Widget::InitParams params;
|
Widget::InitParams params;
|
||||||
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
||||||
params.parent = GetDefaultContainer();
|
|
||||||
params.child = true;
|
|
||||||
widget->Init(params);
|
widget->Init(params);
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
@@ -40,8 +32,6 @@ Widget* CreateAlwaysOnTopWidget() {
|
|||||||
Widget* widget = new Widget;
|
Widget* widget = new Widget;
|
||||||
Widget::InitParams params;
|
Widget::InitParams params;
|
||||||
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
||||||
params.parent = GetDefaultContainer();
|
|
||||||
params.child = true;
|
|
||||||
params.keep_on_top = true;
|
params.keep_on_top = true;
|
||||||
widget->Init(params);
|
widget->Init(params);
|
||||||
return widget;
|
return widget;
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "ash/shell_window_ids.h"
|
#include "ash/shell_window_ids.h"
|
||||||
#include "ash/system/tray/system_tray.h"
|
#include "ash/system/tray/system_tray.h"
|
||||||
#include "ash/test/ash_test_base.h"
|
#include "ash/test/ash_test_base.h"
|
||||||
|
#include "ash/wm/window_util.h"
|
||||||
#include "ui/aura/client/aura_constants.h"
|
#include "ui/aura/client/aura_constants.h"
|
||||||
#include "ui/aura/env.h"
|
#include "ui/aura/env.h"
|
||||||
#include "ui/aura/display_manager.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->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
||||||
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
||||||
window->Init(ui::LAYER_TEXTURED);
|
window->Init(ui::LAYER_TEXTURED);
|
||||||
aura::Window* parent = Shell::GetContainer(
|
window->SetParent(NULL);
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
window->SetParent(parent);
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,6 +438,7 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
|
|||||||
window->SetBounds(gfx::Rect(0, 0, 100, 100));
|
window->SetBounds(gfx::Rect(0, 0, 100, 100));
|
||||||
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
||||||
window->Show();
|
window->Show();
|
||||||
|
wm::ActivateWindow(window);
|
||||||
|
|
||||||
EXPECT_FALSE(shell->GetAppListTargetVisibility());
|
EXPECT_FALSE(shell->GetAppListTargetVisibility());
|
||||||
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state());
|
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->SetBounds(gfx::Rect(0, 0, 100, 100));
|
||||||
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
||||||
window->Show();
|
window->Show();
|
||||||
|
wm::ActivateWindow(window);
|
||||||
|
|
||||||
// App list and shelf is not shown.
|
// App list and shelf is not shown.
|
||||||
EXPECT_FALSE(shell->GetAppListTargetVisibility());
|
EXPECT_FALSE(shell->GetAppListTargetVisibility());
|
||||||
|
@@ -29,12 +29,6 @@ aura::Window* GetModalContainer() {
|
|||||||
ash::internal::kShellWindowId_SystemModalContainer);
|
ash::internal::kShellWindowId_SystemModalContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
aura::Window* GetDefaultContainer() {
|
|
||||||
return Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
ash::internal::kShellWindowId_DefaultContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TestWindow : public views::WidgetDelegateView {
|
class TestWindow : public views::WidgetDelegateView {
|
||||||
public:
|
public:
|
||||||
explicit TestWindow(bool modal) : modal_(modal) {}
|
explicit TestWindow(bool modal) : modal_(modal) {}
|
||||||
@@ -121,7 +115,7 @@ TEST_F(SystemModalContainerLayoutManagerTest, NonModalTransient) {
|
|||||||
transient->AddObserver(&destruction_observer);
|
transient->AddObserver(&destruction_observer);
|
||||||
|
|
||||||
EXPECT_EQ(parent.get(), transient->transient_parent());
|
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.
|
// The transient should be destroyed with its parent.
|
||||||
parent.reset();
|
parent.reset();
|
||||||
|
@@ -22,12 +22,8 @@ namespace internal {
|
|||||||
typedef ash::test::AshTestBase WindowAnimationsTest;
|
typedef ash::test::AshTestBase WindowAnimationsTest;
|
||||||
|
|
||||||
TEST_F(WindowAnimationsTest, HideShow) {
|
TEST_F(WindowAnimationsTest, HideShow) {
|
||||||
aura::Window* default_container =
|
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window> window(
|
scoped_ptr<aura::Window> window(
|
||||||
aura::test::CreateTestWindowWithId(0, default_container));
|
aura::test::CreateTestWindowWithId(0, NULL));
|
||||||
window->Show();
|
window->Show();
|
||||||
EXPECT_TRUE(window->layer()->visible());
|
EXPECT_TRUE(window->layer()->visible());
|
||||||
// Hiding.
|
// Hiding.
|
||||||
@@ -60,12 +56,8 @@ TEST_F(WindowAnimationsTest, HideShow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WindowAnimationsTest, ShowHide) {
|
TEST_F(WindowAnimationsTest, ShowHide) {
|
||||||
aura::Window* default_container =
|
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window> window(
|
scoped_ptr<aura::Window> window(
|
||||||
aura::test::CreateTestWindowWithId(0, default_container));
|
aura::test::CreateTestWindowWithId(0, NULL));
|
||||||
window->Show();
|
window->Show();
|
||||||
EXPECT_TRUE(window->layer()->visible());
|
EXPECT_TRUE(window->layer()->visible());
|
||||||
// Showing -- should be a no-op.
|
// Showing -- should be a no-op.
|
||||||
@@ -98,12 +90,8 @@ TEST_F(WindowAnimationsTest, ShowHide) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
|
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
|
||||||
aura::Window* default_container =
|
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window> window(
|
scoped_ptr<aura::Window> window(
|
||||||
aura::test::CreateTestWindowWithId(0, default_container));
|
aura::test::CreateTestWindowWithId(0, NULL));
|
||||||
window->Show();
|
window->Show();
|
||||||
EXPECT_TRUE(window->layer()->visible());
|
EXPECT_TRUE(window->layer()->visible());
|
||||||
|
|
||||||
@@ -139,12 +127,8 @@ TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
|
TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
|
||||||
aura::Window* default_container =
|
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<aura::Window> window(
|
scoped_ptr<aura::Window> window(
|
||||||
aura::test::CreateTestWindowWithId(0, default_container));
|
aura::test::CreateTestWindowWithId(0, NULL));
|
||||||
|
|
||||||
// Layer target visibility changes according to Show/Hide.
|
// Layer target visibility changes according to Show/Hide.
|
||||||
window->Show();
|
window->Show();
|
||||||
@@ -158,12 +142,8 @@ TEST_F(WindowAnimationsTest, LayerTargetVisibility) {
|
|||||||
TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
|
TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
|
||||||
internal::SetDelayedOldLayerDeletionInCrossFadeForTest(true);
|
internal::SetDelayedOldLayerDeletionInCrossFadeForTest(true);
|
||||||
|
|
||||||
Window* default_container =
|
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window(
|
scoped_ptr<Window> window(
|
||||||
aura::test::CreateTestWindowWithId(0, default_container));
|
aura::test::CreateTestWindowWithId(0, NULL));
|
||||||
window->SetBounds(gfx::Rect(5, 10, 320, 240));
|
window->SetBounds(gfx::Rect(5, 10, 320, 240));
|
||||||
window->Show();
|
window->Show();
|
||||||
|
|
||||||
|
@@ -15,10 +15,12 @@
|
|||||||
#include "ash/wm/window_cycle_list.h"
|
#include "ash/wm/window_cycle_list.h"
|
||||||
#include "ash/wm/window_util.h"
|
#include "ash/wm/window_util.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
|
#include "ui/aura/client/screen_position_client.h"
|
||||||
#include "ui/aura/env.h"
|
#include "ui/aura/env.h"
|
||||||
#include "ui/aura/test/test_windows.h"
|
#include "ui/aura/test/test_windows.h"
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
|
#include "ui/gfx/screen.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
|
|
||||||
@@ -38,11 +40,7 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
|
|||||||
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
|
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window0.get()));
|
||||||
|
|
||||||
@@ -58,11 +56,7 @@ TEST_F(WindowCycleControllerTest, SingleWindowNotActive) {
|
|||||||
Shell::GetInstance()->window_cycle_controller();
|
Shell::GetInstance()->window_cycle_controller();
|
||||||
|
|
||||||
// Create a single test window.
|
// Create a single test window.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
ash::Shell::GetContainer(
|
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(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
|
// Set up several windows to use to test cycling. Create them in reverse
|
||||||
// order so they are stacked 0 over 1 over 2.
|
// order so they are stacked 0 over 1 over 2.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
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));
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
|
|
||||||
// Simulate pressing and releasing Alt-tab.
|
// Simulate pressing and releasing Alt-tab.
|
||||||
@@ -192,12 +182,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
|
|||||||
// Cycles between a maximized and normal window.
|
// Cycles between a maximized and normal window.
|
||||||
TEST_F(WindowCycleControllerTest, MaximizedWindow) {
|
TEST_F(WindowCycleControllerTest, MaximizedWindow) {
|
||||||
// Create a couple of test windows.
|
// Create a couple of test windows.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
ash::Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
|
|
||||||
|
|
||||||
wm::MaximizeWindow(window1.get());
|
wm::MaximizeWindow(window1.get());
|
||||||
wm::ActivateWindow(window1.get());
|
wm::ActivateWindow(window1.get());
|
||||||
@@ -217,12 +203,8 @@ TEST_F(WindowCycleControllerTest, MaximizedWindow) {
|
|||||||
// Cycles to a minimized window.
|
// Cycles to a minimized window.
|
||||||
TEST_F(WindowCycleControllerTest, Minimized) {
|
TEST_F(WindowCycleControllerTest, Minimized) {
|
||||||
// Create a couple of test windows.
|
// Create a couple of test windows.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
|
|
||||||
|
|
||||||
wm::MinimizeWindow(window1.get());
|
wm::MinimizeWindow(window1.get());
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
@@ -245,12 +227,8 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) {
|
|||||||
Shell::GetInstance()->window_cycle_controller();
|
Shell::GetInstance()->window_cycle_controller();
|
||||||
|
|
||||||
// Set up several windows to use to test cycling.
|
// Set up several windows to use to test cycling.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
|
|
||||||
|
|
||||||
Window* top_container =
|
Window* top_container =
|
||||||
Shell::GetContainer(
|
Shell::GetContainer(
|
||||||
@@ -293,12 +271,8 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) {
|
|||||||
Shell::GetInstance()->window_cycle_controller();
|
Shell::GetInstance()->window_cycle_controller();
|
||||||
|
|
||||||
// Set up several windows to use to test cycling.
|
// Set up several windows to use to test cycling.
|
||||||
Window* default_container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container));
|
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, default_container));
|
|
||||||
|
|
||||||
Window* top_container =
|
Window* top_container =
|
||||||
Shell::GetContainer(
|
Shell::GetContainer(
|
||||||
@@ -347,41 +321,43 @@ TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) {
|
|||||||
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
|
||||||
ASSERT_EQ(2U, root_windows.size());
|
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 =
|
WindowCycleController* controller =
|
||||||
Shell::GetInstance()->window_cycle_controller();
|
Shell::GetInstance()->window_cycle_controller();
|
||||||
|
|
||||||
// Set up several windows to use to test cycling.
|
Shell::GetInstance()->set_active_root_window(root_windows[0]);
|
||||||
Window* default_container0 =
|
|
||||||
Shell::GetContainer(
|
|
||||||
root_windows[0],
|
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, default_container0));
|
|
||||||
|
|
||||||
|
// Create two windows in the primary root.
|
||||||
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
|
EXPECT_EQ(root_windows[0], window0->GetRootWindow());
|
||||||
Window* top_container0 =
|
Window* top_container0 =
|
||||||
Shell::GetContainer(
|
Shell::GetContainer(
|
||||||
root_windows[0],
|
root_windows[0],
|
||||||
internal::kShellWindowId_AlwaysOnTopContainer);
|
internal::kShellWindowId_AlwaysOnTopContainer);
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0));
|
||||||
|
EXPECT_EQ(root_windows[0], window1->GetRootWindow());
|
||||||
|
|
||||||
// Set up several windows to use to test cycling.
|
// And two on the secondary root.
|
||||||
Window* default_container1 =
|
Shell::GetInstance()->set_active_root_window(root_windows[1]);
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
|
||||||
root_windows[1],
|
EXPECT_EQ(root_windows[1], window2->GetRootWindow());
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window2(CreateTestWindowWithId(2, default_container1));
|
|
||||||
|
|
||||||
Window* top_container1 =
|
Window* top_container1 =
|
||||||
Shell::GetContainer(
|
Shell::GetContainer(
|
||||||
root_windows[1],
|
root_windows[1],
|
||||||
internal::kShellWindowId_AlwaysOnTopContainer);
|
internal::kShellWindowId_AlwaysOnTopContainer);
|
||||||
scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1));
|
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());
|
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.
|
// Simulate pressing and releasing Alt-tab.
|
||||||
EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
|
EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
|
||||||
controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
|
controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
|
||||||
@@ -420,13 +396,9 @@ TEST_F(WindowCycleControllerTest, MostRecentlyUsed) {
|
|||||||
Shell::GetInstance()->window_cycle_controller();
|
Shell::GetInstance()->window_cycle_controller();
|
||||||
|
|
||||||
// Set up several windows to use to test cycling.
|
// Set up several windows to use to test cycling.
|
||||||
Window* container =
|
scoped_ptr<Window> window0(CreateTestWindowWithId(0, NULL));
|
||||||
Shell::GetContainer(
|
scoped_ptr<Window> window1(CreateTestWindowWithId(1, NULL));
|
||||||
Shell::GetPrimaryRootWindow(),
|
scoped_ptr<Window> window2(CreateTestWindowWithId(2, NULL));
|
||||||
internal::kShellWindowId_DefaultContainer);
|
|
||||||
scoped_ptr<Window> window0(CreateTestWindowWithId(0, container));
|
|
||||||
scoped_ptr<Window> window1(CreateTestWindowWithId(1, container));
|
|
||||||
scoped_ptr<Window> window2(CreateTestWindowWithId(2, container));
|
|
||||||
|
|
||||||
wm::ActivateWindow(window0.get());
|
wm::ActivateWindow(window0.get());
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ class MultiWindowResizeControllerTest : public test::AshTestBase {
|
|||||||
ash::Shell::TestApi(Shell::GetInstance()).workspace_controller();
|
ash::Shell::TestApi(Shell::GetInstance()).workspace_controller();
|
||||||
wc->SetGridSize(0);
|
wc->SetGridSize(0);
|
||||||
WorkspaceEventFilter* event_filter =
|
WorkspaceEventFilter* event_filter =
|
||||||
WorkspaceControllerTestHelper(wc).filter();
|
WorkspaceControllerTestHelper(wc).GetFilter();
|
||||||
resize_controller_ = WorkspaceEventFilterTestHelper(event_filter).
|
resize_controller_ = WorkspaceEventFilterTestHelper(event_filter).
|
||||||
resize_controller();
|
resize_controller();
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
#include "ash/wm/property_util.h"
|
#include "ash/wm/property_util.h"
|
||||||
#include "ash/wm/window_frame.h"
|
#include "ash/wm/window_frame.h"
|
||||||
#include "ash/wm/window_util.h"
|
#include "ash/wm/window_util.h"
|
||||||
#include "ash/wm/workspace/workspace_layout_manager.h"
|
|
||||||
#include "ash/wm/workspace/workspace_window_resizer.h"
|
#include "ash/wm/workspace/workspace_window_resizer.h"
|
||||||
#include "ui/aura/client/aura_constants.h"
|
#include "ui/aura/client/aura_constants.h"
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
@@ -69,10 +68,13 @@ namespace internal {
|
|||||||
|
|
||||||
WorkspaceEventFilter::WorkspaceEventFilter(aura::Window* owner)
|
WorkspaceEventFilter::WorkspaceEventFilter(aura::Window* owner)
|
||||||
: ToplevelWindowEventFilter(owner),
|
: ToplevelWindowEventFilter(owner),
|
||||||
hovered_window_(NULL) {
|
hovered_window_(NULL),
|
||||||
|
destroyed_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceEventFilter::~WorkspaceEventFilter() {
|
WorkspaceEventFilter::~WorkspaceEventFilter() {
|
||||||
|
if (destroyed_)
|
||||||
|
*destroyed_ = true;
|
||||||
if (hovered_window_)
|
if (hovered_window_)
|
||||||
hovered_window_->RemoveObserver(this);
|
hovered_window_->RemoveObserver(this);
|
||||||
}
|
}
|
||||||
@@ -95,14 +97,21 @@ bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target,
|
|||||||
case ui::ET_MOUSE_EXITED:
|
case ui::ET_MOUSE_EXITED:
|
||||||
UpdateHoveredWindow(NULL);
|
UpdateHoveredWindow(NULL);
|
||||||
break;
|
break;
|
||||||
case ui::ET_MOUSE_PRESSED:
|
case ui::ET_MOUSE_PRESSED: {
|
||||||
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
|
if (event->flags() & ui::EF_IS_DOUBLE_CLICK &&
|
||||||
target->delegate()->GetNonClientComponent(event->location()) ==
|
target->delegate()->GetNonClientComponent(event->location()) ==
|
||||||
HTCAPTION)
|
HTCAPTION) {
|
||||||
|
bool destroyed = false;
|
||||||
|
destroyed_ = &destroyed;
|
||||||
ToggleMaximizedState(target);
|
ToggleMaximizedState(target);
|
||||||
|
if (destroyed)
|
||||||
|
return false;
|
||||||
|
destroyed_ = NULL;
|
||||||
|
}
|
||||||
multi_window_resize_controller_.Hide();
|
multi_window_resize_controller_.Hide();
|
||||||
HandleVerticalResizeDoubleClick(target, event);
|
HandleVerticalResizeDoubleClick(target, event);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -57,6 +57,9 @@ class WorkspaceEventFilter : public ToplevelWindowEventFilter,
|
|||||||
|
|
||||||
MultiWindowResizeController multi_window_resize_controller_;
|
MultiWindowResizeController multi_window_resize_controller_;
|
||||||
|
|
||||||
|
// If non-NULL, set to true in the destructor.
|
||||||
|
bool* destroyed_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilter);
|
DISALLOW_COPY_AND_ASSIGN(WorkspaceEventFilter);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -41,10 +41,7 @@ class WorkspaceEventFilterTest : public test::AshTestBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
|
TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
|
||||||
WorkspaceControllerTestHelper workspace_helper(
|
Shell::TestApi(Shell::GetInstance()).workspace_controller()->SetGridSize(0);
|
||||||
Shell::TestApi(Shell::GetInstance()).workspace_controller());
|
|
||||||
WorkspaceManager* manager = workspace_helper.workspace_manager();
|
|
||||||
manager->set_grid_size(0);
|
|
||||||
|
|
||||||
// Double clicking the vertical resize edge of a window should maximize it
|
// Double clicking the vertical resize edge of a window should maximize it
|
||||||
// vertically.
|
// vertically.
|
||||||
@@ -52,6 +49,8 @@ TEST_F(WorkspaceEventFilterTest, DoubleClickSingleAxisResizeEdge) {
|
|||||||
aura::test::TestWindowDelegate wd;
|
aura::test::TestWindowDelegate wd;
|
||||||
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
|
scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
|
||||||
|
|
||||||
|
wm::ActivateWindow(window.get());
|
||||||
|
|
||||||
gfx::Rect work_area =
|
gfx::Rect work_area =
|
||||||
gfx::Screen::GetDisplayNearestWindow(window.get()).work_area();
|
gfx::Screen::GetDisplayNearestWindow(window.get()).work_area();
|
||||||
|
|
||||||
|
@@ -134,6 +134,10 @@ void WorkspaceManager::SetActiveWorkspaceByWindow(aura::Window* window) {
|
|||||||
workspace->Activate();
|
workspace->Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorkspaceManager::SetGridSize(int grid_size) {
|
||||||
|
grid_size_ = grid_size;
|
||||||
|
}
|
||||||
|
|
||||||
void WorkspaceManager::UpdateShelfVisibility() {
|
void WorkspaceManager::UpdateShelfVisibility() {
|
||||||
if (shelf_)
|
if (shelf_)
|
||||||
shelf_->UpdateVisibilityState();
|
shelf_->UpdateVisibilityState();
|
||||||
|
@@ -66,7 +66,7 @@ class ASH_EXPORT WorkspaceManager {
|
|||||||
|
|
||||||
// Sets the size of the grid. Newly added windows are forced to align to the
|
// Sets the size of the grid. Newly added windows are forced to align to the
|
||||||
// size of the grid.
|
// 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_; }
|
int grid_size() const { return grid_size_; }
|
||||||
|
|
||||||
void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; }
|
void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; }
|
||||||
|
@@ -78,7 +78,7 @@ class WorkspaceManagerTest : public test::AshTestBase {
|
|||||||
WorkspaceControllerTestHelper workspace_helper(
|
WorkspaceControllerTestHelper workspace_helper(
|
||||||
Shell::TestApi(Shell::GetInstance()).workspace_controller());
|
Shell::TestApi(Shell::GetInstance()).workspace_controller());
|
||||||
manager_ = workspace_helper.workspace_manager();
|
manager_ = workspace_helper.workspace_manager();
|
||||||
manager_->set_grid_size(0);
|
manager_->SetGridSize(0);
|
||||||
}
|
}
|
||||||
virtual void TearDown() OVERRIDE {
|
virtual void TearDown() OVERRIDE {
|
||||||
manager_ = NULL;
|
manager_ = NULL;
|
||||||
@@ -303,7 +303,7 @@ TEST_F(WorkspaceManagerTest, ChangeBoundsOfNormalWindow) {
|
|||||||
|
|
||||||
// Assertions around grid size.
|
// Assertions around grid size.
|
||||||
TEST_F(WorkspaceManagerTest, SnapToGrid) {
|
TEST_F(WorkspaceManagerTest, SnapToGrid) {
|
||||||
manager_->set_grid_size(8);
|
manager_->SetGridSize(8);
|
||||||
|
|
||||||
// Verify snap to grid when bounds are set before parented.
|
// Verify snap to grid when bounds are set before parented.
|
||||||
scoped_ptr<Window> w1(CreateTestWindowUnparented());
|
scoped_ptr<Window> w1(CreateTestWindowUnparented());
|
||||||
|
@@ -57,28 +57,25 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
|
|||||||
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
|
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
|
||||||
root->SetHostSize(gfx::Size(800, kRootHeight));
|
root->SetHostSize(gfx::Size(800, kRootHeight));
|
||||||
|
|
||||||
aura::Window* default_container =
|
|
||||||
Shell::GetContainer(root, kShellWindowId_DefaultContainer);
|
|
||||||
|
|
||||||
gfx::Rect root_bounds(root->bounds());
|
gfx::Rect root_bounds(root->bounds());
|
||||||
EXPECT_EQ(kRootHeight, root_bounds.height());
|
EXPECT_EQ(kRootHeight, root_bounds.height());
|
||||||
Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
|
Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
|
||||||
window_.reset(new aura::Window(&delegate_));
|
window_.reset(new aura::Window(&delegate_));
|
||||||
window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
||||||
window_->Init(ui::LAYER_NOT_DRAWN);
|
window_->Init(ui::LAYER_NOT_DRAWN);
|
||||||
window_->SetParent(default_container);
|
window_->SetParent(NULL);
|
||||||
window_->set_id(1);
|
window_->set_id(1);
|
||||||
|
|
||||||
window2_.reset(new aura::Window(&delegate2_));
|
window2_.reset(new aura::Window(&delegate2_));
|
||||||
window2_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
window2_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
||||||
window2_->Init(ui::LAYER_NOT_DRAWN);
|
window2_->Init(ui::LAYER_NOT_DRAWN);
|
||||||
window2_->SetParent(default_container);
|
window2_->SetParent(NULL);
|
||||||
window2_->set_id(2);
|
window2_->set_id(2);
|
||||||
|
|
||||||
window3_.reset(new aura::Window(&delegate3_));
|
window3_.reset(new aura::Window(&delegate3_));
|
||||||
window3_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
window3_->SetType(aura::client::WINDOW_TYPE_NORMAL);
|
||||||
window3_->Init(ui::LAYER_NOT_DRAWN);
|
window3_->Init(ui::LAYER_NOT_DRAWN);
|
||||||
window3_->SetParent(default_container);
|
window3_->SetParent(NULL);
|
||||||
window3_->set_id(3);
|
window3_->set_id(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ bool WorkspaceController::IsInMaximizedMode() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorkspaceController::SetGridSize(int grid_size) {
|
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);
|
event_filter_->set_grid_size(grid_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "ash/wm/workspace_controller.h"
|
#include "ash/wm/workspace_controller.h"
|
||||||
#include "ash/wm/workspace/workspace_event_filter_test_helper.h"
|
#include "ash/wm/workspace/workspace_event_filter_test_helper.h"
|
||||||
|
#include "ui/aura/window.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -18,9 +19,13 @@ WorkspaceControllerTestHelper::WorkspaceControllerTestHelper(
|
|||||||
WorkspaceControllerTestHelper::~WorkspaceControllerTestHelper() {
|
WorkspaceControllerTestHelper::~WorkspaceControllerTestHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorkspaceEventFilter* WorkspaceControllerTestHelper::GetFilter() {
|
||||||
|
return controller_->event_filter_;
|
||||||
|
}
|
||||||
|
|
||||||
MultiWindowResizeController*
|
MultiWindowResizeController*
|
||||||
WorkspaceControllerTestHelper::GetMultiWindowResizeController() {
|
WorkspaceControllerTestHelper::GetMultiWindowResizeController() {
|
||||||
return WorkspaceEventFilterTestHelper(filter()).resize_controller();
|
return WorkspaceEventFilterTestHelper(GetFilter()).resize_controller();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#define ASH_WM_WORKSPACE_CONTROLLER_TEST_HELPER_H_
|
#define ASH_WM_WORKSPACE_CONTROLLER_TEST_HELPER_H_
|
||||||
|
|
||||||
#include "ash/wm/workspace_controller.h"
|
#include "ash/wm/workspace_controller.h"
|
||||||
|
#include "ash/wm/workspace/workspace_manager.h"
|
||||||
|
|
||||||
namespace ash {
|
namespace ash {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@@ -18,10 +19,11 @@ class WorkspaceControllerTestHelper {
|
|||||||
explicit WorkspaceControllerTestHelper(WorkspaceController* controller);
|
explicit WorkspaceControllerTestHelper(WorkspaceController* controller);
|
||||||
~WorkspaceControllerTestHelper();
|
~WorkspaceControllerTestHelper();
|
||||||
|
|
||||||
WorkspaceEventFilter* filter() { return controller_->event_filter_; }
|
WorkspaceEventFilter* GetFilter();
|
||||||
MultiWindowResizeController* GetMultiWindowResizeController();
|
MultiWindowResizeController* GetMultiWindowResizeController();
|
||||||
WorkspaceManager* workspace_manager() {
|
WorkspaceManager* workspace_manager() {
|
||||||
return controller_->workspace_manager_.get();
|
return static_cast<WorkspaceManager*>(
|
||||||
|
controller_->workspace_manager_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -22,6 +22,8 @@ class AURA_EXPORT StackingClient {
|
|||||||
|
|
||||||
// Called by the Window when its parent is set to NULL, returns the window
|
// Called by the Window when its parent is set to NULL, returns the window
|
||||||
// that |window| should be added to instead.
|
// that |window| should be added to instead.
|
||||||
|
// NOTE: this may have side effects. It should only be used when |window| is
|
||||||
|
// going to be immediately added.
|
||||||
virtual Window* GetDefaultParent(Window* window, const gfx::Rect& bounds) = 0;
|
virtual Window* GetDefaultParent(Window* window, const gfx::Rect& bounds) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user