| Index: ui/aura_shell/workspace/workspace_manager_unittest.cc
|
| diff --git a/ui/aura_shell/workspace/workspace_manager_unittest.cc b/ui/aura_shell/workspace/workspace_manager_unittest.cc
|
| index e7ea6f2e07d896b2f35b03aef83eb8bec425f9e4..943d9267d46b91e5fe601e8de5aaba12797f50eb 100644
|
| --- a/ui/aura_shell/workspace/workspace_manager_unittest.cc
|
| +++ b/ui/aura_shell/workspace/workspace_manager_unittest.cc
|
| @@ -6,6 +6,9 @@
|
| #include "ui/aura_shell/workspace/workspace.h"
|
|
|
| #include "ui/aura/test/aura_test_base.h"
|
| +#include "ui/aura/test/test_desktop_delegate.h"
|
| +#include "ui/aura/desktop.h"
|
| +#include "ui/aura/screen_aura.h"
|
| #include "ui/aura/window.h"
|
|
|
| namespace {
|
| @@ -17,6 +20,10 @@ class WorkspaceManagerTestBase : public aura::test::AuraTestBase {
|
| window->Init();
|
| return window;
|
| }
|
| +
|
| + aura::Window* viewport() {
|
| + return GetTestDesktopDelegate()->default_container();
|
| + }
|
| };
|
|
|
| } // namespace
|
| @@ -25,12 +32,13 @@ namespace aura_shell {
|
|
|
| using aura::Window;
|
| using aura_shell::Workspace;
|
| +using aura_shell::WorkspaceManager;
|
|
|
| class WorkspaceManagerTest : public WorkspaceManagerTestBase {
|
| };
|
|
|
| -TEST_F(WorkspaceManagerTest, WorkspaceManagerBaic) {
|
| - WorkspaceManager manager;
|
| +TEST_F(WorkspaceManagerTest, WorkspaceManagerCreateAddFind) {
|
| + WorkspaceManager manager(viewport());
|
| scoped_ptr<Window> w1(CreateTestWindow());
|
| scoped_ptr<Window> w2(CreateTestWindow());
|
|
|
| @@ -54,27 +62,88 @@ TEST_F(WorkspaceManagerTest, WorkspaceManagerBaic) {
|
| EXPECT_EQ(NULL, manager.FindBy(w2.get()));
|
| }
|
|
|
| -TEST_F(WorkspaceManagerTest, WorkspaceManagerLayout) {
|
| - WorkspaceManager manager;
|
| - manager.set_workspace_size(gfx::Size(100, 100));
|
| - EXPECT_EQ(0, manager.GetTotalWidth());
|
| +TEST_F(WorkspaceManagerTest, LayoutWorkspaces) {
|
| + WorkspaceManager manager(viewport());
|
| + manager.workspace_size_ = gfx::Size(100, 100);
|
| + manager.LayoutWorkspaces();
|
| + EXPECT_EQ("0,0 100x100", viewport()->bounds().ToString());
|
|
|
| Workspace* ws1 = manager.CreateWorkspace();
|
| - manager.Layout();
|
| + manager.LayoutWorkspaces();
|
| +
|
| // ws1 is laied out in left most position.
|
| - EXPECT_EQ(100, manager.GetTotalWidth());
|
| + EXPECT_EQ(100, viewport()->bounds().width());
|
| EXPECT_EQ("0,0 100x100", ws1->bounds().ToString());
|
|
|
| // ws2 is laied out next to ws1, with 50 margin.
|
| Workspace* ws2 = manager.CreateWorkspace();
|
| - manager.Layout();
|
| - EXPECT_EQ(250, manager.GetTotalWidth());
|
| + manager.LayoutWorkspaces();
|
| +
|
| + EXPECT_EQ(250, viewport()->bounds().width());
|
| EXPECT_EQ("0,0 100x100", ws1->bounds().ToString());
|
| EXPECT_EQ("150,0 100x100", ws2->bounds().ToString());
|
| }
|
|
|
| +TEST_F(WorkspaceManagerTest, WorkspaceManagerDragArea) {
|
| + aura::Desktop::GetInstance()->screen()->set_work_area_insets(
|
| + gfx::Insets(10, 10, 10, 10));
|
| +
|
| + WorkspaceManager manager(viewport());
|
| + viewport()->SetBounds(gfx::Rect(0, 0, 200, 200));
|
| + EXPECT_EQ("10,10 180x180", manager.GetDragAreaBounds().ToString());
|
| +}
|
| +
|
| +TEST_F(WorkspaceManagerTest, Overview) {
|
| + WorkspaceManager manager(viewport());
|
| + manager.workspace_size_ = gfx::Size(500, 300);
|
| +
|
| + // Creating two workspaces, ws1 which contains window w1,
|
| + // and ws2 which contains window w2.
|
| + Workspace* ws1 = manager.CreateWorkspace();
|
| + scoped_ptr<Window> w1(CreateTestWindow());
|
| + viewport()->AddChild(w1.get());
|
| + EXPECT_TRUE(ws1->AddWindowAfter(w1.get(), NULL));
|
| +
|
| + Workspace* ws2 = manager.CreateWorkspace();
|
| + scoped_ptr<Window> w2(CreateTestWindow());
|
| + viewport()->AddChild(w2.get());
|
| + EXPECT_TRUE(ws2->AddWindowAfter(w2.get(), NULL));
|
| +
|
| + // Activating a window switches the active workspace.
|
| + w2->Activate();
|
| + EXPECT_EQ(ws2, manager.GetActiveWorkspace());
|
| +
|
| + // The size of viewport() is now ws1(500) + ws2(500) + margin(50).
|
| + EXPECT_EQ("0,0 1050x300", viewport()->bounds().ToString());
|
| + EXPECT_FALSE(manager.is_overview());
|
| + manager.SetOverview(true);
|
| + EXPECT_TRUE(manager.is_overview());
|
| +
|
| + // Switching overview mode doesn't change the active workspace.
|
| + EXPECT_EQ(ws2, manager.GetActiveWorkspace());
|
| +
|
| + // Activaing window w1 switches the active window and
|
| + // the mode back to normal mode.
|
| + w1->Activate();
|
| + EXPECT_EQ(ws1, manager.GetActiveWorkspace());
|
| + EXPECT_FALSE(manager.is_overview());
|
| +
|
| + // Deleting w1 without DesktopDelegate resets the active workspace
|
| + ws1->RemoveWindow(w1.get());
|
| + delete ws1;
|
| + w1.reset();
|
| + EXPECT_EQ(NULL, manager.GetActiveWorkspace());
|
| +
|
| + EXPECT_EQ("0,0 500x300", viewport()->bounds().ToString());
|
| + ws2->RemoveWindow(w2.get());
|
| + delete ws2;
|
| + // The size of viewport() for no workspace case must be
|
| + // same as one viewport() case.
|
| + EXPECT_EQ("0,0 500x300", viewport()->bounds().ToString());
|
| +}
|
| +
|
| TEST_F(WorkspaceManagerTest, WorkspaceManagerActivate) {
|
| - WorkspaceManager manager;
|
| + WorkspaceManager manager(viewport());
|
| Workspace* ws1 = manager.CreateWorkspace();
|
| Workspace* ws2 = manager.CreateWorkspace();
|
| EXPECT_EQ(NULL, manager.GetActiveWorkspace());
|
| @@ -96,7 +165,7 @@ class WorkspaceTest : public WorkspaceManagerTestBase {
|
| };
|
|
|
| TEST_F(WorkspaceTest, WorkspaceBasic) {
|
| - WorkspaceManager manager;
|
| + WorkspaceManager manager(viewport());
|
|
|
| Workspace* ws = manager.CreateWorkspace();
|
| // Sanity check
|
|
|