Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: ash/wm/custom_frame_view_ash_unittest.cc

Issue 24108003: [Cleanup] Rename WindowSettings to WindowState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/custom_frame_view_ash_unittest.cc
diff --git a/ash/wm/custom_frame_view_ash_unittest.cc b/ash/wm/custom_frame_view_ash_unittest.cc
index 5c1098b4d54433c12cffbff75db5f130dc1957b9..af6538a89714aee03426c69a41ae0cc10a6f2546 100644
--- a/ash/wm/custom_frame_view_ash_unittest.cc
+++ b/ash/wm/custom_frame_view_ash_unittest.cc
@@ -10,7 +10,7 @@
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
#include "ash/wm/caption_buttons/frame_maximize_button.h"
#include "ash/wm/caption_buttons/maximize_bubble_controller.h"
-#include "ash/wm/property_util.h"
+#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "base/command_line.h"
@@ -146,35 +146,37 @@ class CustomFrameViewAshTest : public ash::test::AshTestBase {
// Tests that clicking on the resize-button toggles between maximize and normal
// state.
TEST_F(CustomFrameViewAshTest, ResizeButtonToggleMaximize) {
- aura::Window* window = widget()->GetNativeWindow();
+ wm::WindowState* window_state =
+ wm::GetWindowState(widget()->GetNativeWindow());
views::View* view = maximize_button();
gfx::Point center = view->GetBoundsInScreen().CenterPoint();
- aura::test::EventGenerator generator(window->GetRootWindow(), center);
+ aura::test::EventGenerator generator(
+ window_state->window()->GetRootWindow(), center);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.ClickLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
center = view->GetBoundsInScreen().CenterPoint();
generator.MoveMouseTo(center);
generator.ClickLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
}
#if defined(OS_WIN)
@@ -192,7 +194,8 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
aura::test::EventGenerator generator(window->GetRootWindow(), center);
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsNormal());
// Snap right.
{
@@ -201,8 +204,8 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::RIGHT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -218,8 +221,8 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -235,10 +238,10 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
}
- ash::wm::RestoreWindow(window);
+ window_state->Restore();
// Now test the same behaviour for gesture events.
@@ -252,8 +255,8 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
// This is a short resizing distance and different touch behavior
// applies which leads in half of the screen being used.
EXPECT_EQ("400,0 400x553", window->bounds().ToString());
@@ -269,8 +272,8 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, center,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -287,7 +290,7 @@ TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) {
3);
RunAllPendingInMessageLoop();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
}
// Test with gesture events.
@@ -319,8 +322,9 @@ TEST_F(CustomFrameViewAshTest,
gfx::Point end_point = gfx::Point(work_area.width(), start_point.y());
aura::test::EventGenerator generator(window->GetRootWindow(), start_point);
+ wm::WindowState* window_state = wm::GetWindowState(window);
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(window_state->IsNormal());
// Snap right with a touch drag.
generator.GestureScrollSequence(start_point,
@@ -329,8 +333,8 @@ TEST_F(CustomFrameViewAshTest,
10);
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
gfx::Rect touch_result = window->bounds();
EXPECT_NE(bounds.ToString(), touch_result.ToString());
@@ -343,8 +347,8 @@ TEST_F(CustomFrameViewAshTest,
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
gfx::Rect mouse_result = window->bounds();
// The difference between the two operations should be that the mouse
@@ -367,7 +371,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeButtonExternalShutDown) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormal());
// Move the mouse cursor over the button to bring up the maximizer bubble.
generator.MoveMouseTo(button_pos);
@@ -390,13 +394,13 @@ TEST_F(CustomFrameViewAshTest, MaximizeOnHoverThenClick) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormal());
// Move the mouse cursor over the button to bring up the maximizer bubble.
generator.MoveMouseTo(button_pos);
EXPECT_TRUE(maximize_button->maximizer());
generator.ClickLeftButton();
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized());
}
// Test that hovering over a button in the balloon dialog will show the phantom
@@ -413,7 +417,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftButtonDragOut) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormal());
EXPECT_FALSE(maximize_button->phantom_window_open());
// Move the mouse cursor over the button to bring up the maximizer bubble.
@@ -458,7 +462,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormal());
EXPECT_FALSE(maximize_button->phantom_window_open());
// Move the mouse cursor over the button to bring up the maximizer bubble.
@@ -475,8 +479,9 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) {
EXPECT_FALSE(maximize_button->maximizer());
EXPECT_FALSE(maximize_button->phantom_window_open());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
- EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+ wm::WindowState* window_state =wm::GetWindowState(window);
James Cook 2013/09/18 20:44:17 space after =
oshima 2013/09/19 01:52:01 Done.
+ EXPECT_FALSE(window_state->IsMaximized());
+ EXPECT_FALSE(window_state->IsMinimized());
internal::SnapSizer sizer(window, button_pos,
internal::SnapSizer::LEFT_EDGE,
internal::SnapSizer::OTHER_INPUT);
@@ -495,7 +500,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
+ EXPECT_TRUE(wm::GetWindowState(window)->IsNormal());
aura::Window* active =
aura::client::GetFocusClient(window)->GetFocusedWindow();
@@ -548,8 +553,9 @@ TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) {
aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
EXPECT_FALSE(maximize_button->maximizer());
- EXPECT_TRUE(ash::wm::IsWindowNormal(window));
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsNormal());
+ EXPECT_FALSE(window_state->IsMaximized());
// Move the mouse cursor over the button.
generator.MoveMouseTo(button_pos);
@@ -560,7 +566,7 @@ TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) {
generator.PressLeftButton();
RunAllPendingInMessageLoop();
EXPECT_TRUE(maximize_button->is_snap_enabled());
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// Pressing the right button then should cancel the operation.
generator.PressRightButton();
@@ -571,7 +577,7 @@ TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) {
generator.ReleaseRightButton();
generator.ReleaseLeftButton();
RunAllPendingInMessageLoop();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// Second experiment: Starting with right should also not trigger.
generator.MoveMouseTo(off_pos);
@@ -589,7 +595,7 @@ TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) {
EXPECT_FALSE(maximize_button->is_snap_enabled());
generator.ReleaseRightButton();
generator.ReleaseLeftButton();
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
}
// Click a button of window maximize functionality.
@@ -634,8 +640,9 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_LEFT);
+ wm::WindowState* window_state = wm::GetWindowState(window);
// The window should not be maximized.
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
// But the bounds should be different.
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(0, new_bounds.x());
@@ -650,7 +657,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftRestore) {
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Maximize, left/right maximize and then restore should works.
@@ -662,10 +669,12 @@ TEST_F(CustomFrameViewAshTest, MaximizeMaximizeLeftRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ EXPECT_TRUE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(0, new_bounds.x());
EXPECT_EQ(0, new_bounds.y());
@@ -680,7 +689,7 @@ TEST_F(CustomFrameViewAshTest, MaximizeMaximizeLeftRestore) {
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Left/right maximize, maximize and then restore should work.
@@ -692,20 +701,22 @@ TEST_F(CustomFrameViewAshTest, MaximizeLeftMaximizeRestore) {
maximize_button->set_bubble_appearance_delay_ms(0);
ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+
+ wm::WindowState* window_state =wm::GetWindowState(window);
James Cook 2013/09/18 20:44:17 space after =
oshima 2013/09/19 01:52:01 Done.
+ EXPECT_FALSE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(window_state->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(window_state->IsMaximized());
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(new_bounds.x(), initial_bounds.x());
EXPECT_EQ(new_bounds.y(), initial_bounds.x());
EXPECT_EQ(new_bounds.width(), initial_bounds.width());
EXPECT_EQ(new_bounds.height(), initial_bounds.height());
// Make sure that there is no restore rectangle left.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(window_state->HasRestoreBounds());
}
// Starting with a window which has no restore bounds, maximize then left/right
@@ -716,21 +727,23 @@ TEST_F(CustomFrameViewAshTest, MaximizeThenLeftMaximize) {
ash::FrameMaximizeButton* maximize_button =
CustomFrameViewAshTest::maximize_button();
maximize_button->set_bubble_appearance_delay_ms(0);
+
+ wm::WindowState* controller = wm::GetWindowState(window);
James Cook 2013/09/18 20:44:17 optional: controller -> window_state?
oshima 2013/09/19 01:52:01 This test is gone on tot.
// Make sure that there is no restore rectangle.
- EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window));
+ EXPECT_FALSE(controller->HasRestoreBounds());
ClickMaxButton(maximize_button, window, SNAP_NONE);
- EXPECT_TRUE(ash::wm::IsWindowMaximized(window));
+ EXPECT_TRUE(controller->IsMaximized());
ClickMaxButton(maximize_button, window, SNAP_LEFT);
- EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
+ EXPECT_FALSE(controller->IsMaximized());
gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen();
EXPECT_EQ(new_bounds.x(), 0);
EXPECT_EQ(new_bounds.y(), 0);
// Make sure that the restore rectangle is the original rectangle.
EXPECT_EQ(initial_bounds.ToString(),
- GetRestoreBoundsInScreen(window)->ToString());
+ controller->GetRestoreBoundsInScreen().ToString());
}
// Test that minimizing the window per keyboard closes the maximize bubble.
@@ -751,9 +764,10 @@ TEST_F(CustomFrameViewAshTest, MinimizePerKeyClosesBubble) {
EXPECT_TRUE(maximize_button->maximizer());
// We simulate the keystroke by calling minimizeWindow directly.
- wm::MinimizeWindow(window);
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ window_state->Minimize();
- EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
}
@@ -763,9 +777,10 @@ TEST_F(CustomFrameViewAshTest, MaximizeButtonDragDownMinimizes) {
ash::FrameMaximizeButton* maximize_button =
CustomFrameViewAshTest::maximize_button();
+ wm::WindowState* window_state = wm::GetWindowState(window);
// Drag down on a maximized window.
- wm::MaximizeWindow(window);
- EXPECT_TRUE(wm::IsWindowMaximized(window));
+ window_state->Maximize();
+ EXPECT_TRUE(window_state->IsMaximized());
gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
gfx::Point off_pos(button_pos.x(), button_pos.y() + 100);
@@ -773,17 +788,17 @@ TEST_F(CustomFrameViewAshTest, MaximizeButtonDragDownMinimizes) {
generator.GestureScrollSequence(button_pos, off_pos,
base::TimeDelta::FromMilliseconds(0), 1);
- EXPECT_TRUE(wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
// Drag down on a restored window.
- wm::RestoreWindow(window);
+ window_state->Restore();
button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200);
generator.GestureScrollSequence(button_pos, off_pos,
base::TimeDelta::FromMilliseconds(10), 1);
- EXPECT_TRUE(wm::IsWindowMinimized(window));
+ EXPECT_TRUE(window_state->IsMinimized());
EXPECT_FALSE(maximize_button->maximizer());
}

Powered by Google App Engine
This is Rietveld 408576698