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

Side by Side Diff: ash/wm/window_state_unittest.cc

Issue 557693002: [Ash] Only snap windows that can maximize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/window_state.h" 5 #include "ash/wm/window_state.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/wm_event.h" 11 #include "ash/wm/wm_event.h"
12 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/test/test_window_delegate.h" 13 #include "ui/aura/test/test_window_delegate.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 15
15 namespace ash { 16 namespace ash {
16 namespace wm { 17 namespace wm {
17 namespace { 18 namespace {
18 19
19 class AlwaysMaximizeTestState : public WindowState::State { 20 class AlwaysMaximizeTestState : public WindowState::State {
20 public: 21 public:
21 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type) 22 explicit AlwaysMaximizeTestState(WindowStateType initial_state_type)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 EXPECT_TRUE(window_state->CanSnap()); 119 EXPECT_TRUE(window_state->CanSnap());
119 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT); 120 const WMEvent snap_right(WM_EVENT_SNAP_RIGHT);
120 window_state->OnWMEvent(&snap_right); 121 window_state->OnWMEvent(&snap_right);
121 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1, 122 gfx::Rect expected = gfx::Rect(kWorkAreaBounds.x() + 1,
122 kWorkAreaBounds.y(), 123 kWorkAreaBounds.y(),
123 kWorkAreaBounds.width() - 1, 124 kWorkAreaBounds.width() - 1,
124 kWorkAreaBounds.height()); 125 kWorkAreaBounds.height());
125 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString()); 126 EXPECT_EQ(expected.ToString(), window->GetBoundsInScreen().ToString());
126 127
127 // It should not be possible to snap a window with a maximum size. 128 // It should not be possible to snap a window with a maximum size.
128 delegate.set_minimum_size(gfx::Size()); 129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0));
129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX)); 130 EXPECT_FALSE(window_state->CanSnap());
131 delegate.set_maximum_size(gfx::Size(0, kWorkAreaBounds.height() - 1));
130 EXPECT_FALSE(window_state->CanSnap()); 132 EXPECT_FALSE(window_state->CanSnap());
oshima 2014/09/11 01:00:05 I probably wasn't clear, sorry: You should also t
jackhou1 2014/09/11 01:52:43 Done.
131 } 133 }
132 134
133 // Test that the minimum size specified by aura::WindowDelegate gets respected. 135 // Test that the minimum size specified by aura::WindowDelegate gets respected.
134 TEST_F(WindowStateTest, TestRespectMinimumSize) { 136 TEST_F(WindowStateTest, TestRespectMinimumSize) {
135 if (!SupportsHostWindowResize()) 137 if (!SupportsHostWindowResize())
136 return; 138 return;
137 139
138 UpdateDisplay("0+0-1024x768"); 140 UpdateDisplay("0+0-1024x768");
139 141
140 aura::test::TestWindowDelegate delegate; 142 aura::test::TestWindowDelegate delegate;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EXPECT_FALSE(window_state->IsMaximized()); 332 EXPECT_FALSE(window_state->IsMaximized());
331 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); 333 EXPECT_NE(work_area.ToString(), window->bounds().ToString());
332 EXPECT_TRUE(work_area.Contains(window->bounds())); 334 EXPECT_TRUE(work_area.Contains(window->bounds()));
333 } 335 }
334 336
335 // TODO(skuhne): Add more unit test to verify the correctness for the restore 337 // TODO(skuhne): Add more unit test to verify the correctness for the restore
336 // operation. 338 // operation.
337 339
338 } // namespace wm 340 } // namespace wm
339 } // namespace ash 341 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698