summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/wm/default_state.cc77
-rw-r--r--ash/wm/default_state.h16
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.cc132
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager.h19
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc136
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_state.cc218
-rw-r--r--ash/wm/maximize_mode/maximize_mode_window_state.h68
-rw-r--r--ash/wm/window_state.cc9
-rw-r--r--ash/wm/window_state.h22
-rw-r--r--ash/wm/window_state_unittest.cc86
11 files changed, 129 insertions, 656 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 222e894..a53624e 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -549,8 +549,6 @@
'wm/lock_state_observer.h',
'wm/maximize_mode/maximize_mode_window_manager.cc',
'wm/maximize_mode/maximize_mode_window_manager.h',
- 'wm/maximize_mode/maximize_mode_window_state.cc',
- 'wm/maximize_mode/maximize_mode_window_state.h',
'wm/maximize_mode/workspace_backdrop_delegate.cc',
'wm/maximize_mode/workspace_backdrop_delegate.h',
'wm/mru_window_tracker.cc',
diff --git a/ash/wm/default_state.cc b/ash/wm/default_state.cc
index 55ba9fa..6a2de1d 100644
--- a/ash/wm/default_state.cc
+++ b/ash/wm/default_state.cc
@@ -144,83 +144,6 @@ WindowStateType DefaultState::GetType() const {
return state_type_;
}
-void DefaultState::AttachState(WindowState* window_state,
- WindowState::State* previous_state) {
- DCHECK_EQ(stored_window_state_, window_state);
- WindowStateType old_state_type = state_type_;
- state_type_ = previous_state->GetType();
-
- // Forget our restore sizes when the workspace size has changed.
- bool workspace_unchanged = stored_workspace_size_ ==
- window_state->window()->parent()->bounds().size();
-
- // Set the restore bounds to be the previous bounds - this might be required
- // for some state transitions like restore, so that the animations are sound.
- if (!stored_bounds_.IsEmpty() && workspace_unchanged)
- window_state->SetRestoreBoundsInParent(stored_bounds_);
- else
- window_state->ClearRestoreBounds();
-
- if (old_state_type != state_type_) {
- wm::WMEventType type = wm::WM_EVENT_NORMAL;
- switch (old_state_type) {
- case wm::WINDOW_STATE_TYPE_DEFAULT:
- case wm::WINDOW_STATE_TYPE_AUTO_POSITIONED:
- case wm::WINDOW_STATE_TYPE_NORMAL:
- case wm::WINDOW_STATE_TYPE_DETACHED:
- case wm::WINDOW_STATE_TYPE_END:
- break;
- case wm::WINDOW_STATE_TYPE_MINIMIZED:
- type = wm::WM_EVENT_MINIMIZE;
- break;
- case wm::WINDOW_STATE_TYPE_MAXIMIZED:
- type = wm::WM_EVENT_MAXIMIZE;
- break;
- case wm::WINDOW_STATE_TYPE_INACTIVE:
- type = wm::WM_EVENT_SHOW_INACTIVE;
- break;
- case wm::WINDOW_STATE_TYPE_FULLSCREEN:
- type = wm::WM_EVENT_TOGGLE_FULLSCREEN;
- break;
- case wm::WINDOW_STATE_TYPE_LEFT_SNAPPED:
- type = wm::WM_EVENT_SNAP_LEFT;
- break;
- case wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED:
- type = wm::WM_EVENT_SNAP_RIGHT;
- break;
- }
- wm::WMEvent event(type);
- window_state->OnWMEvent(&event);
- }
-
- if (workspace_unchanged) {
- // If the bounds are not yet set and valid we restore them.
- if (!stored_bounds_.IsEmpty() &&
- stored_bounds_ != window_state->window()->bounds()) {
- if (state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED)
- window_state->SetBoundsDirect(stored_bounds_);
- else
- window_state->SetBoundsDirectAnimated(stored_bounds_);
- }
-
- // Then restore the restore bounds to their previous value.
- if (!stored_restore_bounds_.IsEmpty())
- window_state->SetRestoreBoundsInParent(stored_restore_bounds_);
- else
- window_state->ClearRestoreBounds();
- }
-}
-
-void DefaultState::DetachState(WindowState* window_state) {
- stored_window_state_ = window_state;
- aura::Window* window = window_state->window();
- stored_bounds_ = window->bounds();
- stored_restore_bounds_ = window_state->HasRestoreBounds() ?
- window_state->GetRestoreBoundsInParent() : gfx::Rect();
- stored_workspace_size_ =
- Shell::GetScreen()->GetDisplayNearestWindow(window).work_area().size();
-}
-
// static
bool DefaultState::ProcessCompoundEvents(WindowState* window_state,
const WMEvent* event) {
diff --git a/ash/wm/default_state.h b/ash/wm/default_state.h
index 1051fae..e7e3de8 100644
--- a/ash/wm/default_state.h
+++ b/ash/wm/default_state.h
@@ -20,10 +20,8 @@ class DefaultState : public WindowState::State {
// WindowState::State overrides:
virtual void OnWMEvent(WindowState* window_state,
const WMEvent* event) OVERRIDE;
+
virtual WindowStateType GetType() const OVERRIDE;
- virtual void AttachState(WindowState* window_state,
- WindowState::State* previous_state) OVERRIDE;
- virtual void DetachState(WindowState* window_state) OVERRIDE;
private:
// Process state dependent events, such as TOGGLE_MAXIMIZED,
@@ -45,20 +43,8 @@ class DefaultState : public WindowState::State {
static void SetBounds(WindowState* window_state,
const SetBoundsEvent* bounds_event);
- // The current type of the window.
WindowStateType state_type_;
- // The saved window state for the case that the state gets de-/activated.
- gfx::Rect stored_bounds_;
- gfx::Rect stored_restore_bounds_;
-
- // The size of the workspace when the mode got started. If it differs from
- // the current values the bounds will get ignored.
- gfx::Size stored_workspace_size_;
-
- // The window state only gets remembered for DCHECK reasons.
- WindowState* stored_window_state_;
-
DISALLOW_COPY_AND_ASSIGN(DefaultState);
};
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.cc b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
index a97030e..24be9cb 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.cc
@@ -7,10 +7,8 @@
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
-#include "ash/wm/maximize_mode/maximize_mode_window_state.h"
#include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
#include "ash/wm/mru_window_tracker.h"
-#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/workspace_controller.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"
@@ -28,17 +26,7 @@ MaximizeModeWindowManager::~MaximizeModeWindowManager() {
}
int MaximizeModeWindowManager::GetNumberOfManagedWindows() {
- return window_state_map_.size();
-}
-
-void MaximizeModeWindowManager::WindowStateDestroyed(aura::Window* window) {
- // At this time ForgetWindow() should already have been called. If not,
- // someone else must have replaced the "window manager's state object".
- DCHECK(!window->HasObserver(this));
-
- WindowToState::iterator it = window_state_map_.find(window);
- DCHECK(it != window_state_map_.end());
- window_state_map_.erase(it);
+ return initial_state_type_.size();
}
void MaximizeModeWindowManager::OnOverviewModeStarted() {
@@ -67,7 +55,7 @@ void MaximizeModeWindowManager::OnWindowAdded(
aura::Window* window) {
// A window can get removed and then re-added by a drag and drop operation.
if (IsContainerWindow(window->parent()) &&
- window_state_map_.find(window) == window_state_map_.end())
+ initial_state_type_.find(window) == initial_state_type_.end())
MaximizeAndTrackWindow(window);
}
@@ -78,10 +66,11 @@ void MaximizeModeWindowManager::OnWindowBoundsChanged(
if (!IsContainerWindow(window))
return;
// Reposition all non maximizeable windows.
- for (WindowToState::iterator it = window_state_map_.begin();
- it != window_state_map_.end();
+ for (WindowToStateType::iterator it = initial_state_type_.begin();
+ it != initial_state_type_.end();
++it) {
- it->second->UpdateWindowPosition(wm::GetWindowState(it->first), false);
+ if (!CanMaximize(it->first))
+ CenterWindow(it->first);
}
}
@@ -100,13 +89,8 @@ void MaximizeModeWindowManager::OnDisplayRemoved(const gfx::Display& display) {
MaximizeModeWindowManager::MaximizeModeWindowManager()
: backdrops_hidden_(false) {
- // The overview mode needs to be ended before the maximize mode is started. To
- // guarantee the proper order, it will be turned off from here.
- WindowSelectorController* controller =
- Shell::GetInstance()->window_selector_controller();
- if (controller && controller->IsSelecting())
- controller->OnSelectionCanceled();
-
+ // TODO(skuhne): Turn off the overview mode and full screen modes before
+ // entering the MaximzieMode.
MaximizeAllWindows();
AddWindowCreationObservers();
EnableBackdropBehindTopWindowOnEachDisplay(true);
@@ -126,8 +110,8 @@ void MaximizeModeWindowManager::MaximizeAllWindows() {
}
void MaximizeModeWindowManager::RestoreAllWindows() {
- while (window_state_map_.size())
- ForgetWindow(window_state_map_.begin()->first);
+ while (initial_state_type_.size())
+ RestoreAndForgetWindow(initial_state_type_.begin()->first);
}
void MaximizeModeWindowManager::MaximizeAndTrackWindow(
@@ -135,27 +119,72 @@ void MaximizeModeWindowManager::MaximizeAndTrackWindow(
if (!ShouldHandleWindow(window))
return;
- DCHECK(window_state_map_.find(window) == window_state_map_.end());
+ DCHECK(initial_state_type_.find(window) == initial_state_type_.end());
window->AddObserver(this);
-
- // We create and remember a maximize mode state which will attach itself to
- // the provided state object.
- window_state_map_[window] = new MaximizeModeWindowState(window, this);
+ // Remember the state at the creation.
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ wm::WindowStateType state = window_state->GetStateType();
+ initial_state_type_[window] = state;
+ // If it is not maximized yet we may need to maximize it now.
+ if (state != wm::WINDOW_STATE_TYPE_MAXIMIZED) {
+ if (!CanMaximize(window)) {
+ // This window type should not be able to have a restore state set (since
+ // it cannot maximize).
+ DCHECK(!window_state->HasRestoreBounds());
+ // Store the coordinates as restore coordinates.
+ gfx::Rect initial_rect = window->bounds();
+ if (window->parent())
+ window_state->SetRestoreBoundsInParent(initial_rect);
+ else
+ window_state->SetRestoreBoundsInScreen(initial_rect);
+ CenterWindow(window);
+ } else {
+ // Minimized windows can remain as they are.
+ if (state != wm::WINDOW_STATE_TYPE_MINIMIZED)
+ wm::GetWindowState(window)->Maximize();
+ }
+ }
+ window_state->set_can_be_dragged(false);
}
-void MaximizeModeWindowManager::ForgetWindow(aura::Window* window) {
- WindowToState::iterator it = window_state_map_.find(window);
+void MaximizeModeWindowManager::RestoreAndForgetWindow(
+ aura::Window* window) {
+ wm::WindowStateType state = ForgetWindow(window);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ window_state->set_can_be_dragged(true);
+ // Restore window if it can be restored.
+ if (state != wm::WINDOW_STATE_TYPE_MAXIMIZED) {
+ if (!CanMaximize(window)) {
+ if (window_state->HasRestoreBounds()) {
+ // TODO(skuhne): If the system shuts down in maximized mode, the proper
+ // restore coordinates should get saved.
+ gfx::Rect initial_bounds =
+ window->parent() ? window_state->GetRestoreBoundsInParent() :
+ window_state->GetRestoreBoundsInScreen();
+ window_state->ClearRestoreBounds();
+ // TODO(skuhne): The screen might have changed and we should make sure
+ // that the bounds are in a visible area.
+ window->SetBounds(initial_bounds);
+ }
+ } else {
+ // If the window neither was minimized or maximized and it is currently
+ // not minimized, we restore it.
+ if (state != wm::WINDOW_STATE_TYPE_MINIMIZED &&
+ !wm::GetWindowState(window)->IsMinimized()) {
+ wm::GetWindowState(window)->Restore();
+ }
+ }
+ }
+}
- // The following DCHECK could fail if our window state object was destroyed
- // earlier by someone else. However - at this point there is no other client
- // which replaces the state object and therefore this should not happen.
- DCHECK(it != window_state_map_.end());
+wm::WindowStateType MaximizeModeWindowManager::ForgetWindow(
+ aura::Window* window) {
+ WindowToStateType::iterator it = initial_state_type_.find(window);
+ DCHECK(it != initial_state_type_.end());
window->RemoveObserver(this);
-
- // By telling the state object to revert, it will switch back the old
- // State object and destroy itself, calling WindowStateDerstroyed().
- it->second->LeaveMaximizeMode(wm::GetWindowState(it->first));
- DCHECK(window_state_map_.find(window) == window_state_map_.end());
+ wm::WindowStateType state = it->second;
+ initial_state_type_.erase(it);
+ return state;
}
bool MaximizeModeWindowManager::ShouldHandleWindow(aura::Window* window) {
@@ -163,6 +192,25 @@ bool MaximizeModeWindowManager::ShouldHandleWindow(aura::Window* window) {
return window->type() == ui::wm::WINDOW_TYPE_NORMAL;
}
+bool MaximizeModeWindowManager::CanMaximize(aura::Window* window) {
+ DCHECK(window);
+ return wm::GetWindowState(window)->CanMaximize();
+}
+
+void MaximizeModeWindowManager::CenterWindow(aura::Window* window) {
+ gfx::Size window_size = window->bounds().size();
+ gfx::Rect work_area = gfx::Screen::GetScreenFor(window)->
+ GetDisplayNearestWindow(window).work_area();
+
+ gfx::Rect window_bounds(
+ work_area.x() + (work_area.width() - window_size.width()) / 2,
+ work_area.y() + (work_area.height() - window_size.height()) / 2,
+ window_size.width(),
+ window_size.height());
+
+ window->SetBounds(window_bounds);
+}
+
void MaximizeModeWindowManager::AddWindowCreationObservers() {
DCHECK(observed_container_windows_.empty());
// Observe window activations/creations in the default containers on all root
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager.h b/ash/wm/maximize_mode/maximize_mode_window_manager.h
index 0c51cb3..f8af8d0 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager.h
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager.h
@@ -20,7 +20,6 @@ namespace ash {
class Shell;
namespace internal{
-class MaximizeModeWindowState;
// A window manager which - when created - will force all windows into maximized
// mode. Exception are panels and windows which cannot be maximized.
@@ -38,9 +37,6 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
// Returns the number of maximized & tracked windows by this manager.
int GetNumberOfManagedWindows();
- // Called from a window state object when it gets destroyed.
- void WindowStateDestroyed(aura::Window* window);
-
// Overridden from WindowObserver:
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
@@ -65,7 +61,7 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
MaximizeModeWindowManager();
private:
- typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
+ typedef std::map<aura::Window*, wm::WindowStateType> WindowToStateType;
// Maximize all windows and restore their current state.
void MaximizeAllWindows();
@@ -80,12 +76,21 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
// immediately.
void MaximizeAndTrackWindow(aura::Window* window);
+ // Restore the window to its original state and remove it from our tracking.
+ void RestoreAndForgetWindow(aura::Window* window);
+
// Remove a window from our tracking list.
- void ForgetWindow(aura::Window* window);
+ wm::WindowStateType ForgetWindow(aura::Window* window);
// Returns true when the given window should be modified in any way by us.
bool ShouldHandleWindow(aura::Window* window);
+ // Returns true when the given window can be maximized.
+ bool CanMaximize(aura::Window* window);
+
+ // Maximize the window on the screen's workspace.
+ void CenterWindow(aura::Window* window);
+
// Add window creation observers to track creation of new windows.
void AddWindowCreationObservers();
@@ -103,7 +108,7 @@ class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
// Every window which got touched by our window manager gets added here.
- WindowToState window_state_map_;
+ WindowToStateType initial_state_type_;
// All container windows which have to be tracked.
std::set<aura::Window*> observed_container_windows_;
diff --git a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
index f2ee161..57e89f6 100644
--- a/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc
@@ -10,7 +10,6 @@
#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"
@@ -22,12 +21,8 @@
namespace ash {
-// TODO(skuhne): These tests are failing on Widows because maximized is there
-// differently handled. Fix this!
-#if !defined(OS_WIN)
-
class MaximizeModeWindowManagerTest : public test::AshTestBase {
- public:
+public:
MaximizeModeWindowManagerTest() {}
virtual ~MaximizeModeWindowManagerTest() {}
@@ -268,18 +263,16 @@ TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) {
gfx::Rect rect1(10, 10, 200, 50);
gfx::Rect rect2(10, 60, 200, 50);
gfx::Rect rect3(20, 140, 100, 100);
+ // Bounds for anything else.
+ gfx::Rect rect(80, 90, 100, 110);
scoped_ptr<aura::Window> w1(
- CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
+ CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
scoped_ptr<aura::Window> w2(
- CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50)));
+ CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
scoped_ptr<aura::Window> w3(
- CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL,
- gfx::Rect(20, 140, 100, 100)));
- // Check that the windows got automatically maximized as well.
+ CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
+
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();
@@ -308,8 +301,7 @@ TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) {
}
// Test that minimized windows do neither get maximized nor restored upon
-// entering maximized mode and get restored to their previous state after
-// leaving.
+// entering or leaving the maximized mode.
TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
// Bounds for windows we know can be controlled.
gfx::Rect rect(10, 10, 200, 50);
@@ -333,7 +325,7 @@ TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
EXPECT_TRUE(wm::GetWindowState(
initially_maximized_window.get())->IsMaximized());
// Now minimize the second window to check that upon leaving the window
- // will get restored to its minimized state.
+ // remains in its minimized state.
wm::GetWindowState(initially_normal_window.get())->Minimize();
wm::GetWindowState(initially_maximized_window.get())->Minimize();
EXPECT_TRUE(wm::GetWindowState(
@@ -343,14 +335,13 @@ TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
EXPECT_TRUE(wm::GetWindowState(
initially_maximized_window.get())->IsMinimized());
- // Destroy the manager again and check that the window will get minimized.
+ // Destroy the manager again and check that the window will remain minimized.
DestroyMaximizeModeWindowManager();
EXPECT_TRUE(wm::GetWindowState(
initially_minimized_window.get())->IsMinimized());
- EXPECT_FALSE(wm::GetWindowState(
- initially_normal_window.get())->IsMinimized());
+ EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMinimized());
EXPECT_TRUE(wm::GetWindowState(
- initially_maximized_window.get())->IsMaximized());
+ initially_maximized_window.get())->IsMinimized());
}
// Check that resizing the desktop does reposition unmaximizable & managed
@@ -377,38 +368,7 @@ TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) {
EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
- // Turning off the mode should not restore to the initial coordinates since
- // the new resolution is different.
- DestroyMaximizeModeWindowManager();
- EXPECT_NE(rect.ToString(), window->bounds().ToString());
-}
-
-// Check that windows return to original location if desktop size changes to
-// something else and back while in maximize mode.
-TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) {
- gfx::Rect rect(20, 140, 100, 100);
- scoped_ptr<aura::Window> window(
- CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
-
- // Turning on the manager will reposition (but not resize) the window.
- ash::internal::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());
-
- // Simulating a desktop resize should move the window again.
- 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());
-
- // Then resize back to the original desktop size which should move windows
- // to their original location after leaving the maximize mode.
- ResizeDesktop(10);
+ // Turning off the mode however should restore to the initial coordinates.
DestroyMaximizeModeWindowManager();
EXPECT_EQ(rect.ToString(), window->bounds().ToString());
}
@@ -466,74 +426,6 @@ TEST_F(MaximizeModeWindowManagerTest, ModeChangeKeepsMRUOrder) {
}
}
-// Check that a restore state change does always restore to maximized.
-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();
-}
-
-// Check that a full screen window is changing to maximized in maximize mode,
-// cannot go to fullscreen and goes back to fullscreen thereafter.
-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();
-
- // Fullscreen mode should now be off and it should not come back while in
- // maximize mode.
- 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());
-}
-
-// Check that snapping operations get ignored.
-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();
-
- // Fullscreen mode should now be off and it should not come back while in
- // maximize mode.
- 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());
-}
-
// Check that non maximizable windows cannot be dragged by the user.
TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) {
gfx::Rect rect(10, 10, 100, 100);
@@ -580,6 +472,4 @@ TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) {
EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
}
-#endif // OS_WIN
-
} // namespace ash
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc
deleted file mode 100644
index 7027c91..0000000
--- a/ash/wm/maximize_mode/maximize_mode_window_state.cc
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/wm/maximize_mode/maximize_mode_window_state.h"
-
-#include "ash/display/display_controller.h"
-#include "ash/screen_util.h"
-#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/coordinate_conversion.h"
-#include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
-#include "ash/wm/window_animations.h"
-#include "ash/wm/window_state.h"
-#include "ash/wm/window_state_delegate.h"
-#include "ash/wm/window_util.h"
-#include "ash/wm/wm_event.h"
-#include "ash/wm/workspace/workspace_window_resizer.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_delegate.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/rect.h"
-
-namespace ash {
-namespace internal {
-namespace {
-
-// Returns the biggest possible size for a window which is about to be
-// maximized.
-gfx::Size GetMaximumSizeOfWindow(wm::WindowState* window_state) {
- DCHECK(window_state->CanMaximize());
-
- gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent(
- window_state->window()).size();
-
- aura::WindowDelegate* delegate = window_state->window()->delegate();
- if (!delegate)
- return workspace_size;
-
- gfx::Size size = delegate->GetMaximumSize();
- if (size.IsEmpty())
- return workspace_size;
-
- size.SetToMin(workspace_size);
- return size;
-}
-
-// Returns the maximized and centered bounds of a window.
-gfx::Rect GetMaximizedAndCenteredBounds(wm::WindowState* state_object) {
- gfx::Rect bounds_in_parent;
- if (state_object->CanMaximize()) {
- bounds_in_parent.set_size(GetMaximumSizeOfWindow(state_object));
- } else {
- // We prefer the user given window dimensions over the current windows
- // dimensions since they are likely to be the result from some other state
- // object logic.
- if (state_object->HasRestoreBounds())
- bounds_in_parent = state_object->GetRestoreBoundsInParent();
- else
- bounds_in_parent = state_object->window()->bounds();
- }
-
- // Make sure that part of the window is always visible and centered.
- bounds_in_parent.ClampToCenteredSize(
- ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- state_object->window()).size());
-
- return bounds_in_parent;
-}
-
-} // namespace
-
-// static
-void MaximizeModeWindowState::UpdateWindowPosition(
- wm::WindowState* window_state, bool animated) {
- gfx::Rect bounds_in_parent = GetMaximizedAndCenteredBounds(window_state);
-
- if (bounds_in_parent == window_state->window()->bounds())
- return;
-
- if (animated)
- window_state->SetBoundsDirect(bounds_in_parent);
- else
- window_state->SetBoundsDirectAnimated(bounds_in_parent);
-}
-
-MaximizeModeWindowState::MaximizeModeWindowState(
- aura::Window* window, MaximizeModeWindowManager* creator)
- : window_(window),
- creator_(creator),
- current_state_type_(wm::GetWindowState(window)->GetStateType()) {
- old_state_.reset(
- wm::GetWindowState(window)->SetStateObject(
- scoped_ptr<State>(this).Pass()).release());
-}
-
-MaximizeModeWindowState::~MaximizeModeWindowState() {
- creator_->WindowStateDestroyed(window_);
-}
-
-void MaximizeModeWindowState::LeaveMaximizeMode(wm::WindowState* window_state) {
- // Note: When we return we will destroy ourselves with the |our_reference|.
- scoped_ptr<wm::WindowState::State> our_reference =
- window_state->SetStateObject(old_state_.Pass());
-}
-
-void MaximizeModeWindowState::OnWMEvent(wm::WindowState* window_state,
- const wm::WMEvent* event) {
- switch (event->type()) {
- case wm::WM_EVENT_TOGGLE_MAXIMIZE_CAPTION:
- case wm::WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE:
- case wm::WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE:
- case wm::WM_EVENT_TOGGLE_FULLSCREEN:
- case wm::WM_EVENT_TOGGLE_MAXIMIZE:
- case wm::WM_EVENT_FULLSCREEN:
- case wm::WM_EVENT_SNAP_LEFT:
- case wm::WM_EVENT_SNAP_RIGHT:
- case wm::WM_EVENT_NORMAL:
- case wm::WM_EVENT_MAXIMIZE:
- MaximizeOrCenterWindow(window_state, true);
- return;
- case wm::WM_EVENT_MINIMIZE:
- if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) {
- current_state_type_ = wm::WINDOW_STATE_TYPE_MINIMIZED;
- window_state->Minimize();
- }
- return;
- case wm::WM_EVENT_SHOW_INACTIVE:
- return;
- case wm::WM_EVENT_SET_BOUNDS:
- if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED &&
- current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED) {
- gfx::Rect bounds_in_parent =
- (static_cast<const wm::SetBoundsEvent*>(event))->requested_bounds();
- bounds_in_parent.ClampToCenteredSize(
- ScreenUtil::GetDisplayWorkAreaBoundsInParent(
- window_state->window()).size());
- if (bounds_in_parent != window_state->window()->bounds())
- window_state->SetBoundsDirectAnimated(bounds_in_parent);
- }
- break;
- case wm::WM_EVENT_ADDED_TO_WORKSPACE:
- MaximizeOrCenterWindow(window_state, true);
- break;
- case wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED:
- case wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED:
- if (current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED)
- MaximizeOrCenterWindow(window_state, false);
- break;
- }
-}
-
-wm::WindowStateType MaximizeModeWindowState::GetType() const {
- return current_state_type_;
-}
-
-void MaximizeModeWindowState::AttachState(
- wm::WindowState* window_state,
- wm::WindowState::State* previous_state) {
- current_state_type_ = previous_state->GetType();
-
- // Initialize the state to a good preset.
- if (current_state_type_ != wm::WINDOW_STATE_TYPE_MAXIMIZED &&
- current_state_type_ != wm::WINDOW_STATE_TYPE_MINIMIZED) {
- MaximizeOrCenterWindow(window_state, true);
- }
-
- window_state->set_can_be_dragged(false);
-}
-
-void MaximizeModeWindowState::DetachState(wm::WindowState* window_state) {
- window_state->set_can_be_dragged(true);
-}
-
-void MaximizeModeWindowState::MaximizeOrCenterWindow(
- wm::WindowState* window_state,
- bool animated) {
- const wm::WindowStateType target_state =
- window_state->CanMaximize() ? wm::WINDOW_STATE_TYPE_MAXIMIZED :
- wm::WINDOW_STATE_TYPE_NORMAL;
- const wm::WindowStateType old_state_type = current_state_type_;
- gfx::Rect bounds_in_parent = GetMaximizedAndCenteredBounds(window_state);
-
- if (current_state_type_ != target_state) {
- current_state_type_ = target_state;
- window_state->UpdateWindowShowStateFromStateType();
- window_state->NotifyPreStateTypeChange(old_state_type);
- // If we have a target bounds rectangle, we center it and set it
- // accordingly.
- if (!bounds_in_parent.IsEmpty()) {
- if (current_state_type_ == wm::WINDOW_STATE_TYPE_MINIMIZED || !animated)
- window_state->SetBoundsDirect(bounds_in_parent);
- else
- window_state->SetBoundsDirectAnimated(bounds_in_parent);
- }
- window_state->NotifyPostStateTypeChange(old_state_type);
- } else if (!bounds_in_parent.IsEmpty() &&
- bounds_in_parent != window_state->window()->bounds()) {
- // Coming here, we were most probably called through a display change.
- // Do not animate.
- if (animated)
- window_state->SetBoundsDirectAnimated(bounds_in_parent);
- else
- window_state->SetBoundsDirect(bounds_in_parent);
- }
-
- if ((window_state->window()->TargetVisibility() ||
- old_state_type == wm::WINDOW_STATE_TYPE_MINIMIZED) &&
- !window_state->window()->layer()->visible()) {
- // The layer may be hidden if the window was previously minimized. Make
- // sure it's visible.
- window_state->window()->Show();
- }
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.h b/ash/wm/maximize_mode/maximize_mode_window_state.h
deleted file mode 100644
index 0129960..0000000
--- a/ash/wm/maximize_mode/maximize_mode_window_state.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_
-#define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_
-
-#include "ash/wm/window_state.h"
-
-namespace ash {
-namespace internal {
-class MaximizeModeWindowManager;
-
-// The MaximizeModeWindowState implementation which reduces all possible window
-// states to minimized and maximized. If a window cannot be maximized it will be
-// set to normal. If a window cannot fill the entire workspace it will be
-// centered within the workspace.
-class MaximizeModeWindowState : public wm::WindowState::State {
- public:
- // Called when the window position might need to be updated.
- static void UpdateWindowPosition(wm::WindowState* window_state,
- bool animated);
-
- // The |window|'s state object will be modified to use this new window mode
- // state handler. Upon destruction it will restore the previous state handler
- // and call |creator::WindowStateDestroyed()| to inform that the window mode
- // was reverted to the old window manager.
- MaximizeModeWindowState(aura::Window* window,
- MaximizeModeWindowManager* creator);
- virtual ~MaximizeModeWindowState();
-
- // Leaves the maximize mode by reverting to previous state object.
- void LeaveMaximizeMode(wm::WindowState* window_state);
-
- // WindowState::State overrides:
- virtual void OnWMEvent(wm::WindowState* window_state,
- const wm::WMEvent* event) OVERRIDE;
-
- virtual wm::WindowStateType GetType() const OVERRIDE;
- virtual void AttachState(wm::WindowState* window_state,
- wm::WindowState::State* previous_state) OVERRIDE;
- virtual void DetachState(wm::WindowState* window_state) OVERRIDE;
-
- private:
- // Centers the window on top of the workspace or maximizes it. If |animate| is
- // set to true, a bounds change will be animated - otherwise immediate.
- void MaximizeOrCenterWindow(wm::WindowState* window_state, bool animate);
-
- // The original state object of the window.
- scoped_ptr<wm::WindowState::State> old_state_;
-
- // The state object for this object which owns this instance.
- aura::Window* window_;
-
- // The creator which needs to be informed when this state goes away.
- MaximizeModeWindowManager* creator_;
-
- // The current state type. Due to the nature of this state, this can only be
- // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}.
- wm::WindowStateType current_state_type_;
-
- DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowState);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc
index 9af59ca..6adead4 100644
--- a/ash/wm/window_state.cc
+++ b/ash/wm/window_state.cc
@@ -255,15 +255,6 @@ void WindowState::ClearRestoreBounds() {
window_->ClearProperty(aura::client::kRestoreBoundsKey);
}
-scoped_ptr<WindowState::State> WindowState::SetStateObject(
- scoped_ptr<WindowState::State> new_state) {
- current_state_->DetachState(this);
- scoped_ptr<WindowState::State> old_object = current_state_.Pass();
- current_state_ = new_state.Pass();
- current_state_->AttachState(this, old_object.get());
- return old_object.Pass();
-}
-
void WindowState::SetPreAutoManageWindowBounds(
const gfx::Rect& bounds) {
pre_auto_manage_window_bounds_.reset(new gfx::Rect(bounds));
diff --git a/ash/wm/window_state.h b/ash/wm/window_state.h
index 8bfb16e..3a98cbb 100644
--- a/ash/wm/window_state.h
+++ b/ash/wm/window_state.h
@@ -26,7 +26,6 @@ class Rect;
namespace ash {
namespace internal {
class WorkspaceLayoutManager;
-class MaximizeModeWindowState;
}
namespace wm {
@@ -58,23 +57,10 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
virtual ~State() {}
// Update WindowState based on |event|.
- virtual void OnWMEvent(WindowState* window_state, const WMEvent* event) = 0;
+ virtual void OnWMEvent(WindowState* state, const WMEvent* event) = 0;
virtual WindowStateType GetType() const = 0;
- // Gets called when the state object became active and the managed window
- // needs to be adjusted to the State's requirement.
- // The passed |previous_state| may be used to properly implement state
- // transitions such as bound animations from the previous state.
- // Note: This only gets called when the state object gets changed.
- virtual void AttachState(WindowState* window_state,
- State* previous_state) = 0;
-
- // Gets called before the state objects gets deactivated / detached from the
- // window, so that it can save the various states it is interested in.
- // Note: This only gets called when the state object gets changed.
- virtual void DetachState(WindowState* window_state) = 0;
-
private:
DISALLOW_COPY_AND_ASSIGN(State);
};
@@ -164,11 +150,6 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
// Deletes and clears the restore bounds property on the window.
void ClearRestoreBounds();
- // Replace the State object of a window with a state handler which can
- // implement a new window manager type. The passed object will be owned
- // by this object and the returned object will be owned by the caller.
- scoped_ptr<State> SetStateObject(scoped_ptr<State> new_state);
-
// True if the window should be unminimized to the restore bounds, as
// opposed to the window's current bounds. |unminimized_to_restore_bounds_| is
// reset to the default value after the window is unminimized.
@@ -296,7 +277,6 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
private:
friend class DefaultState;
- friend class ash::internal::MaximizeModeWindowState;
FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds);
WindowStateDelegate* delegate() { return delegate_.get(); }
diff --git a/ash/wm/window_state_unittest.cc b/ash/wm/window_state_unittest.cc
index 2b4e8a3..bc3e05f 100644
--- a/ash/wm/window_state_unittest.cc
+++ b/ash/wm/window_state_unittest.cc
@@ -14,40 +14,6 @@
namespace ash {
namespace wm {
-namespace {
-
-class AlwaysMaximizeTestState : public WindowState::State {
- public:
- explicit AlwaysMaximizeTestState(WindowStateType initial_state_type)
- : state_type_(initial_state_type) {}
- virtual ~AlwaysMaximizeTestState() {}
-
- // WindowState::State overrides:
- virtual void OnWMEvent(WindowState* window_state,
- const WMEvent* event) OVERRIDE {
- // We don't do anything here.
- }
- virtual WindowStateType GetType() const OVERRIDE {
- return state_type_;
- }
- virtual void AttachState(
- WindowState* window_state,
- WindowState::State* previous_state) OVERRIDE {
- // We always maximize.
- if (state_type_ != WINDOW_STATE_TYPE_MAXIMIZED) {
- window_state->Maximize();
- state_type_ = WINDOW_STATE_TYPE_MAXIMIZED;
- }
- }
- virtual void DetachState(WindowState* window_state) OVERRIDE {}
-
- private:
- WindowStateType state_type_;
-
- DISALLOW_COPY_AND_ASSIGN(AlwaysMaximizeTestState);
-};
-
-} // namespace
typedef test::AshTestBase WindowStateTest;
@@ -65,8 +31,8 @@ TEST_F(WindowStateTest, SnapWindowBasic) {
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
- WindowState* window_state = GetWindowState(window.get());
- const WMEvent snap_left(WM_EVENT_SNAP_LEFT);
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
window_state->OnWMEvent(&snap_left);
gfx::Rect expected = gfx::Rect(
kPrimaryDisplayWorkAreaBounds.x(),
@@ -75,7 +41,7 @@ TEST_F(WindowStateTest, SnapWindowBasic) {
kPrimaryDisplayWorkAreaBounds.height());
EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
- const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
+ const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&snap_right);
expected.set_x(kPrimaryDisplayWorkAreaBounds.right() - expected.width());
EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
@@ -114,9 +80,9 @@ TEST_F(WindowStateTest, SnapWindowMinimumSize) {
// It should be possible to snap a window with a minimum size.
delegate.set_minimum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0));
- WindowState* window_state = GetWindowState(window.get());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
EXPECT_TRUE(window_state->CanSnap());
- const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
+ const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&snap_right);
gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1,
kWorkAreaBounds.y(),
@@ -141,8 +107,8 @@ TEST_F(WindowStateTest, SnapWindowSetBounds) {
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
- WindowState* window_state = GetWindowState(window.get());
- const WMEvent snap_left(WM_EVENT_SNAP_LEFT);
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
+ const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
window_state->OnWMEvent(&snap_left);
EXPECT_EQ(WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x(),
@@ -162,7 +128,7 @@ TEST_F(WindowStateTest, SnapWindowSetBounds) {
TEST_F(WindowStateTest, RestoreBounds) {
scoped_ptr<aura::Window> window(
CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100)));
- WindowState* window_state = GetWindowState(window.get());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
EXPECT_TRUE(window_state->IsNormalStateType());
@@ -170,9 +136,9 @@ TEST_F(WindowStateTest, RestoreBounds) {
gfx::Rect restore_bounds = window->GetBoundsInScreen();
restore_bounds.set_width(restore_bounds.width() + 1);
window_state->SetRestoreBoundsInScreen(restore_bounds);
- const WMEvent snap_left(WM_EVENT_SNAP_LEFT);
+ const wm::WMEvent snap_left(wm::WM_EVENT_SNAP_LEFT);
window_state->OnWMEvent(&snap_left);
- const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
+ const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&snap_right);
EXPECT_NE(restore_bounds.ToString(), window->GetBoundsInScreen().ToString());
EXPECT_EQ(restore_bounds.ToString(),
@@ -202,14 +168,14 @@ TEST_F(WindowStateTest, RestoreBounds) {
// at the snapped bounds and not at the auto-managed (centered) bounds.
TEST_F(WindowStateTest, AutoManaged) {
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
- WindowState* window_state = GetWindowState(window.get());
+ wm::WindowState* window_state = wm::GetWindowState(window.get());
window_state->set_window_position_managed(true);
window->Hide();
window->SetBounds(gfx::Rect(100, 100, 100, 100));
window->Show();
window_state->Maximize();
- const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
+ const wm::WMEvent snap_right(wm::WM_EVENT_SNAP_RIGHT);
window_state->OnWMEvent(&snap_right);
const gfx::Rect kWorkAreaBounds =
@@ -226,33 +192,5 @@ TEST_F(WindowStateTest, AutoManaged) {
EXPECT_TRUE(window_state->window_position_managed());
}
-// Test that the replacement of a State object works as expected.
-TEST_F(WindowStateTest, SimpleStateSwap) {
- scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
- WindowState* window_state = GetWindowState(window.get());
- EXPECT_FALSE(window_state->IsMaximized());
- window_state->SetStateObject(
- scoped_ptr<WindowState::State> (new AlwaysMaximizeTestState(
- window_state->GetStateType())));
- EXPECT_TRUE(window_state->IsMaximized());
-}
-
-// Test that the replacement of a state object, following a restore with the
-// original one restores the window to its original state.
-TEST_F(WindowStateTest, StateSwapRestore) {
- scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
- WindowState* window_state = GetWindowState(window.get());
- EXPECT_FALSE(window_state->IsMaximized());
- scoped_ptr<WindowState::State> old(window_state->SetStateObject(
- scoped_ptr<WindowState::State> (new AlwaysMaximizeTestState(
- window_state->GetStateType()))).Pass());
- EXPECT_TRUE(window_state->IsMaximized());
- window_state->SetStateObject(old.Pass());
- EXPECT_FALSE(window_state->IsMaximized());
-}
-
-// TODO(skuhne): Add more unit test to verify the correctness for the restore
-// operation.
-
} // namespace wm
} // namespace ash