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

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

Issue 10910164: Removes the grid from ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ShelfBrowserTest Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/base_layout_manager_unittest.cc ('k') | ash/wm/default_window_resizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/custom_frame_view_ash.h" 5 #include "ash/wm/custom_frame_view_ash.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/maximize_bubble_controller.h" 9 #include "ash/wm/maximize_bubble_controller.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 // Tests that click+dragging on the resize-button tiles or minimizes the window. 152 // Tests that click+dragging on the resize-button tiles or minimizes the window.
153 TEST_F(CustomFrameViewAshTest, ResizeButtonDrag) { 153 TEST_F(CustomFrameViewAshTest, ResizeButtonDrag) {
154 views::Widget* widget = CreateWidget(); 154 views::Widget* widget = CreateWidget();
155 aura::Window* window = widget->GetNativeWindow(); 155 aura::Window* window = widget->GetNativeWindow();
156 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); 156 CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
157 CustomFrameViewAsh::TestApi test(frame); 157 CustomFrameViewAsh::TestApi test(frame);
158 views::View* view = test.maximize_button(); 158 views::View* view = test.maximize_button();
159 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); 159 gfx::Point center = view->GetBoundsInScreen().CenterPoint();
160 const int kGridSize = ash::Shell::GetInstance()->GetGridSize();
161 160
162 aura::test::EventGenerator generator(window->GetRootWindow(), center); 161 aura::test::EventGenerator generator(window->GetRootWindow(), center);
163 162
164 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); 163 EXPECT_TRUE(ash::wm::IsWindowNormal(window));
165 164
166 // Snap right. 165 // Snap right.
167 { 166 {
168 generator.PressLeftButton(); 167 generator.PressLeftButton();
169 generator.MoveMouseBy(10, 0); 168 generator.MoveMouseBy(10, 0);
170 generator.ReleaseLeftButton(); 169 generator.ReleaseLeftButton();
171 RunAllPendingInMessageLoop(); 170 RunAllPendingInMessageLoop();
172 171
173 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 172 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
174 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 173 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
175 internal::SnapSizer sizer(window, center, 174 internal::SnapSizer sizer(window, center,
176 internal::SnapSizer::RIGHT_EDGE, kGridSize); 175 internal::SnapSizer::RIGHT_EDGE);
177 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 176 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
178 } 177 }
179 178
180 // Snap left. 179 // Snap left.
181 { 180 {
182 center = view->GetBoundsInScreen().CenterPoint(); 181 center = view->GetBoundsInScreen().CenterPoint();
183 generator.MoveMouseTo(center); 182 generator.MoveMouseTo(center);
184 generator.PressLeftButton(); 183 generator.PressLeftButton();
185 generator.MoveMouseBy(-10, 0); 184 generator.MoveMouseBy(-10, 0);
186 generator.ReleaseLeftButton(); 185 generator.ReleaseLeftButton();
187 RunAllPendingInMessageLoop(); 186 RunAllPendingInMessageLoop();
188 187
189 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 188 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
190 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 189 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
191 internal::SnapSizer sizer(window, center, 190 internal::SnapSizer sizer(window, center,
192 internal::SnapSizer::LEFT_EDGE, kGridSize); 191 internal::SnapSizer::LEFT_EDGE);
193 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 192 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
194 } 193 }
195 194
196 // Minimize. 195 // Minimize.
197 { 196 {
198 center = view->GetBoundsInScreen().CenterPoint(); 197 center = view->GetBoundsInScreen().CenterPoint();
199 generator.MoveMouseTo(center); 198 generator.MoveMouseTo(center);
200 generator.PressLeftButton(); 199 generator.PressLeftButton();
201 generator.MoveMouseBy(0, 10); 200 generator.MoveMouseBy(0, 10);
202 generator.ReleaseLeftButton(); 201 generator.ReleaseLeftButton();
(...skipping 12 matching lines...) Expand all
215 gfx::Point end = center; 214 gfx::Point end = center;
216 end.Offset(40, 0); 215 end.Offset(40, 0);
217 generator.GestureScrollSequence(center, end, 216 generator.GestureScrollSequence(center, end,
218 base::TimeDelta::FromMilliseconds(100), 217 base::TimeDelta::FromMilliseconds(100),
219 3); 218 3);
220 RunAllPendingInMessageLoop(); 219 RunAllPendingInMessageLoop();
221 220
222 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 221 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
223 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 222 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
224 internal::SnapSizer sizer(window, center, 223 internal::SnapSizer sizer(window, center,
225 internal::SnapSizer::RIGHT_EDGE, kGridSize); 224 internal::SnapSizer::RIGHT_EDGE);
226 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 225 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
227 } 226 }
228 227
229 // Snap left. 228 // Snap left.
230 { 229 {
231 center = view->GetBoundsInScreen().CenterPoint(); 230 center = view->GetBoundsInScreen().CenterPoint();
232 gfx::Point end = center; 231 gfx::Point end = center;
233 end.Offset(-40, 0); 232 end.Offset(-40, 0);
234 generator.GestureScrollSequence(center, end, 233 generator.GestureScrollSequence(center, end,
235 base::TimeDelta::FromMilliseconds(100), 234 base::TimeDelta::FromMilliseconds(100),
236 3); 235 3);
237 RunAllPendingInMessageLoop(); 236 RunAllPendingInMessageLoop();
238 237
239 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 238 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
240 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 239 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
241 internal::SnapSizer sizer(window, center, 240 internal::SnapSizer sizer(window, center,
242 internal::SnapSizer::LEFT_EDGE, kGridSize); 241 internal::SnapSizer::LEFT_EDGE);
243 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 242 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
244 } 243 }
245 244
246 // Minimize. 245 // Minimize.
247 { 246 {
248 center = view->GetBoundsInScreen().CenterPoint(); 247 center = view->GetBoundsInScreen().CenterPoint();
249 gfx::Point end = center; 248 gfx::Point end = center;
250 end.Offset(0, 40); 249 end.Offset(0, 40);
251 generator.GestureScrollSequence(center, end, 250 generator.GestureScrollSequence(center, end,
252 base::TimeDelta::FromMilliseconds(100), 251 base::TimeDelta::FromMilliseconds(100),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 generator.MoveMouseTo(off_pos); 331 generator.MoveMouseTo(off_pos);
333 generator.ReleaseLeftButton(); 332 generator.ReleaseLeftButton();
334 333
335 // Check that the phantom window is also gone. 334 // Check that the phantom window is also gone.
336 EXPECT_FALSE(maximize_button->phantom_window_open()); 335 EXPECT_FALSE(maximize_button->phantom_window_open());
337 } 336 }
338 337
339 // Test that clicking a button in the maximizer bubble (in this case the 338 // Test that clicking a button in the maximizer bubble (in this case the
340 // maximize left button) will do the requested action. 339 // maximize left button) will do the requested action.
341 TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) { 340 TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) {
342 const int kGridSize = ash::Shell::GetInstance()->GetGridSize();
343 views::Widget* widget = CreateWidget(); 341 views::Widget* widget = CreateWidget();
344 aura::Window* window = widget->GetNativeWindow(); 342 aura::Window* window = widget->GetNativeWindow();
345 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); 343 CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
346 CustomFrameViewAsh::TestApi test(frame); 344 CustomFrameViewAsh::TestApi test(frame);
347 ash::FrameMaximizeButton* maximize_button = test.maximize_button(); 345 ash::FrameMaximizeButton* maximize_button = test.maximize_button();
348 maximize_button->set_bubble_appearance_delay_ms(0); 346 maximize_button->set_bubble_appearance_delay_ms(0);
349 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 347 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
350 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 348 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
351 349
352 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 350 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
(...skipping 11 matching lines...) Expand all
364 generator.MoveMouseTo(left_max_pos); 362 generator.MoveMouseTo(left_max_pos);
365 EXPECT_TRUE(maximize_button->phantom_window_open()); 363 EXPECT_TRUE(maximize_button->phantom_window_open());
366 generator.ClickLeftButton(); 364 generator.ClickLeftButton();
367 365
368 EXPECT_FALSE(maximize_button->maximizer()); 366 EXPECT_FALSE(maximize_button->maximizer());
369 EXPECT_FALSE(maximize_button->phantom_window_open()); 367 EXPECT_FALSE(maximize_button->phantom_window_open());
370 368
371 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); 369 EXPECT_FALSE(ash::wm::IsWindowMaximized(window));
372 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); 370 EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
373 internal::SnapSizer sizer(window, button_pos, 371 internal::SnapSizer sizer(window, button_pos,
374 internal::SnapSizer::LEFT_EDGE, kGridSize); 372 internal::SnapSizer::LEFT_EDGE);
375 sizer.SelectDefaultSizeAndDisableResize(); 373 sizer.SelectDefaultSizeAndDisableResize();
376 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); 374 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString());
377 } 375 }
378 376
379 // Test that the activation focus does not change when the bubble gets shown. 377 // Test that the activation focus does not change when the bubble gets shown.
380 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { 378 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) {
381 views::Widget* widget = CreateWidget(); 379 views::Widget* widget = CreateWidget();
382 aura::Window* window = widget->GetNativeWindow(); 380 aura::Window* window = widget->GetNativeWindow();
383 CustomFrameViewAsh* frame = custom_frame_view_ash(widget); 381 CustomFrameViewAsh* frame = custom_frame_view_ash(widget);
384 CustomFrameViewAsh::TestApi test(frame); 382 CustomFrameViewAsh::TestApi test(frame);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); 603 EXPECT_EQ(new_bounds.x(), initial_bounds.x());
606 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); 604 EXPECT_EQ(new_bounds.y(), initial_bounds.x());
607 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); 605 EXPECT_EQ(new_bounds.width(), initial_bounds.width());
608 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); 606 EXPECT_EQ(new_bounds.height(), initial_bounds.height());
609 // Make sure that there is no restore rectangle left. 607 // Make sure that there is no restore rectangle left.
610 EXPECT_EQ(NULL, window->GetProperty(aura::client::kRestoreBoundsKey)); 608 EXPECT_EQ(NULL, window->GetProperty(aura::client::kRestoreBoundsKey));
611 } 609 }
612 610
613 } // namespace internal 611 } // namespace internal
614 } // namespace ash 612 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/base_layout_manager_unittest.cc ('k') | ash/wm/default_window_resizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698