| Index: ui/aura_shell/default_container_layout_manager_unittest.cc
|
| diff --git a/ui/aura_shell/default_container_layout_manager_unittest.cc b/ui/aura_shell/default_container_layout_manager_unittest.cc
|
| index f96ea3f065d24e25c9bd629108238cf88f591d8a..765d167b222cdbc3316472e928dea04fb826e091 100644
|
| --- a/ui/aura_shell/default_container_layout_manager_unittest.cc
|
| +++ b/ui/aura_shell/default_container_layout_manager_unittest.cc
|
| @@ -7,11 +7,15 @@
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/scoped_vector.h"
|
| -#include "ui/aura/test/aura_test_base.h"
|
| +#include "ui/aura/aura_constants.h"
|
| #include "ui/aura/desktop.h"
|
| #include "ui/aura/screen_aura.h"
|
| +#include "ui/aura/test/aura_test_base.h"
|
| #include "ui/aura/window.h"
|
| +#include "ui/aura_shell/workspace/workspace.h"
|
| #include "ui/aura_shell/workspace/workspace_controller.h"
|
| +#include "ui/aura_shell/workspace/workspace_manager.h"
|
| +#include "ui/base/ui_base_types.h"
|
| #include "views/widget/native_widget_aura.h"
|
|
|
| namespace aura_shell {
|
| @@ -64,6 +68,11 @@ class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase {
|
| }
|
|
|
| protected:
|
| + aura_shell::internal::WorkspaceManager* workspace_manager() {
|
| + return workspace_controller_->layout_manager()->workspace_manager();
|
| + }
|
| +
|
| + private:
|
| scoped_ptr<aura::Window> container_;
|
| scoped_ptr<aura_shell::internal::WorkspaceController> workspace_controller_;
|
|
|
| @@ -71,6 +80,24 @@ class DefaultContainerLayoutManagerTest : public aura::test::AuraTestBase {
|
| DISALLOW_COPY_AND_ASSIGN(DefaultContainerLayoutManagerTest);
|
| };
|
|
|
| +// Utility functions to set and get show state on |window|.
|
| +void Maximize(aura::Window* window) {
|
| + window->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
|
| +}
|
| +
|
| +void Fullscreen(aura::Window* window) {
|
| + window->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
|
| +}
|
| +
|
| +void Restore(aura::Window* window) {
|
| + window->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| +}
|
| +
|
| +ui::WindowShowState GetShowState(aura::Window* window) {
|
| + return static_cast<ui::WindowShowState>(
|
| + window->GetIntProperty(aura::kShowStateKey));
|
| +}
|
| +
|
| } // namespace
|
|
|
| #if !defined(OS_WIN)
|
| @@ -146,5 +173,167 @@ TEST_F(DefaultContainerLayoutManagerTest, IgnoreTransient) {
|
| EXPECT_EQ("0,0 200x200", window->bounds().ToString());
|
| }
|
|
|
| +TEST_F(DefaultContainerLayoutManagerTest, Fullscreen) {
|
| + scoped_ptr<aura::Window> w(
|
| + CreateTestWindow(gfx::Rect(0, 0, 100, 100), container()));
|
| + gfx::Rect fullscreen_bounds =
|
| + workspace_manager()->FindBy(w.get())->bounds();
|
| + gfx::Rect original_bounds = w->GetTargetBounds();
|
| +
|
| + // Restoreing the restored window.
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + // Fullscreen
|
| + Fullscreen(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetShowState(w.get()));
|
| + EXPECT_EQ(fullscreen_bounds.ToString(), w->bounds().ToString());
|
| + w->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL);
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + Fullscreen(w.get());
|
| + // Setting |ui::SHOW_STATE_FULLSCREEN| should have no additional effect.
|
| + Fullscreen(w.get());
|
| + EXPECT_EQ(fullscreen_bounds, w->bounds());
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + // Calling SetBounds() in fullscreen mode should only update the
|
| + // restore bounds not change the bounds of the window.
|
| + gfx::Rect new_bounds(50, 50, 50, 50);
|
| + Fullscreen(w.get());
|
| + w->SetBounds(new_bounds);
|
| + EXPECT_EQ(fullscreen_bounds.ToString(), w->bounds().ToString());
|
| + EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetShowState(w.get()));
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(50, w->bounds().height());
|
| +}
|
| +
|
| +TEST_F(DefaultContainerLayoutManagerTest, Maximized) {
|
| + scoped_ptr<aura::Window> w(
|
| + CreateTestWindow(gfx::Rect(0, 0, 100, 100), container()));
|
| + gfx::Rect original_bounds = w->GetTargetBounds();
|
| + gfx::Rect fullscreen_bounds =
|
| + workspace_manager()->FindBy(w.get())->bounds();
|
| + gfx::Rect work_area_bounds =
|
| + workspace_manager()->FindBy(w.get())->GetWorkAreaBounds();
|
| +
|
| + // Maximized
|
| + Maximize(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetShowState(w.get()));
|
| + EXPECT_EQ(work_area_bounds.ToString(), w->bounds().ToString());
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + // Maximize twice
|
| + Maximize(w.get());
|
| + Maximize(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetShowState(w.get()));
|
| + EXPECT_EQ(work_area_bounds.ToString(), w->bounds().ToString());
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + // Maximized -> Fullscreen -> Maximized -> Normal
|
| + Maximize(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetShowState(w.get()));
|
| + EXPECT_EQ(work_area_bounds.ToString(), w->bounds().ToString());
|
| + Fullscreen(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetShowState(w.get()));
|
| + EXPECT_EQ(fullscreen_bounds.ToString(), w->bounds().ToString());
|
| + Maximize(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetShowState(w.get()));
|
| + EXPECT_EQ(work_area_bounds.ToString(), w->bounds().ToString());
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(original_bounds.ToString(), w->bounds().ToString());
|
| +
|
| + // Calling SetBounds() in maximized mode mode should only update the
|
| + // restore bounds not change the bounds of the window.
|
| + gfx::Rect new_bounds(50, 50, 50, 50);
|
| + Maximize(w.get());
|
| + w->SetBounds(new_bounds);
|
| + EXPECT_EQ(work_area_bounds.ToString(), w->bounds().ToString());
|
| + Restore(w.get());
|
| + EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetShowState(w.get()));
|
| + EXPECT_EQ(50, w->bounds().height());
|
| +}
|
| +
|
| +// Tests that fullscreen windows get resized after desktop is resized.
|
| +TEST_F(DefaultContainerLayoutManagerTest, FullscreenAfterDesktopResize) {
|
| + scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(300, 400),
|
| + container()));
|
| + gfx::Rect window_bounds = w1->GetTargetBounds();
|
| + gfx::Rect fullscreen_bounds =
|
| + workspace_manager()->FindBy(w1.get())->bounds();
|
| +
|
| + w1->Show();
|
| + EXPECT_EQ(window_bounds.ToString(), w1->bounds().ToString());
|
| +
|
| + Fullscreen(w1.get());
|
| + EXPECT_EQ(fullscreen_bounds.ToString(), w1->bounds().ToString());
|
| +
|
| + // Resize the desktop.
|
| + aura::Desktop* desktop = aura::Desktop::GetInstance();
|
| + gfx::Size new_desktop_size = desktop->GetHostSize();
|
| + new_desktop_size.Enlarge(100, 200);
|
| + desktop->OnHostResized(new_desktop_size);
|
| +
|
| + gfx::Rect new_fullscreen_bounds =
|
| + workspace_manager()->FindBy(w1.get())->bounds();
|
| + EXPECT_NE(fullscreen_bounds.size().ToString(),
|
| + new_fullscreen_bounds.size().ToString());
|
| +
|
| + EXPECT_EQ(new_fullscreen_bounds.ToString(),
|
| + w1->GetTargetBounds().ToString());
|
| +
|
| + Restore(w1.get());
|
| +
|
| + // The following test does not pass due to crbug.com/102413.
|
| + // TODO(oshima): Re-enable this once the bug is fixed.
|
| + // EXPECT_EQ(window_bounds.size().ToString(),
|
| + // w1->GetTargetBounds().size().ToString());
|
| +}
|
| +
|
| +// Tests that maximized windows get resized after desktop is resized.
|
| +TEST_F(DefaultContainerLayoutManagerTest, MaximizeAfterDesktopResize) {
|
| + scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(300, 400),
|
| + container()));
|
| + gfx::Rect window_bounds = w1->GetTargetBounds();
|
| + gfx::Rect work_area_bounds =
|
| + workspace_manager()->FindBy(w1.get())->GetWorkAreaBounds();
|
| +
|
| + w1->Show();
|
| + EXPECT_EQ(window_bounds.ToString(), w1->bounds().ToString());
|
| +
|
| + Maximize(w1.get());
|
| + EXPECT_EQ(work_area_bounds.ToString(), w1->bounds().ToString());
|
| +
|
| + // Resize the desktop.
|
| + aura::Desktop* desktop = aura::Desktop::GetInstance();
|
| + gfx::Size new_desktop_size = desktop->GetHostSize();
|
| + new_desktop_size.Enlarge(100, 200);
|
| + desktop->OnHostResized(new_desktop_size);
|
| +
|
| + gfx::Rect new_work_area_bounds =
|
| + workspace_manager()->FindBy(w1.get())->bounds();
|
| + EXPECT_NE(work_area_bounds.size().ToString(),
|
| + new_work_area_bounds.size().ToString());
|
| +
|
| + EXPECT_EQ(new_work_area_bounds.ToString(),
|
| + w1->GetTargetBounds().ToString());
|
| +
|
| + Restore(w1.get());
|
| + // The following test does not pass due to crbug.com/102413.
|
| + // TODO(oshima): Re-enable this once the bug is fixed.
|
| + // EXPECT_EQ(window_bounds.size().ToString(),
|
| + // w1->GetTargetBounds().size().ToString());
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace aura_shell
|
|
|