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

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: Change ash_test_base.cc 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 WindowState* window_state = GetWindowState(window.get()); 118 WindowState* window_state = GetWindowState(window.get());
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, or if it
128 delegate.set_minimum_size(gfx::Size()); 129 // cannot be maximized.
129 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, INT_MAX)); 130 delegate.set_maximum_size(gfx::Size(kWorkAreaBounds.width() - 1, 0));
131 EXPECT_FALSE(window_state->CanSnap());
132 delegate.set_maximum_size(gfx::Size(0, kWorkAreaBounds.height() - 1));
133 EXPECT_FALSE(window_state->CanSnap());
134 delegate.set_maximum_size(gfx::Size());
135 window->SetProperty(aura::client::kCanMaximizeKey, false);
130 EXPECT_FALSE(window_state->CanSnap()); 136 EXPECT_FALSE(window_state->CanSnap());
131 } 137 }
132 138
133 // Test that the minimum size specified by aura::WindowDelegate gets respected. 139 // Test that the minimum size specified by aura::WindowDelegate gets respected.
134 TEST_F(WindowStateTest, TestRespectMinimumSize) { 140 TEST_F(WindowStateTest, TestRespectMinimumSize) {
135 if (!SupportsHostWindowResize()) 141 if (!SupportsHostWindowResize())
136 return; 142 return;
137 143
138 UpdateDisplay("0+0-1024x768"); 144 UpdateDisplay("0+0-1024x768");
139 145
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EXPECT_FALSE(window_state->IsMaximized()); 336 EXPECT_FALSE(window_state->IsMaximized());
331 EXPECT_NE(work_area.ToString(), window->bounds().ToString()); 337 EXPECT_NE(work_area.ToString(), window->bounds().ToString());
332 EXPECT_TRUE(work_area.Contains(window->bounds())); 338 EXPECT_TRUE(work_area.Contains(window->bounds()));
333 } 339 }
334 340
335 // TODO(skuhne): Add more unit test to verify the correctness for the restore 341 // TODO(skuhne): Add more unit test to verify the correctness for the restore
336 // operation. 342 // operation.
337 343
338 } // namespace wm 344 } // namespace wm
339 } // namespace ash 345 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698