| Index: ash/wm/workspace/workspace_layout_manager_unittest.cc
|
| diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc
|
| index 0332c25edebce9004c34973ae22bd9f51ad2a9e1..8ee16091332a9932a92a22f6b388119c196fbc47 100644
|
| --- a/ash/wm/workspace/workspace_layout_manager_unittest.cc
|
| +++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc
|
| @@ -14,10 +14,15 @@
|
| #include "ash/common/shelf/wm_shelf.h"
|
| #include "ash/common/shell_observer.h"
|
| #include "ash/common/shell_window_ids.h"
|
| +#include "ash/common/test/ash_test.h"
|
| +#include "ash/common/wm/fullscreen_window_finder.h"
|
| #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h"
|
| #include "ash/common/wm/window_state.h"
|
| #include "ash/common/wm/wm_event.h"
|
| +#include "ash/common/wm/wm_screen_util.h"
|
| #include "ash/common/wm/workspace/workspace_window_resizer.h"
|
| +#include "ash/common/wm_lookup.h"
|
| +#include "ash/common/wm_root_window_controller.h"
|
| #include "ash/common/wm_shell.h"
|
| #include "ash/display/display_manager.h"
|
| #include "ash/root_window_controller.h"
|
| @@ -25,15 +30,12 @@
|
| #include "ash/shell.h"
|
| #include "ash/test/ash_test_base.h"
|
| #include "ash/test/display_manager_test_api.h"
|
| +#include "ash/test/test_session_state_delegate.h"
|
| #include "ash/wm/window_state_aura.h"
|
| #include "ash/wm/window_util.h"
|
| #include "base/command_line.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/run_loop.h"
|
| -#include "ui/aura/client/aura_constants.h"
|
| -#include "ui/aura/test/test_windows.h"
|
| -#include "ui/aura/window.h"
|
| -#include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/base/ui_base_switches.h"
|
| #include "ui/base/ui_base_types.h"
|
| #include "ui/display/manager/display_layout.h"
|
| @@ -96,33 +98,33 @@ class TestShellObserver : public ShellObserver {
|
|
|
| } // namespace
|
|
|
| -typedef test::AshTestBase WorkspaceLayoutManagerTest;
|
| +using WorkspaceLayoutManagerTest = AshTest;
|
|
|
| // Verifies that a window containing a restore coordinate will be restored to
|
| // to the size prior to minimize, keeping the restore rectangle in tact (if
|
| // there is one).
|
| TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window = window_owner->window();
|
| gfx::Rect bounds(10, 15, 25, 35);
|
| window->SetBounds(bounds);
|
|
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
|
|
| // This will not be used for un-minimizing window.
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
|
| window_state->Minimize();
|
| window_state->Restore();
|
| EXPECT_EQ("0,0 100x100", window_state->GetRestoreBoundsInScreen().ToString());
|
| - EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString());
|
| + EXPECT_EQ("10,15 25x35", window->GetBounds().ToString());
|
|
|
| if (!SupportsMultipleDisplays())
|
| return;
|
|
|
| UpdateDisplay("400x300,500x400");
|
| - window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
|
| - display_manager()->GetSecondaryDisplay());
|
| - EXPECT_EQ(Shell::GetAllRootWindows()[1], window->GetRootWindow());
|
| + window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), GetSecondaryDisplay());
|
| + EXPECT_EQ(WmShell::Get()->GetAllRootWindows()[1], window->GetRootWindow());
|
| window_state->Minimize();
|
| // This will not be used for un-minimizing window.
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(0, 0, 100, 100));
|
| @@ -134,9 +136,9 @@ TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
|
| window_state->Minimize();
|
| UpdateDisplay("400x300");
|
| window_state->Restore();
|
| - EXPECT_EQ(Shell::GetPrimaryRootWindow(), window->GetRootWindow());
|
| - EXPECT_TRUE(
|
| - Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
|
| + EXPECT_EQ(WmShell::Get()->GetPrimaryRootWindow(), window->GetRootWindow());
|
| + EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
|
| + window->GetBounds()));
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) {
|
| @@ -144,21 +146,23 @@ TEST_F(WorkspaceLayoutManagerTest, KeepMinimumVisibilityInDisplays) {
|
| return;
|
|
|
| UpdateDisplay("300x400,400x500");
|
| - aura::Window::Windows root_windows = Shell::GetAllRootWindows();
|
| + WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows();
|
| +
|
| + if (!SetSecondaryDisplayPlacement(display::DisplayPlacement::TOP, 0))
|
| + return;
|
|
|
| - Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
|
| - test::CreateDisplayLayout(display_manager(),
|
| - display::DisplayPlacement::TOP, 0));
|
| EXPECT_EQ("0,-500 400x500", root_windows[1]->GetBoundsInScreen().ToString());
|
|
|
| - std::unique_ptr<aura::Window> window1(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(10, -400, 200, 200)));
|
| - EXPECT_EQ("10,-400 200x200", window1->GetBoundsInScreen().ToString());
|
| + std::unique_ptr<WindowOwner> window1_owner(
|
| + CreateTestWindow(gfx::Rect(10, -400, 200, 200)));
|
| + EXPECT_EQ("10,-400 200x200",
|
| + window1_owner->window()->GetBoundsInScreen().ToString());
|
|
|
| // Make sure the caption is visible.
|
| - std::unique_ptr<aura::Window> window2(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(10, -600, 200, 200)));
|
| - EXPECT_EQ("10,-500 200x200", window2->GetBoundsInScreen().ToString());
|
| + std::unique_ptr<WindowOwner> window2_owner(
|
| + CreateTestWindow(gfx::Rect(10, -600, 200, 200)));
|
| + EXPECT_EQ("10,-500 200x200",
|
| + window2_owner->window()->GetBoundsInScreen().ToString());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) {
|
| @@ -166,49 +170,50 @@ TEST_F(WorkspaceLayoutManagerTest, NoMinimumVisibilityForPopupWindows) {
|
|
|
| // Create a popup window out of display boundaries and make sure it is not
|
| // moved to have minimum visibility.
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegateAndType(
|
| - nullptr, ui::wm::WINDOW_TYPE_POPUP, 0, gfx::Rect(400, 100, 50, 50)));
|
| - EXPECT_EQ("400,100 50x50", window->GetBoundsInScreen().ToString());
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(400, 100, 50, 50), ui::wm::WINDOW_TYPE_POPUP));
|
| + EXPECT_EQ("400,100 50x50",
|
| + window_owner->window()->GetBoundsInScreen().ToString());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerTest, KeepRestoredWindowInDisplay) {
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
|
| + WmWindow* window = window_owner->window();
|
| + wm::WindowState* window_state = window->GetWindowState();
|
|
|
| // Maximized -> Normal transition.
|
| window_state->Maximize();
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
|
| window_state->Restore();
|
| - EXPECT_TRUE(
|
| - Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
|
| + EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
|
| + window->GetBounds()));
|
| // Y bounds should not be negative.
|
| - EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
|
| + EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
|
|
|
| // Minimized -> Normal transition.
|
| window->SetBounds(gfx::Rect(-100, -100, 30, 40));
|
| window_state->Minimize();
|
| - EXPECT_FALSE(
|
| - Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
|
| - EXPECT_EQ("-100,-100 30x40", window->bounds().ToString());
|
| + EXPECT_FALSE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
|
| + window->GetBounds()));
|
| + EXPECT_EQ("-100,-100 30x40", window->GetBounds().ToString());
|
| window->Show();
|
| - EXPECT_TRUE(
|
| - Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
|
| + EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
|
| + window->GetBounds()));
|
| // Y bounds should not be negative.
|
| - EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
|
| + EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
|
|
|
| // Fullscreen -> Normal transition.
|
| window->SetBounds(gfx::Rect(0, 0, 30, 40)); // reset bounds.
|
| - ASSERT_EQ("0,0 30x40", window->bounds().ToString());
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| - EXPECT_EQ(window->bounds(), window->GetRootWindow()->bounds());
|
| + ASSERT_EQ("0,0 30x40", window->GetBounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| + EXPECT_EQ(window->GetBounds(), window->GetRootWindow()->GetBounds());
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(-100, -100, 30, 40));
|
| window_state->Restore();
|
| - EXPECT_TRUE(
|
| - Shell::GetPrimaryRootWindow()->bounds().Intersects(window->bounds()));
|
| + EXPECT_TRUE(WmShell::Get()->GetPrimaryRootWindow()->GetBounds().Intersects(
|
| + window->GetBounds()));
|
| // Y bounds should not be negative.
|
| - EXPECT_EQ("-5,0 30x40", window->bounds().ToString());
|
| + EXPECT_EQ("-5,0 30x40", window->GetBounds().ToString());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
|
| @@ -216,13 +221,14 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
|
| return;
|
| UpdateDisplay("300x400,400x500");
|
|
|
| - aura::Window::Windows root_windows = Shell::GetAllRootWindows();
|
| + WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows();
|
|
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
|
| + WmWindow* window = window_owner->window();
|
| EXPECT_EQ(root_windows[0], window->GetRootWindow());
|
|
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
|
| // Maximize the window in 2nd display as the restore bounds
|
| // is inside 2nd display.
|
| @@ -254,16 +260,21 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeInDisplayToBeRestored) {
|
| views::Widget::InitParams params;
|
| params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| params.delegate = new MaximizeDelegateView(gfx::Rect(400, 0, 30, 40));
|
| - params.context = root_windows[0];
|
| + ConfigureWidgetInitParamsForDisplay(root_windows[0], ¶ms);
|
| w1->Init(params);
|
| + WmLookup* wm_lookup = WmLookup::Get();
|
| + EXPECT_EQ(root_windows[0],
|
| + wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow());
|
| w1->Show();
|
| EXPECT_TRUE(w1->IsMaximized());
|
| - EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
|
| + EXPECT_EQ(root_windows[1],
|
| + wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow());
|
| EXPECT_EQ(
|
| gfx::Rect(300, 0, 400, 500 - GetShelfConstant(SHELF_SIZE)).ToString(),
|
| w1->GetWindowBoundsInScreen().ToString());
|
| w1->Restore();
|
| - EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
|
| + EXPECT_EQ(root_windows[1],
|
| + wm_lookup->GetWindowForWidget(w1.get())->GetRootWindow());
|
| EXPECT_EQ("400,0 30x40", w1->GetWindowBoundsInScreen().ToString());
|
| }
|
|
|
| @@ -272,17 +283,18 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
|
| return;
|
| UpdateDisplay("300x400,400x500");
|
|
|
| - aura::Window::Windows root_windows = Shell::GetAllRootWindows();
|
| + WmWindow::Windows root_windows = WmShell::Get()->GetAllRootWindows();
|
|
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
|
| + WmWindow* window = window_owner->window();
|
| EXPECT_EQ(root_windows[0], window->GetRootWindow());
|
|
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(400, 0, 30, 40));
|
| // Maximize the window in 2nd display as the restore bounds
|
| // is inside 2nd display.
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| + window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| EXPECT_EQ(root_windows[1], window->GetRootWindow());
|
| EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
|
|
|
| @@ -293,7 +305,7 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
|
| // If the restore bounds intersects with the current display,
|
| // don't move.
|
| window_state->SetRestoreBoundsInScreen(gfx::Rect(295, 0, 30, 40));
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| + window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| EXPECT_EQ(root_windows[1], window->GetRootWindow());
|
| EXPECT_EQ("300,0 400x500", window->GetBoundsInScreen().ToString());
|
|
|
| @@ -302,37 +314,36 @@ TEST_F(WorkspaceLayoutManagerTest, FullscreenInDisplayToBeRestored) {
|
| EXPECT_EQ("295,0 30x40", window->GetBoundsInScreen().ToString());
|
| }
|
|
|
| -// WindowObserver implementation used by DontClobberRestoreBoundsWindowObserver.
|
| -// This code mirrors what BrowserFrameAsh does. In particular when this code
|
| -// sees the window was maximized it changes the bounds of a secondary
|
| -// window. The secondary window mirrors the status window.
|
| -class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
|
| +// WmWindowObserver implementation used by
|
| +// DontClobberRestoreBoundsWindowObserver. This code mirrors what
|
| +// BrowserFrameAsh does. In particular when this code sees the window was
|
| +// maximized it changes the bounds of a secondary window. The secondary window
|
| +// mirrors the status window.
|
| +class DontClobberRestoreBoundsWindowObserver : public WmWindowObserver {
|
| public:
|
| DontClobberRestoreBoundsWindowObserver() : window_(nullptr) {}
|
|
|
| - void set_window(aura::Window* window) { window_ = window; }
|
| + void set_window(WmWindow* window) { window_ = window; }
|
|
|
| - // aura::WindowObserver:
|
| - void OnWindowPropertyChanged(aura::Window* window,
|
| - const void* key,
|
| - intptr_t old) override {
|
| + // WmWindowObserver:
|
| + void OnWindowPropertyChanged(WmWindow* window,
|
| + WmWindowProperty property) override {
|
| if (!window_)
|
| return;
|
|
|
| - if (wm::GetWindowState(window)->IsMaximized()) {
|
| - aura::Window* w = window_;
|
| + if (window->GetWindowState()->IsMaximized()) {
|
| + WmWindow* w = window_;
|
| window_ = nullptr;
|
|
|
| - gfx::Rect shelf_bounds(
|
| - test::AshTestBase::GetPrimaryShelf()->GetIdealBounds());
|
| - const gfx::Rect& window_bounds(w->bounds());
|
| + gfx::Rect shelf_bounds(AshTest::GetPrimaryShelf()->GetIdealBounds());
|
| + const gfx::Rect& window_bounds(w->GetBounds());
|
| w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1,
|
| window_bounds.width(), window_bounds.height()));
|
| }
|
| }
|
|
|
| private:
|
| - aura::Window* window_;
|
| + WmWindow* window_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver);
|
| };
|
| @@ -342,25 +353,26 @@ class DontClobberRestoreBoundsWindowObserver : public aura::WindowObserver {
|
| // doesn't effect the restore bounds.
|
| TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
|
| DontClobberRestoreBoundsWindowObserver window_observer;
|
| - std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
|
| - window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
|
| - window->Init(ui::LAYER_TEXTURED);
|
| + WindowOwner window_owner(WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL,
|
| + ui::LAYER_TEXTURED));
|
| + WmWindow* window = window_owner.window();
|
| window->SetBounds(gfx::Rect(10, 20, 30, 40));
|
| // NOTE: for this test to exercise the failure the observer needs to be added
|
| // before the parent set. This mimics what BrowserFrameAsh does.
|
| window->AddObserver(&window_observer);
|
| - ParentWindowInPrimaryRootWindow(window.get());
|
| + ParentWindowInPrimaryRootWindow(window);
|
| window->Show();
|
|
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| window_state->Activate();
|
|
|
| - std::unique_ptr<aura::Window> window2(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 30, 40)));
|
| - ::wm::AddTransientChild(window.get(), window2.get());
|
| + std::unique_ptr<WindowOwner> window2_owner(
|
| + CreateTestWindow(gfx::Rect(12, 20, 30, 40)));
|
| + WmWindow* window2 = window2_owner->window();
|
| + AddTransientChild(window, window2);
|
| window2->Show();
|
|
|
| - window_observer.set_window(window2.get());
|
| + window_observer.set_window(window2);
|
| window_state->Maximize();
|
| EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInScreen().ToString());
|
| window->RemoveObserver(&window_observer);
|
| @@ -368,28 +380,30 @@ TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
|
|
|
| // Verifies when a window is maximized all descendant windows have a size.
|
| TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(10, 20, 30, 40)));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(10, 20, 30, 40)));
|
| + WmWindow* window = window_owner->window();
|
| window->Show();
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| window_state->Activate();
|
| - std::unique_ptr<aura::Window> child_window(
|
| - aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8),
|
| - window.get()));
|
| - child_window->Show();
|
| + std::unique_ptr<WindowOwner> child_window_owner(
|
| + CreateChildWindow(window, gfx::Rect(5, 6, 7, 8)));
|
| + WmWindow* child_window = child_window_owner->window();
|
| window_state->Maximize();
|
| - EXPECT_EQ("5,6 7x8", child_window->bounds().ToString());
|
| + EXPECT_EQ("5,6 7x8", child_window->GetBounds().ToString());
|
| }
|
|
|
| // Verifies a window created with maximized state has the maximized
|
| // bounds.
|
| TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) {
|
| - std::unique_ptr<aura::Window> window(
|
| - aura::test::CreateTestWindowWithBounds(gfx::Rect(0, 0, 0, 0), nullptr));
|
| - wm::GetWindowState(window.get())->Maximize();
|
| - aura::Window* default_container = Shell::GetContainer(
|
| - Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer);
|
| - default_container->AddChild(window.get());
|
| + WindowOwner window_owner(WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_NORMAL,
|
| + ui::LAYER_TEXTURED));
|
| + WmWindow* window = window_owner.window();
|
| + window->GetWindowState()->Maximize();
|
| + WmWindow* default_container =
|
| + WmShell::Get()->GetPrimaryRootWindowController()->GetContainer(
|
| + kShellWindowId_DefaultContainer);
|
| + default_container->AddChild(window);
|
| window->Show();
|
| gfx::Rect work_area(
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
|
| @@ -399,33 +413,34 @@ TEST_F(WorkspaceLayoutManagerTest, MaximizeWithEmptySize) {
|
| TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
|
| // Normal window bounds shouldn't be changed.
|
| gfx::Rect window_bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(window_bounds));
|
| - EXPECT_EQ(window_bounds, window->bounds());
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds));
|
| + WmWindow* window = window_owner->window();
|
| + EXPECT_EQ(window_bounds, window->GetBounds());
|
|
|
| // If the window is out of the workspace, it would be moved on screen.
|
| gfx::Rect root_window_bounds =
|
| - Shell::GetInstance()->GetPrimaryRootWindow()->bounds();
|
| + WmShell::Get()->GetPrimaryRootWindow()->GetBounds();
|
| window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height());
|
| ASSERT_FALSE(window_bounds.Intersects(root_window_bounds));
|
| - std::unique_ptr<aura::Window> out_window(
|
| - CreateTestWindowInShellWithBounds(window_bounds));
|
| - EXPECT_EQ(window_bounds.size(), out_window->bounds().size());
|
| - gfx::Rect bounds = out_window->bounds();
|
| + std::unique_ptr<WindowOwner> out_window_owner(
|
| + CreateTestWindow(window_bounds));
|
| + WmWindow* out_window = out_window_owner->window();
|
| + EXPECT_EQ(window_bounds.size(), out_window->GetBounds().size());
|
| + gfx::Rect bounds = out_window->GetBounds();
|
| bounds.Intersect(root_window_bounds);
|
|
|
| // 30% of the window edge must be visible.
|
| - EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
|
| - EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
|
| + EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
|
| + EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
|
|
|
| - aura::Window* parent = out_window->parent();
|
| - parent->RemoveChild(out_window.get());
|
| + WmWindow* parent = out_window->GetParent();
|
| + parent->RemoveChild(out_window);
|
| out_window->SetBounds(gfx::Rect(-200, -200, 200, 200));
|
| // UserHasChangedWindowPositionOrSize flag shouldn't turn off this behavior.
|
| - wm::GetWindowState(window.get())->set_bounds_changed_by_user(true);
|
| - parent->AddChild(out_window.get());
|
| - EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
|
| - EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
|
| + window->GetWindowState()->set_bounds_changed_by_user(true);
|
| + parent->AddChild(out_window);
|
| + EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
|
| + EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
|
|
|
| // Make sure we always make more than 1/3 of the window edge visible even
|
| // if the initial bounds intersects with display.
|
| @@ -435,32 +450,35 @@ TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
|
|
|
| // Make sure that the initial bounds' visible area is less than 26%
|
| // so that the auto adjustment logic kicks in.
|
| - ASSERT_LT(bounds.width(), out_window->bounds().width() * 0.26);
|
| - ASSERT_LT(bounds.height(), out_window->bounds().height() * 0.26);
|
| + ASSERT_LT(bounds.width(), out_window->GetBounds().width() * 0.26);
|
| + ASSERT_LT(bounds.height(), out_window->GetBounds().height() * 0.26);
|
| ASSERT_TRUE(window_bounds.Intersects(root_window_bounds));
|
|
|
| - std::unique_ptr<aura::Window> partially_out_window(
|
| - CreateTestWindowInShellWithBounds(window_bounds));
|
| - EXPECT_EQ(window_bounds.size(), partially_out_window->bounds().size());
|
| - bounds = partially_out_window->bounds();
|
| + std::unique_ptr<WindowOwner> partially_out_window_owner(
|
| + CreateTestWindow(window_bounds));
|
| + WmWindow* partially_out_window = partially_out_window_owner->window();
|
| + EXPECT_EQ(window_bounds.size(), partially_out_window->GetBounds().size());
|
| + bounds = partially_out_window->GetBounds();
|
| bounds.Intersect(root_window_bounds);
|
| - EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
|
| - EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
|
| + EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
|
| + EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
|
|
|
| // Make sure the window whose 30% width/height is bigger than display
|
| // will be placed correctly.
|
| window_bounds.SetRect(-1900, -1900, 3000, 3000);
|
| - std::unique_ptr<aura::Window> window_bigger_than_display(
|
| - CreateTestWindowInShellWithBounds(window_bounds));
|
| + std::unique_ptr<WindowOwner> window_bigger_than_display_owner(
|
| + CreateTestWindow(window_bounds));
|
| + WmWindow* window_bigger_than_display =
|
| + window_bigger_than_display_owner->window();
|
| EXPECT_GE(root_window_bounds.width(),
|
| - window_bigger_than_display->bounds().width());
|
| + window_bigger_than_display->GetBounds().width());
|
| EXPECT_GE(root_window_bounds.height(),
|
| - window_bigger_than_display->bounds().height());
|
| + window_bigger_than_display->GetBounds().height());
|
|
|
| - bounds = window_bigger_than_display->bounds();
|
| + bounds = window_bigger_than_display->GetBounds();
|
| bounds.Intersect(root_window_bounds);
|
| - EXPECT_GT(bounds.width(), out_window->bounds().width() * 0.29);
|
| - EXPECT_GT(bounds.height(), out_window->bounds().height() * 0.29);
|
| + EXPECT_GT(bounds.width(), out_window->GetBounds().width() * 0.29);
|
| + EXPECT_GT(bounds.height(), out_window->GetBounds().height() * 0.29);
|
| }
|
|
|
| // Verifies the size of a window is enforced to be smaller than the work area.
|
| @@ -470,26 +488,28 @@ TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) {
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area().size());
|
| const gfx::Rect window_bounds(100, 101, work_area.width() + 1,
|
| work_area.height() + 2);
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithBounds(window_bounds));
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(window_bounds));
|
| + WmWindow* window = window_owner->window();
|
| EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
|
| - window->bounds().ToString());
|
| + window->GetBounds().ToString());
|
|
|
| // Directly setting the bounds triggers a slightly different code path. Verify
|
| // that too.
|
| window->SetBounds(window_bounds);
|
| EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
|
| - window->bounds().ToString());
|
| + window->GetBounds().ToString());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
|
| TestShellObserver observer;
|
| - std::unique_ptr<aura::Window> window1(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
|
| - std::unique_ptr<aura::Window> window2(
|
| - CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 30, 40)));
|
| - wm::WindowState* window_state1 = wm::GetWindowState(window1.get());
|
| - wm::WindowState* window_state2 = wm::GetWindowState(window2.get());
|
| + std::unique_ptr<WindowOwner> window1_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
|
| + WmWindow* window1 = window1_owner->window();
|
| + std::unique_ptr<WindowOwner> window2_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 30, 40)));
|
| + WmWindow* window2 = window2_owner->window();
|
| + wm::WindowState* window_state1 = window1->GetWindowState();
|
| + wm::WindowState* window_state2 = window2->GetWindowState();
|
| window_state2->Activate();
|
|
|
| const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
|
| @@ -516,69 +536,61 @@ TEST_F(WorkspaceLayoutManagerTest, NotifyFullscreenChanges) {
|
| EXPECT_TRUE(observer.is_fullscreen());
|
|
|
| // Closing the window should change the fullscreen state.
|
| - window2.reset();
|
| + window2_owner.reset();
|
| EXPECT_EQ(6, observer.call_count());
|
| EXPECT_FALSE(observer.is_fullscreen());
|
| }
|
|
|
| // Following "Solo" tests were originally written for BaseLayoutManager.
|
| -namespace {
|
| -
|
| -class WorkspaceLayoutManagerSoloTest : public test::AshTestBase {
|
| - public:
|
| - WorkspaceLayoutManagerSoloTest() {}
|
| - ~WorkspaceLayoutManagerSoloTest() override {}
|
| -
|
| - aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
|
| - return CreateTestWindowInShellWithBounds(bounds);
|
| - }
|
| -
|
| - private:
|
| - DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerSoloTest);
|
| -};
|
| -
|
| -} // namespace
|
| +using WorkspaceLayoutManagerSoloTest = AshTest;
|
|
|
| // Tests normal->maximize->normal.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, Maximize) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds));
|
| + WmWindow* window = window_owner->window();
|
| + window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
|
| // Maximized window fills the work area, not the whole display.
|
| - EXPECT_EQ(
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
|
| - window->bounds().ToString());
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| - EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
|
| + window->GetBounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_NORMAL);
|
| + EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| // Tests normal->minimize->normal.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, Minimize) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds));
|
| + WmWindow* window = window_owner->window();
|
| + window->SetShowState(ui::SHOW_STATE_MINIMIZED);
|
| // Note: Currently minimize doesn't do anything except set the state.
|
| // See crbug.com/104571.
|
| - EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| - EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_NORMAL);
|
| + EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| -// A WindowDelegate which sets the focus when the window
|
| -// becomes visible.
|
| -class FocusDelegate : public aura::test::TestWindowDelegate {
|
| +// A WmWindowObserver which sets the focus when the window becomes visible.
|
| +class FocusDuringUnminimizeWindowObserver : public WmWindowObserver {
|
| public:
|
| - FocusDelegate() : window_(nullptr), show_state_(ui::SHOW_STATE_END) {}
|
| - ~FocusDelegate() override {}
|
| -
|
| - void set_window(aura::Window* window) { window_ = window; }
|
| + FocusDuringUnminimizeWindowObserver()
|
| + : window_(nullptr), show_state_(ui::SHOW_STATE_END) {}
|
| + ~FocusDuringUnminimizeWindowObserver() override { SetWindow(nullptr); }
|
| +
|
| + void SetWindow(WmWindow* window) {
|
| + if (window_)
|
| + window_->RemoveObserver(this);
|
| + window_ = window;
|
| + if (window_)
|
| + window_->AddObserver(this);
|
| + }
|
|
|
| - // aura::test::TestWindowDelegate overrides:
|
| - void OnWindowTargetVisibilityChanged(bool visible) override {
|
| + // WmWindowObserver:
|
| + void OnWindowVisibilityChanged(WmWindow* window, bool visible) override {
|
| if (window_) {
|
| if (visible)
|
| - window_->Focus();
|
| - show_state_ = window_->GetProperty(aura::client::kShowStateKey);
|
| + window_->SetFocused();
|
| + show_state_ = window_->GetShowState();
|
| }
|
| }
|
|
|
| @@ -589,27 +601,28 @@ class FocusDelegate : public aura::test::TestWindowDelegate {
|
| }
|
|
|
| private:
|
| - aura::Window* window_;
|
| + WmWindow* window_;
|
| ui::WindowShowState show_state_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(FocusDelegate);
|
| + DISALLOW_COPY_AND_ASSIGN(FocusDuringUnminimizeWindowObserver);
|
| };
|
|
|
| // Make sure that the window's show state is correct in
|
| -// |WindowDelegate::OnWindowTargetVisibilityChanged|, and setting
|
| -// focus in this callback doesn't cause DCHECK error. See
|
| -// crbug.com/168383.
|
| +// WindowObserver::OnWindowTargetVisibilityChanged(), and setting focus in this
|
| +// callback doesn't cause DCHECK error. See crbug.com/168383.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) {
|
| - FocusDelegate delegate;
|
| - std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
|
| - &delegate, 0, gfx::Rect(100, 100, 100, 100)));
|
| - delegate.set_window(window.get());
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED);
|
| + FocusDuringUnminimizeWindowObserver observer;
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(100, 100, 100, 100)));
|
| + WmWindow* window = window_owner->window();
|
| + observer.SetWindow(window);
|
| + window->SetShowState(ui::SHOW_STATE_MINIMIZED);
|
| EXPECT_FALSE(window->IsVisible());
|
| - EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, delegate.GetShowStateAndReset());
|
| + EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, observer.GetShowStateAndReset());
|
| window->Show();
|
| EXPECT_TRUE(window->IsVisible());
|
| - EXPECT_EQ(ui::SHOW_STATE_NORMAL, delegate.GetShowStateAndReset());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, observer.GetShowStateAndReset());
|
| + observer.SetWindow(nullptr);
|
| }
|
|
|
| // Tests maximized window size during root window resize.
|
| @@ -621,186 +634,180 @@ TEST_F(WorkspaceLayoutManagerSoloTest, FocusDuringUnminimize) {
|
| #endif
|
| TEST_F(WorkspaceLayoutManagerSoloTest, MAYBE_MaximizeRootWindowResize) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds));
|
| + WmWindow* window = window_owner->window();
|
| + window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
|
| gfx::Rect initial_work_area_bounds =
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get());
|
| - EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString());
|
| + wm::GetMaximizedWindowBoundsInParent(window);
|
| + EXPECT_EQ(initial_work_area_bounds.ToString(),
|
| + window->GetBounds().ToString());
|
| // Enlarge the root window. We should still match the work area size.
|
| UpdateDisplay("900x700");
|
| - EXPECT_EQ(
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
|
| - window->bounds().ToString());
|
| - EXPECT_NE(
|
| - initial_work_area_bounds.ToString(),
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString());
|
| + EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
|
| + window->GetBounds().ToString());
|
| + EXPECT_NE(initial_work_area_bounds.ToString(),
|
| + wm::GetMaximizedWindowBoundsInParent(window).ToString());
|
| }
|
|
|
| // Tests normal->fullscreen->normal.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, Fullscreen) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds));
|
| + WmWindow* window = window_owner->window();
|
| + window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| // Fullscreen window fills the whole display.
|
| - EXPECT_EQ(display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .bounds()
|
| - .ToString(),
|
| - window->bounds().ToString());
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| - EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
|
| + window->GetBounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_NORMAL);
|
| + EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| // Tests that fullscreen window causes always_on_top windows to stack below.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenSuspendsAlwaysOnTop) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> fullscreen_window(CreateTestWindow(bounds));
|
| - std::unique_ptr<aura::Window> always_on_top_window1(CreateTestWindow(bounds));
|
| - std::unique_ptr<aura::Window> always_on_top_window2(CreateTestWindow(bounds));
|
| - always_on_top_window1->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| - always_on_top_window2->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| + std::unique_ptr<WindowOwner> fullscreen_window_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* fullscreen_window = fullscreen_window_owner->window();
|
| + std::unique_ptr<WindowOwner> always_on_top_window1_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window1 = always_on_top_window1_owner->window();
|
| + std::unique_ptr<WindowOwner> always_on_top_window2_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window2 = always_on_top_window2_owner->window();
|
| + always_on_top_window1->SetAlwaysOnTop(true);
|
| + always_on_top_window2->SetAlwaysOnTop(true);
|
| // Making a window fullscreen temporarily suspends always on top state.
|
| - fullscreen_window->SetProperty(aura::client::kShowStateKey,
|
| - ui::SHOW_STATE_FULLSCREEN);
|
| - EXPECT_FALSE(
|
| - always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_FALSE(
|
| - always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_NE(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow())
|
| - ->GetWindowForFullscreenMode());
|
| + fullscreen_window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| + EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop());
|
| + EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop());
|
| + EXPECT_NE(nullptr, wm::GetWindowForFullscreenMode(fullscreen_window));
|
|
|
| // Adding a new always-on-top window is not affected by fullscreen.
|
| - std::unique_ptr<aura::Window> always_on_top_window3(CreateTestWindow(bounds));
|
| - always_on_top_window3->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| - EXPECT_TRUE(
|
| - always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
|
| + std::unique_ptr<WindowOwner> always_on_top_window3_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window3 = always_on_top_window3_owner->window();
|
| + always_on_top_window3->SetAlwaysOnTop(true);
|
| + EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
|
|
|
| // Making fullscreen window normal restores always on top windows.
|
| - fullscreen_window->SetProperty(aura::client::kShowStateKey,
|
| - ui::SHOW_STATE_NORMAL);
|
| - EXPECT_TRUE(
|
| - always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_TRUE(
|
| - always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_TRUE(
|
| - always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_EQ(nullptr, GetRootWindowController(fullscreen_window->GetRootWindow())
|
| - ->GetWindowForFullscreenMode());
|
| + fullscreen_window->SetShowState(ui::SHOW_STATE_NORMAL);
|
| + EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop());
|
| + EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop());
|
| + EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
|
| + EXPECT_EQ(nullptr, wm::GetWindowForFullscreenMode(fullscreen_window));
|
| }
|
|
|
| // Similary, pinned window causes always_on_top_ windows to stack below.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, PinnedSuspendsAlwaysOnTop) {
|
| + // TODO: mash doesn't support pinning yet http://crbug.com/622486.
|
| + if (WmShell::Get()->IsRunningInMash())
|
| + return;
|
| +
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> pinned_window(CreateTestWindow(bounds));
|
| - std::unique_ptr<aura::Window> always_on_top_window1(CreateTestWindow(bounds));
|
| - std::unique_ptr<aura::Window> always_on_top_window2(CreateTestWindow(bounds));
|
| - always_on_top_window1->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| - always_on_top_window2->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| + std::unique_ptr<WindowOwner> pinned_window_owner(CreateTestWindow(bounds));
|
| + WmWindow* pinned_window = pinned_window_owner->window();
|
| + std::unique_ptr<WindowOwner> always_on_top_window1_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window1 = always_on_top_window1_owner->window();
|
| + std::unique_ptr<WindowOwner> always_on_top_window2_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window2 = always_on_top_window2_owner->window();
|
| + always_on_top_window1->SetAlwaysOnTop(true);
|
| + always_on_top_window2->SetAlwaysOnTop(true);
|
|
|
| // Making a window pinned temporarily suspends always on top state.
|
| - wm::PinWindow(pinned_window.get(), /* trusted */ false);
|
| - EXPECT_FALSE(
|
| - always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_FALSE(
|
| - always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
|
| + const bool trusted = false;
|
| + pinned_window->SetPinned(trusted);
|
| + EXPECT_FALSE(always_on_top_window1->IsAlwaysOnTop());
|
| + EXPECT_FALSE(always_on_top_window2->IsAlwaysOnTop());
|
|
|
| // Adding a new always-on-top window also is affected by pinned mode.
|
| - std::unique_ptr<aura::Window> always_on_top_window3(CreateTestWindow(bounds));
|
| - always_on_top_window3->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| - EXPECT_FALSE(
|
| - always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
|
| + std::unique_ptr<WindowOwner> always_on_top_window3_owner(
|
| + CreateTestWindow(bounds));
|
| + WmWindow* always_on_top_window3 = always_on_top_window3_owner->window();
|
| + always_on_top_window3->SetAlwaysOnTop(true);
|
| + EXPECT_FALSE(always_on_top_window3->IsAlwaysOnTop());
|
|
|
| // Making pinned window normal restores always on top windows.
|
| - WmWindowAura::Get(pinned_window.get())->GetWindowState()->Restore();
|
| - EXPECT_TRUE(
|
| - always_on_top_window1->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_TRUE(
|
| - always_on_top_window2->GetProperty(aura::client::kAlwaysOnTopKey));
|
| - EXPECT_TRUE(
|
| - always_on_top_window3->GetProperty(aura::client::kAlwaysOnTopKey));
|
| + pinned_window->GetWindowState()->Restore();
|
| + EXPECT_TRUE(always_on_top_window1->IsAlwaysOnTop());
|
| + EXPECT_TRUE(always_on_top_window2->IsAlwaysOnTop());
|
| + EXPECT_TRUE(always_on_top_window3->IsAlwaysOnTop());
|
| }
|
|
|
| // Tests fullscreen window size during root window resize.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, FullscreenRootWindowResize) {
|
| gfx::Rect bounds(100, 100, 200, 200);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(bounds));
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(bounds));
|
| + WmWindow* window = window_owner->window();
|
| // Fullscreen window fills the whole display.
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| - EXPECT_EQ(display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .bounds()
|
| - .ToString(),
|
| - window->bounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_FULLSCREEN);
|
| + EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
|
| + window->GetBounds().ToString());
|
| // Enlarge the root window. We should still match the display size.
|
| UpdateDisplay("800x600");
|
| - EXPECT_EQ(display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .bounds()
|
| - .ToString(),
|
| - window->bounds().ToString());
|
| + EXPECT_EQ(window->GetDisplayNearestWindow().bounds().ToString(),
|
| + window->GetBounds().ToString());
|
| }
|
|
|
| // Tests that when the screen gets smaller the windows aren't bigger than
|
| // the screen.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, RootWindowResizeShrinksWindows) {
|
| - std::unique_ptr<aura::Window> window(
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| CreateTestWindow(gfx::Rect(10, 20, 500, 400)));
|
| - gfx::Rect work_area = display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .work_area();
|
| + WmWindow* window = window_owner->window();
|
| + gfx::Rect work_area = window->GetDisplayNearestWindow().work_area();
|
| // Invariant: Window is smaller than work area.
|
| - EXPECT_LE(window->bounds().width(), work_area.width());
|
| - EXPECT_LE(window->bounds().height(), work_area.height());
|
| + EXPECT_LE(window->GetBounds().width(), work_area.width());
|
| + EXPECT_LE(window->GetBounds().height(), work_area.height());
|
|
|
| // Make the root window narrower than our window.
|
| UpdateDisplay("300x400");
|
| - work_area = display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .work_area();
|
| - EXPECT_LE(window->bounds().width(), work_area.width());
|
| - EXPECT_LE(window->bounds().height(), work_area.height());
|
| + work_area = window->GetDisplayNearestWindow().work_area();
|
| + EXPECT_LE(window->GetBounds().width(), work_area.width());
|
| + EXPECT_LE(window->GetBounds().height(), work_area.height());
|
|
|
| // Make the root window shorter than our window.
|
| UpdateDisplay("300x200");
|
| - work_area = display::Screen::GetScreen()
|
| - ->GetDisplayNearestWindow(window.get())
|
| - .work_area();
|
| - EXPECT_LE(window->bounds().width(), work_area.width());
|
| - EXPECT_LE(window->bounds().height(), work_area.height());
|
| + work_area = window->GetDisplayNearestWindow().work_area();
|
| + EXPECT_LE(window->GetBounds().width(), work_area.width());
|
| + EXPECT_LE(window->GetBounds().height(), work_area.height());
|
|
|
| // Enlarging the root window does not change the window bounds.
|
| - gfx::Rect old_bounds = window->bounds();
|
| + gfx::Rect old_bounds = window->GetBounds();
|
| UpdateDisplay("800x600");
|
| - EXPECT_EQ(old_bounds.width(), window->bounds().width());
|
| - EXPECT_EQ(old_bounds.height(), window->bounds().height());
|
| + EXPECT_EQ(old_bounds.width(), window->GetBounds().width());
|
| + EXPECT_EQ(old_bounds.height(), window->GetBounds().height());
|
| }
|
|
|
| // Verifies maximizing sets the restore bounds, and restoring
|
| // restores the bounds.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeSetsRestoreBounds) {
|
| - std::unique_ptr<aura::Window> window(
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| CreateTestWindow(gfx::Rect(10, 20, 30, 40)));
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + WmWindow* window = window_owner->window();
|
| + wm::WindowState* window_state = window->GetWindowState();
|
|
|
| // Maximize it, which will keep the previous restore bounds.
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
| + window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
|
| EXPECT_EQ("10,20 30x40", window_state->GetRestoreBoundsInParent().ToString());
|
|
|
| // Restore it, which should restore bounds and reset restore bounds.
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| - EXPECT_EQ("10,20 30x40", window->bounds().ToString());
|
| + window->SetShowState(ui::SHOW_STATE_NORMAL);
|
| + EXPECT_EQ("10,20 30x40", window->GetBounds().ToString());
|
| EXPECT_FALSE(window_state->HasRestoreBounds());
|
| }
|
|
|
| // Verifies maximizing keeps the restore bounds if set.
|
| TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) {
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| -
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window = window_owner->window();
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| window_state->SetRestoreBoundsInParent(gfx::Rect(10, 11, 12, 13));
|
|
|
| // Maximize it, which will keep the previous restore bounds.
|
| - window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
| + window->SetShowState(ui::SHOW_STATE_MAXIMIZED);
|
| EXPECT_EQ("10,11 12x13", window_state->GetRestoreBoundsInParent().ToString());
|
| }
|
|
|
| @@ -808,11 +815,13 @@ TEST_F(WorkspaceLayoutManagerSoloTest, MaximizeResetsRestoreBounds) {
|
| // maximzied state from a minimized state.
|
| TEST_F(WorkspaceLayoutManagerSoloTest,
|
| BoundsAfterRestoringToMaximizeFromMinimize) {
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window = window_owner->window();
|
| gfx::Rect bounds(10, 15, 25, 35);
|
| window->SetBounds(bounds);
|
|
|
| - wm::WindowState* window_state = wm::GetWindowState(window.get());
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| // Maximize it, which should reset restore bounds.
|
| window_state->Maximize();
|
| EXPECT_EQ(bounds.ToString(),
|
| @@ -830,74 +839,67 @@ TEST_F(WorkspaceLayoutManagerSoloTest,
|
| EXPECT_TRUE(window_state->IsMaximized());
|
|
|
| window_state->Restore();
|
| - EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| // Verify if the window is not resized during screen lock. See: crbug.com/173127
|
| TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
|
| - SetCanLockScreen(true);
|
| - std::unique_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + test::TestSessionStateDelegate::SetCanLockScreen(true);
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window = window_owner->window();
|
| // window with AlwaysOnTop will be managed by BaseLayoutManager.
|
| - window->SetProperty(aura::client::kAlwaysOnTopKey, true);
|
| + window->SetAlwaysOnTop(true);
|
| window->Show();
|
|
|
| WmShelf* shelf = GetPrimaryShelf();
|
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
|
|
|
| - window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()));
|
| - gfx::Rect window_bounds = window->bounds();
|
| - EXPECT_EQ(
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
|
| - window_bounds.ToString());
|
| + window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window));
|
| + gfx::Rect window_bounds = window->GetBounds();
|
| + EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
|
| + window_bounds.ToString());
|
|
|
| // The window size should not get touched while we are in lock screen.
|
| WmShell::Get()->GetSessionStateDelegate()->LockScreen();
|
| ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager();
|
| shelf_layout_manager->UpdateVisibilityState();
|
| - EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
|
|
|
| // Coming out of the lock screen the window size should still remain.
|
| WmShell::Get()->GetSessionStateDelegate()->UnlockScreen();
|
| shelf_layout_manager->UpdateVisibilityState();
|
| - EXPECT_EQ(
|
| - ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
|
| - window_bounds.ToString());
|
| - EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
|
| + window_bounds.ToString());
|
| + EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| // Following tests are written to test the backdrop functionality.
|
|
|
| namespace {
|
|
|
| -WorkspaceLayoutManager* GetWorkspaceLayoutManager(aura::Window* container) {
|
| - return static_cast<WorkspaceLayoutManager*>(
|
| - WmWindowAura::Get(container)->GetLayoutManager());
|
| +WorkspaceLayoutManager* GetWorkspaceLayoutManager(WmWindow* container) {
|
| + return static_cast<WorkspaceLayoutManager*>(container->GetLayoutManager());
|
| }
|
|
|
| -class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
|
| +class WorkspaceLayoutManagerBackdropTest : public AshTest {
|
| public:
|
| WorkspaceLayoutManagerBackdropTest() : default_container_(nullptr) {}
|
| ~WorkspaceLayoutManagerBackdropTest() override {}
|
|
|
| void SetUp() override {
|
| - test::AshTestBase::SetUp();
|
| + AshTest::SetUp();
|
| UpdateDisplay("800x600");
|
| - default_container_ = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
|
| - kShellWindowId_DefaultContainer);
|
| - }
|
| -
|
| - aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
|
| - aura::Window* window = CreateTestWindowInShellWithBounds(bounds);
|
| - return window;
|
| + default_container_ =
|
| + WmShell::Get()->GetPrimaryRootWindowController()->GetContainer(
|
| + kShellWindowId_DefaultContainer);
|
| }
|
|
|
| // Turn the top window back drop on / off.
|
| void ShowTopWindowBackdrop(bool show) {
|
| std::unique_ptr<WorkspaceLayoutManagerBackdropDelegate> backdrop;
|
| - if (show) {
|
| - backdrop.reset(new WorkspaceBackdropDelegate(
|
| - WmWindowAura::Get(default_container_)));
|
| - }
|
| + if (show)
|
| + backdrop.reset(new WorkspaceBackdropDelegate(default_container_));
|
| GetWorkspaceLayoutManager(default_container_)
|
| ->SetMaximizeBackdropDelegate(std::move(backdrop));
|
| // Closing and / or opening can be a delayed operation.
|
| @@ -905,29 +907,29 @@ class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
|
| }
|
|
|
| // Return the default container.
|
| - aura::Window* default_container() { return default_container_; }
|
| + WmWindow* default_container() { return default_container_; }
|
|
|
| // Return the order of windows (top most first) as they are in the default
|
| // container. If the window is visible it will be a big letter, otherwise a
|
| // small one. The backdrop will be an X and unknown windows will be shown as
|
| // '!'.
|
| - std::string GetWindowOrderAsString(aura::Window* backdrop,
|
| - aura::Window* wa,
|
| - aura::Window* wb,
|
| - aura::Window* wc) {
|
| + std::string GetWindowOrderAsString(WmWindow* backdrop,
|
| + WmWindow* wa,
|
| + WmWindow* wb,
|
| + WmWindow* wc) {
|
| std::string result;
|
| - for (int i = static_cast<int>(default_container()->children().size()) - 1;
|
| - i >= 0; --i) {
|
| + WmWindow::Windows children = default_container()->GetChildren();
|
| + for (int i = static_cast<int>(children.size()) - 1; i >= 0; --i) {
|
| if (!result.empty())
|
| result += ",";
|
| - if (default_container()->children()[i] == wa)
|
| - result += default_container()->children()[i]->IsVisible() ? "A" : "a";
|
| - else if (default_container()->children()[i] == wb)
|
| - result += default_container()->children()[i]->IsVisible() ? "B" : "b";
|
| - else if (default_container()->children()[i] == wc)
|
| - result += default_container()->children()[i]->IsVisible() ? "C" : "c";
|
| - else if (default_container()->children()[i] == backdrop)
|
| - result += default_container()->children()[i]->IsVisible() ? "X" : "x";
|
| + if (children[i] == wa)
|
| + result += children[i]->IsVisible() ? "A" : "a";
|
| + else if (children[i] == wb)
|
| + result += children[i]->IsVisible() ? "B" : "b";
|
| + else if (children[i] == wc)
|
| + result += children[i]->IsVisible() ? "C" : "c";
|
| + else if (children[i] == backdrop)
|
| + result += children[i]->IsVisible() ? "X" : "x";
|
| else
|
| result += "!";
|
| }
|
| @@ -936,7 +938,7 @@ class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
|
|
|
| private:
|
| // The default container.
|
| - aura::Window* default_container_;
|
| + WmWindow* default_container_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerBackdropTest);
|
| };
|
| @@ -946,103 +948,120 @@ class WorkspaceLayoutManagerBackdropTest : public test::AshTestBase {
|
| // Check that creating the BackDrop without destroying it does not lead into
|
| // a crash.
|
| TEST_F(WorkspaceLayoutManagerBackdropTest, BackdropCrashTest) {
|
| + // TODO: Triggers crash in mash: http://crbug.com/652871.
|
| + if (WmShell::Get()->IsRunningInMash())
|
| + return;
|
| +
|
| ShowTopWindowBackdrop(true);
|
| }
|
|
|
| // Verify basic assumptions about the backdrop.
|
| TEST_F(WorkspaceLayoutManagerBackdropTest, BasicBackdropTests) {
|
| + // TODO: Triggers crash in mash: http://crbug.com/652871.
|
| + if (WmShell::Get()->IsRunningInMash())
|
| + return;
|
| +
|
| // Create a backdrop and see that there is one window (the backdrop) and
|
| // that the size is the same as the default container as well as that it is
|
| // not visible.
|
| ShowTopWindowBackdrop(true);
|
| - ASSERT_EQ(1U, default_container()->children().size());
|
| - EXPECT_FALSE(default_container()->children()[0]->IsVisible());
|
| + ASSERT_EQ(1U, default_container()->GetChildren().size());
|
| + EXPECT_FALSE(default_container()->GetChildren()[0]->IsVisible());
|
|
|
| {
|
| // Add a window and make sure that the backdrop is the second child.
|
| - std::unique_ptr<aura::Window> window(
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window = window_owner->window();
|
| window->Show();
|
| - ASSERT_EQ(2U, default_container()->children().size());
|
| - EXPECT_TRUE(default_container()->children()[0]->IsVisible());
|
| - EXPECT_TRUE(default_container()->children()[1]->IsVisible());
|
| - EXPECT_EQ(window.get(), default_container()->children()[1]);
|
| - EXPECT_EQ(default_container()->bounds().ToString(),
|
| - default_container()->children()[0]->bounds().ToString());
|
| + ASSERT_EQ(2U, default_container()->GetChildren().size());
|
| + EXPECT_TRUE(default_container()->GetChildren()[0]->IsVisible());
|
| + EXPECT_TRUE(default_container()->GetChildren()[1]->IsVisible());
|
| + EXPECT_EQ(window, default_container()->GetChildren()[1]);
|
| + EXPECT_EQ(default_container()->GetBounds().ToString(),
|
| + default_container()->GetChildren()[0]->GetBounds().ToString());
|
| }
|
|
|
| // With the window gone the backdrop should be invisible again.
|
| - ASSERT_EQ(1U, default_container()->children().size());
|
| - EXPECT_FALSE(default_container()->children()[0]->IsVisible());
|
| + ASSERT_EQ(1U, default_container()->GetChildren().size());
|
| + EXPECT_FALSE(default_container()->GetChildren()[0]->IsVisible());
|
|
|
| // Destroying the Backdrop should empty the container.
|
| ShowTopWindowBackdrop(false);
|
| - ASSERT_EQ(0U, default_container()->children().size());
|
| + ASSERT_EQ(0U, default_container()->GetChildren().size());
|
| }
|
|
|
| // Verify that the backdrop gets properly created and placed.
|
| TEST_F(WorkspaceLayoutManagerBackdropTest, VerifyBackdropAndItsStacking) {
|
| - std::unique_ptr<aura::Window> window1(
|
| + // TODO: Triggers crash in mash: http://crbug.com/652871.
|
| + if (WmShell::Get()->IsRunningInMash())
|
| + return;
|
| +
|
| + std::unique_ptr<WindowOwner> window1_owner(
|
| CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
|
| + WmWindow* window1 = window1_owner->window();
|
| window1->Show();
|
|
|
| // Get the default container and check that only a single window is in there.
|
| - ASSERT_EQ(1U, default_container()->children().size());
|
| - EXPECT_EQ(window1.get(), default_container()->children()[0]);
|
| - EXPECT_EQ("A",
|
| - GetWindowOrderAsString(nullptr, window1.get(), nullptr, nullptr));
|
| + ASSERT_EQ(1U, default_container()->GetChildren().size());
|
| + EXPECT_EQ(window1, default_container()->GetChildren()[0]);
|
| + EXPECT_EQ("A", GetWindowOrderAsString(nullptr, window1, nullptr, nullptr));
|
|
|
| // Create 2 more windows and check that they are also in the container.
|
| - std::unique_ptr<aura::Window> window2(
|
| + std::unique_ptr<WindowOwner> window2_owner(
|
| CreateTestWindow(gfx::Rect(10, 2, 3, 4)));
|
| - std::unique_ptr<aura::Window> window3(
|
| + WmWindow* window2 = window2_owner->window();
|
| + std::unique_ptr<WindowOwner> window3_owner(
|
| CreateTestWindow(gfx::Rect(20, 2, 3, 4)));
|
| + WmWindow* window3 = window3_owner->window();
|
| window2->Show();
|
| window3->Show();
|
|
|
| - aura::Window* backdrop = nullptr;
|
| - EXPECT_EQ("C,B,A", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| + WmWindow* backdrop = nullptr;
|
| + EXPECT_EQ("C,B,A",
|
| + GetWindowOrderAsString(backdrop, window1, window2, window3));
|
|
|
| // Turn on the backdrop mode and check that the window shows up where it
|
| // should be (second highest number).
|
| ShowTopWindowBackdrop(true);
|
| - backdrop = default_container()->children()[2];
|
| - EXPECT_EQ("C,X,B,A", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| + backdrop = default_container()->GetChildren()[2];
|
| + EXPECT_EQ("C,X,B,A",
|
| + GetWindowOrderAsString(backdrop, window1, window2, window3));
|
|
|
| // Switch the order of windows and check that it still remains in that
|
| // location.
|
| - default_container()->StackChildAtTop(window2.get());
|
| - EXPECT_EQ("B,X,C,A", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| + default_container()->StackChildAtTop(window2);
|
| + EXPECT_EQ("B,X,C,A",
|
| + GetWindowOrderAsString(backdrop, window1, window2, window3));
|
|
|
| // Make the top window invisible and check.
|
| - window2.get()->Hide();
|
| - EXPECT_EQ("b,C,X,A", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| + window2->Hide();
|
| + EXPECT_EQ("b,C,X,A",
|
| + GetWindowOrderAsString(backdrop, window1, window2, window3));
|
| // Then delete window after window and see that everything is in order.
|
| - window1.reset();
|
| - EXPECT_EQ("b,C,X", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| - window3.reset();
|
| - EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1.get(),
|
| - window2.get(), window3.get()));
|
| + window1_owner.reset();
|
| + EXPECT_EQ("b,C,X",
|
| + GetWindowOrderAsString(backdrop, window1, window2, window3));
|
| + window3_owner.reset();
|
| + EXPECT_EQ("b,x", GetWindowOrderAsString(backdrop, window1, window2, window3));
|
| ShowTopWindowBackdrop(false);
|
| - EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(),
|
| - window3.get()));
|
| + EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1, window2, window3));
|
| }
|
|
|
| // Tests that when hidding the shelf, that the backdrop resizes to fill the
|
| // entire workspace area.
|
| TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) {
|
| + // TODO: Triggers crash in mash: http://crbug.com/652871.
|
| + if (WmShell::Get()->IsRunningInMash())
|
| + return;
|
| +
|
| WmShelf* shelf = GetPrimaryShelf();
|
| ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager();
|
| ShowTopWindowBackdrop(true);
|
| RunAllPendingInMessageLoop();
|
|
|
| ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
|
| - gfx::Rect initial_bounds = default_container()->children()[0]->bounds();
|
| + gfx::Rect initial_bounds = default_container()->GetChildren()[0]->GetBounds();
|
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
|
| shelf_layout_manager->UpdateVisibilityState();
|
|
|
| @@ -1050,45 +1069,42 @@ TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) {
|
| // including the backdrop.
|
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
|
| shelf_layout_manager->UpdateVisibilityState();
|
| - gfx::Rect reduced_bounds = default_container()->children()[0]->bounds();
|
| + gfx::Rect reduced_bounds = default_container()->GetChildren()[0]->GetBounds();
|
| EXPECT_LT(reduced_bounds.height(), initial_bounds.height());
|
|
|
| shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
|
| shelf_layout_manager->UpdateVisibilityState();
|
|
|
| - EXPECT_GT(default_container()->children()[0]->bounds().height(),
|
| + EXPECT_GT(default_container()->GetChildren()[0]->GetBounds().height(),
|
| reduced_bounds.height());
|
| }
|
|
|
| -class WorkspaceLayoutManagerKeyboardTest : public test::AshTestBase {
|
| +class WorkspaceLayoutManagerKeyboardTest : public AshTest {
|
| public:
|
| WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {}
|
| ~WorkspaceLayoutManagerKeyboardTest() override {}
|
|
|
| void SetUp() override {
|
| - test::AshTestBase::SetUp();
|
| + AshTest::SetUp();
|
| UpdateDisplay("800x600");
|
| - aura::Window* default_container = Shell::GetContainer(
|
| - Shell::GetPrimaryRootWindow(), kShellWindowId_DefaultContainer);
|
| + WmWindow* default_container =
|
| + WmShell::Get()->GetPrimaryRootWindowController()->GetContainer(
|
| + kShellWindowId_DefaultContainer);
|
| layout_manager_ = GetWorkspaceLayoutManager(default_container);
|
| }
|
|
|
| - aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
|
| - return CreateTestWindowInShellWithBounds(bounds);
|
| - }
|
| -
|
| void ShowKeyboard() {
|
| layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
|
| restore_work_area_insets_ =
|
| display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets();
|
| - Shell::GetInstance()->SetDisplayWorkAreaInsets(
|
| - Shell::GetPrimaryRootWindow(),
|
| + WmShell::Get()->SetDisplayWorkAreaInsets(
|
| + WmShell::Get()->GetPrimaryRootWindow(),
|
| gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
|
| }
|
|
|
| void HideKeyboard() {
|
| - Shell::GetInstance()->SetDisplayWorkAreaInsets(
|
| - Shell::GetPrimaryRootWindow(), restore_work_area_insets_);
|
| + WmShell::Get()->SetDisplayWorkAreaInsets(
|
| + WmShell::Get()->GetPrimaryRootWindow(), restore_work_area_insets_);
|
| layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
|
| }
|
|
|
| @@ -1125,15 +1141,14 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
|
| gfx::Rect work_area(
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
|
|
|
| - aura::test::TestWindowDelegate delegate1;
|
| - std::unique_ptr<aura::Window> parent_window(
|
| - CreateTestWindowInShellWithDelegate(&delegate1, -1, work_area));
|
| - aura::test::TestWindowDelegate delegate2;
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegate(&delegate2, -1, work_area));
|
| - parent_window->AddChild(window.get());
|
| + std::unique_ptr<WindowOwner> parent_window_owner(
|
| + CreateToplevelTestWindow(work_area));
|
| + WmWindow* parent_window = parent_window_owner->window();
|
| + std::unique_ptr<WindowOwner> window_owner(CreateTestWindow(work_area));
|
| + WmWindow* window = window_owner->window();
|
| + parent_window->AddChild(window);
|
|
|
| - wm::ActivateWindow(window.get());
|
| + window->Activate();
|
|
|
| int available_height =
|
| display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() -
|
| @@ -1142,13 +1157,13 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) {
|
| gfx::Rect initial_window_bounds(50, 50, 100, 500);
|
| parent_window->SetBounds(initial_window_bounds);
|
| EXPECT_EQ(initial_window_bounds.ToString(),
|
| - parent_window->bounds().ToString());
|
| + parent_window->GetBounds().ToString());
|
| ShowKeyboard();
|
| EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
|
| - parent_window->bounds().ToString());
|
| + parent_window->GetBounds().ToString());
|
| HideKeyboard();
|
| EXPECT_EQ(initial_window_bounds.ToString(),
|
| - parent_window->bounds().ToString());
|
| + parent_window->GetBounds().ToString());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
|
| @@ -1156,33 +1171,33 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
|
| gfx::Rect work_area(
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
|
|
|
| - aura::test::TestWindowDelegate delegate;
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegate(&delegate, -1, work_area));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateToplevelTestWindow(work_area));
|
| + WmWindow* window = window_owner->window();
|
|
|
| int available_height =
|
| display::Screen::GetScreen()->GetPrimaryDisplay().bounds().height() -
|
| keyboard_bounds().height();
|
|
|
| - wm::ActivateWindow(window.get());
|
| + window->Activate();
|
|
|
| - EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(gfx::Rect(work_area).ToString(), window->GetBounds().ToString());
|
| ShowKeyboard();
|
| EXPECT_EQ(gfx::Rect(work_area.origin(),
|
| gfx::Size(work_area.width(), available_height))
|
| .ToString(),
|
| - window->bounds().ToString());
|
| + window->GetBounds().ToString());
|
| HideKeyboard();
|
| - EXPECT_EQ(gfx::Rect(work_area).ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(gfx::Rect(work_area).ToString(), window->GetBounds().ToString());
|
|
|
| gfx::Rect small_window_bound(50, 50, 100, 500);
|
| window->SetBounds(small_window_bound);
|
| - EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(small_window_bound.ToString(), window->GetBounds().ToString());
|
| ShowKeyboard();
|
| EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(),
|
| - window->bounds().ToString());
|
| + window->GetBounds().ToString());
|
| HideKeyboard();
|
| - EXPECT_EQ(small_window_bound.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(small_window_bound.ToString(), window->GetBounds().ToString());
|
|
|
| gfx::Rect occluded_window_bounds(
|
| 50, keyboard_bounds().y() + keyboard_bounds().height() / 2, 50,
|
| @@ -1195,23 +1210,23 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) {
|
| gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2,
|
| occluded_window_bounds.width(), occluded_window_bounds.height())
|
| .ToString(),
|
| - window->bounds().ToString());
|
| + window->GetBounds().ToString());
|
| HideKeyboard();
|
| - EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
|
| + EXPECT_EQ(occluded_window_bounds.ToString(), window->GetBounds().ToString());
|
| }
|
|
|
| -TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChagne) {
|
| +TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) {
|
| InitKeyboardBounds();
|
|
|
| - aura::test::TestWindowDelegate delegate2;
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegate(&delegate2, -1, keyboard_bounds()));
|
| - wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true);
|
| - wm::ActivateWindow(window.get());
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateTestWindow(keyboard_bounds()));
|
| + WmWindow* window = window_owner->window();
|
| + window->GetWindowState()->set_ignore_keyboard_bounds_change(true);
|
| + window->Activate();
|
|
|
| - EXPECT_EQ(keyboard_bounds(), window->bounds());
|
| + EXPECT_EQ(keyboard_bounds(), window->GetBounds());
|
| ShowKeyboard();
|
| - EXPECT_EQ(keyboard_bounds(), window->bounds());
|
| + EXPECT_EQ(keyboard_bounds(), window->GetBounds());
|
| }
|
|
|
| TEST_F(WorkspaceLayoutManagerKeyboardTest, ChangeWorkAreaInNonStickyMode) {
|
| @@ -1224,41 +1239,41 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest, ChangeWorkAreaInNonStickyMode) {
|
| gfx::Rect work_area(
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
|
|
|
| - aura::test::TestWindowDelegate delegate;
|
| gfx::Rect orig_window_bounds(0, 100, work_area.width(),
|
| work_area.height() - 100);
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegate(&delegate, -1, orig_window_bounds));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateToplevelTestWindow(orig_window_bounds));
|
| + WmWindow* window = window_owner->window();
|
|
|
| - wm::ActivateWindow(window.get());
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + window->Activate();
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
|
|
| // Open keyboard in non-sticky mode.
|
| kb_controller->ShowKeyboard(false);
|
| kb_controller->ui()->GetKeyboardWindow()->SetBounds(
|
| keyboard::FullWidthKeyboardBoundsFromRootBounds(
|
| - Shell::GetPrimaryRootWindow()->bounds(), 100));
|
| + WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
|
|
|
| int shift =
|
| work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
|
| gfx::Rect changed_window_bounds(orig_window_bounds);
|
| changed_window_bounds.Offset(0, -shift);
|
| // Window should be shifted up.
|
| - EXPECT_EQ(changed_window_bounds, window->bounds());
|
| + EXPECT_EQ(changed_window_bounds, window->GetBounds());
|
|
|
| kb_controller->HideKeyboard(
|
| keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
|
|
| // Open keyboard in sticky mode.
|
| kb_controller->ShowKeyboard(true);
|
|
|
| // Window should be shifted up.
|
| - EXPECT_EQ(changed_window_bounds, window->bounds());
|
| + EXPECT_EQ(changed_window_bounds, window->GetBounds());
|
|
|
| kb_controller->HideKeyboard(
|
| keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
| }
|
|
|
| // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility
|
| @@ -1277,27 +1292,27 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest,
|
| gfx::Rect work_area(
|
| display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
|
|
|
| - aura::test::TestWindowDelegate delegate;
|
| gfx::Rect orig_window_bounds(0, 100, work_area.width(),
|
| work_area.height() - 100);
|
| - std::unique_ptr<aura::Window> window(
|
| - CreateTestWindowInShellWithDelegate(&delegate, -1, orig_window_bounds));
|
| + std::unique_ptr<WindowOwner> window_owner(
|
| + CreateToplevelTestWindow(orig_window_bounds));
|
| + WmWindow* window = window_owner->window();
|
|
|
| - wm::ActivateWindow(window.get());
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + window->Activate();
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
|
|
| // Open keyboard in non-sticky mode.
|
| kb_controller->ShowKeyboard(false);
|
| kb_controller->ui()->GetKeyboardWindow()->SetBounds(
|
| keyboard::FullWidthKeyboardBoundsFromRootBounds(
|
| - Shell::GetPrimaryRootWindow()->bounds(), 100));
|
| + WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
|
|
|
| // Window should not be shifted up.
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
|
|
| kb_controller->HideKeyboard(
|
| keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
|
|
| // Open keyboard in sticky mode.
|
| kb_controller->ShowKeyboard(true);
|
| @@ -1307,11 +1322,11 @@ TEST_F(WorkspaceLayoutManagerKeyboardTest,
|
| gfx::Rect changed_window_bounds(orig_window_bounds);
|
| changed_window_bounds.Offset(0, -shift);
|
| // Window should be shifted up.
|
| - EXPECT_EQ(changed_window_bounds, window->bounds());
|
| + EXPECT_EQ(changed_window_bounds, window->GetBounds());
|
|
|
| kb_controller->HideKeyboard(
|
| keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
|
| - EXPECT_EQ(orig_window_bounds, window->bounds());
|
| + EXPECT_EQ(orig_window_bounds, window->GetBounds());
|
| }
|
|
|
| } // namespace ash
|
|
|