This source file includes following definitions.
- CreateNonMaximizableWindow
- CreateWindow
- CreateMaximizeModeWindowManager
- DestroyMaximizeModeWindowManager
- maximize_mode_window_manager
- ResizeDesktop
- CreateWindowInWatchedContainer
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
#include "ash/shell.h"
#include "ash/switchable_windows.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/shell_test_api.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
namespace ash {
#if !defined(OS_WIN)
class MaximizeModeWindowManagerTest : public test::AshTestBase {
public:
MaximizeModeWindowManagerTest() {}
virtual ~MaximizeModeWindowManagerTest() {}
aura::Window* CreateNonMaximizableWindow(ui::wm::WindowType type,
const gfx::Rect& bounds) {
return CreateWindowInWatchedContainer(type, bounds, false);
}
aura::Window* CreateWindow(ui::wm::WindowType type,
const gfx::Rect bounds) {
return CreateWindowInWatchedContainer(type, bounds, true);
}
ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
EXPECT_FALSE(maximize_mode_window_manager());
Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
return maximize_mode_window_manager();
}
void DestroyMaximizeModeWindowManager() {
Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
EXPECT_FALSE(maximize_mode_window_manager());
}
ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
test::ShellTestApi test_api(Shell::GetInstance());
return test_api.maximize_mode_window_manager();
}
void ResizeDesktop(int width_delta) {
gfx::Size size = Shell::GetScreen()->GetDisplayNearestWindow(
Shell::GetPrimaryRootWindow()).size();
size.Enlarge(0, width_delta);
UpdateDisplay(size.ToString());
}
private:
aura::Window* CreateWindowInWatchedContainer(ui::wm::WindowType type,
const gfx::Rect& bounds,
bool can_maximize) {
aura::test::TestWindowDelegate* delegate = NULL;
if (!can_maximize) {
delegate = aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate();
delegate->set_window_component(HTCAPTION);
}
aura::Window* window = aura::test::CreateTestWindowWithDelegateAndType(
delegate, type, 0, bounds, NULL);
window->SetProperty(aura::client::kCanMaximizeKey, can_maximize);
aura::Window* container = Shell::GetContainer(
Shell::GetPrimaryRootWindow(),
kSwitchableWindowContainerIds[0]);
container->AddChild(window);
return window;
}
DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest);
};
TEST_F(MaximizeModeWindowManagerTest, SimpleStart) {
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
DestroyMaximizeModeWindowManager();
}
TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) {
gfx::Rect rect1(10, 10, 200, 50);
gfx::Rect rect2(10, 60, 200, 50);
gfx::Rect rect3(20, 140, 100, 100);
gfx::Rect rect(80, 90, 100, 110);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
scoped_ptr<aura::Window> w3(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
scoped_ptr<aura::Window> w4(CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect));
scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect));
scoped_ptr<aura::Window> w6(CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect));
scoped_ptr<aura::Window> w7(CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect));
scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect));
EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized());
EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
DestroyMaximizeModeWindowManager();
EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
}
TEST_F(MaximizeModeWindowManagerTest, CreateWindows) {
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
gfx::Rect rect1(10, 10, 200, 50);
gfx::Rect rect2(10, 60, 200, 50);
gfx::Rect rect3(20, 140, 100, 100);
gfx::Rect rect(80, 90, 100, 110);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
scoped_ptr<aura::Window> w3(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
scoped_ptr<aura::Window> w4(CreateWindow(ui::wm::WINDOW_TYPE_PANEL, rect));
scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_POPUP, rect));
scoped_ptr<aura::Window> w6(CreateWindow(ui::wm::WINDOW_TYPE_CONTROL, rect));
scoped_ptr<aura::Window> w7(CreateWindow(ui::wm::WINDOW_TYPE_MENU, rect));
scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect));
EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
EXPECT_NE(rect3.ToString(), w3->bounds().ToString());
EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized());
EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
DestroyMaximizeModeWindowManager();
EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
}
TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) {
ash::MaximizeModeWindowManager* manager = NULL;
{
gfx::Rect rect1(10, 10, 200, 50);
gfx::Rect rect2(10, 60, 200, 50);
gfx::Rect rect3(20, 140, 100, 100);
gfx::Rect rect(80, 90, 100, 110);
scoped_ptr<aura::Window> w1(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
scoped_ptr<aura::Window> w2(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
scoped_ptr<aura::Window> w3(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
}
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
DestroyMaximizeModeWindowManager();
}
TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) {
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
{
gfx::Rect rect1(10, 10, 200, 50);
gfx::Rect rect2(10, 60, 200, 50);
gfx::Rect rect3(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
scoped_ptr<aura::Window> w2(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50)));
scoped_ptr<aura::Window> w3(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL,
gfx::Rect(20, 140, 100, 100)));
EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
}
EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
DestroyMaximizeModeWindowManager();
}
TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) {
gfx::Rect rect(10, 10, 200, 50);
scoped_ptr<aura::Window> window(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
wm::GetWindowState(window.get())->Maximize();
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
DestroyMaximizeModeWindowManager();
EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
wm::GetWindowState(window.get())->Restore();
EXPECT_EQ(rect.ToString(), window->bounds().ToString());
}
TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
gfx::Rect rect(10, 10, 200, 50);
scoped_ptr<aura::Window> initially_minimized_window(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> initially_normal_window(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> initially_maximized_window(
CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
wm::GetWindowState(initially_minimized_window.get())->Minimize();
wm::GetWindowState(initially_maximized_window.get())->Maximize();
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
EXPECT_TRUE(wm::GetWindowState(
initially_minimized_window.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized());
EXPECT_TRUE(wm::GetWindowState(
initially_maximized_window.get())->IsMaximized());
wm::GetWindowState(initially_normal_window.get())->Minimize();
wm::GetWindowState(initially_maximized_window.get())->Minimize();
EXPECT_TRUE(wm::GetWindowState(
initially_minimized_window.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(
initially_normal_window.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(
initially_maximized_window.get())->IsMinimized());
DestroyMaximizeModeWindowManager();
EXPECT_TRUE(wm::GetWindowState(
initially_minimized_window.get())->IsMinimized());
EXPECT_FALSE(wm::GetWindowState(
initially_normal_window.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(
initially_maximized_window.get())->IsMaximized());
}
TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) {
UpdateDisplay("400x400");
gfx::Rect rect(20, 300, 100, 100);
scoped_ptr<aura::Window> window1(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
EXPECT_EQ(rect.ToString(), window1->bounds().ToString());
gfx::Rect rect2(20, 140, 100, 100);
scoped_ptr<aura::Window> window2(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(2, manager->GetNumberOfManagedWindows());
gfx::Rect moved_bounds(window1->bounds());
EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
UpdateDisplay("300x300");
gfx::Rect new_moved_bounds(window1->bounds());
EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
DestroyMaximizeModeWindowManager();
EXPECT_NE(rect.ToString(), window1->bounds().ToString());
EXPECT_EQ(rect2.ToString(), window2->bounds().ToString());
}
TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> window(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
gfx::Rect moved_bounds(window->bounds());
EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
ResizeDesktop(-10);
gfx::Rect new_moved_bounds(window->bounds());
EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
ResizeDesktop(10);
DestroyMaximizeModeWindowManager();
EXPECT_EQ(rect.ToString(), window->bounds().ToString());
}
TEST_F(MaximizeModeWindowManagerTest, ModeChangeKeepsMRUOrder) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> w2(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> w3(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> w4(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
scoped_ptr<aura::Window> w5(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
{
MruWindowTracker::WindowList windows =
MruWindowTracker::BuildWindowList(false);
EXPECT_EQ(w1.get(), windows[4]);
EXPECT_EQ(w2.get(), windows[3]);
EXPECT_EQ(w3.get(), windows[2]);
EXPECT_EQ(w4.get(), windows[1]);
EXPECT_EQ(w5.get(), windows[0]);
}
ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
ASSERT_TRUE(manager);
EXPECT_EQ(5, manager->GetNumberOfManagedWindows());
{
MruWindowTracker::WindowList windows =
MruWindowTracker::BuildWindowList(false);
EXPECT_EQ(w1.get(), windows[4]);
EXPECT_EQ(w2.get(), windows[3]);
EXPECT_EQ(w3.get(), windows[2]);
EXPECT_EQ(w4.get(), windows[1]);
EXPECT_EQ(w5.get(), windows[0]);
}
DestroyMaximizeModeWindowManager();
{
MruWindowTracker::WindowList windows =
MruWindowTracker::BuildWindowList(false);
EXPECT_EQ(w1.get(), windows[4]);
EXPECT_EQ(w2.get(), windows[3]);
EXPECT_EQ(w3.get(), windows[2]);
EXPECT_EQ(w4.get(), windows[1]);
EXPECT_EQ(w5.get(), windows[0]);
}
}
TEST_F(MaximizeModeWindowManagerTest, IgnoreRestoreStateChages) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
wm::WindowState* window_state = wm::GetWindowState(w1.get());
CreateMaximizeModeWindowManager();
EXPECT_TRUE(window_state->IsMaximized());
window_state->Minimize();
EXPECT_TRUE(window_state->IsMinimized());
window_state->Restore();
EXPECT_TRUE(window_state->IsMaximized());
window_state->Restore();
EXPECT_TRUE(window_state->IsMaximized());
DestroyMaximizeModeWindowManager();
}
TEST_F(MaximizeModeWindowManagerTest, FullScreenModeTests) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
wm::WindowState* window_state = wm::GetWindowState(w1.get());
wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
window_state->OnWMEvent(&event);
EXPECT_TRUE(window_state->IsFullscreen());
CreateMaximizeModeWindowManager();
EXPECT_FALSE(window_state->IsFullscreen());
EXPECT_TRUE(window_state->IsMaximized());
window_state->OnWMEvent(&event);
EXPECT_FALSE(window_state->IsFullscreen());
EXPECT_TRUE(window_state->IsMaximized());
DestroyMaximizeModeWindowManager();
EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_FALSE(window_state->IsMaximized());
}
TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) {
gfx::Rect rect(20, 140, 100, 100);
scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
wm::WindowState* window_state = wm::GetWindowState(w1.get());
wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT);
wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&event_left);
EXPECT_TRUE(window_state->IsSnapped());
CreateMaximizeModeWindowManager();
EXPECT_FALSE(window_state->IsSnapped());
EXPECT_TRUE(window_state->IsMaximized());
window_state->OnWMEvent(&event_left);
EXPECT_FALSE(window_state->IsSnapped());
EXPECT_TRUE(window_state->IsMaximized());
window_state->OnWMEvent(&event_right);
EXPECT_FALSE(window_state->IsSnapped());
EXPECT_TRUE(window_state->IsMaximized());
DestroyMaximizeModeWindowManager();
EXPECT_TRUE(window_state->IsSnapped());
}
TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) {
gfx::Rect rect(10, 10, 100, 100);
scoped_ptr<aura::Window> window(
CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
EXPECT_EQ(rect.ToString(), window->bounds().ToString());
aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2));
generator.PressLeftButton();
generator.MoveMouseBy(10, 5);
RunAllPendingInMessageLoop();
generator.ReleaseLeftButton();
gfx::Point first_dragged_origin = window->bounds().origin();
EXPECT_EQ(rect.x() + 10, first_dragged_origin.x());
EXPECT_EQ(rect.y() + 5, first_dragged_origin.y());
ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
gfx::Rect center_bounds(window->bounds());
EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString());
generator.MoveMouseTo(gfx::Point(center_bounds.x() + 1,
center_bounds.y() + 1));
generator.PressLeftButton();
generator.MoveMouseBy(10, 5);
RunAllPendingInMessageLoop();
generator.ReleaseLeftButton();
EXPECT_EQ(center_bounds.x(), window->bounds().x());
EXPECT_EQ(center_bounds.y(), window->bounds().y());
ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
generator.MoveMouseTo(gfx::Point(first_dragged_origin.x() + 1,
first_dragged_origin.y() + 1));
generator.PressLeftButton();
generator.MoveMouseBy(10, 5);
RunAllPendingInMessageLoop();
generator.ReleaseLeftButton();
EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
}
#endif
}