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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 424463002: Makes a window that has been resized to maximized bounds, then maximized and then restored shrink (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Maximizes a window that has been resized to maximized bounds (added a test) Created 6 years, 4 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
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/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); 413 EXPECT_EQ("0,50 400x300", window_->bounds().ToString());
414 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); 414 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString());
415 415
416 // Revert and make sure everything moves back. 416 // Revert and make sure everything moves back.
417 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); 417 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0);
418 resizer->RevertDrag(); 418 resizer->RevertDrag();
419 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); 419 EXPECT_EQ("0,50 400x200", window_->bounds().ToString());
420 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); 420 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString());
421 } 421 }
422 422
423 // Tests that resizing a window to maximized bounds (or even close to them with
424 // magnetism) maximizes the window.
425 TEST_F(WorkspaceWindowResizerTest, WindowResizedToMaximizedBoundsIsMaximized) {
426 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
427 window_->SetProperty(aura::client::kCanMaximizeKey, true);
428 {
429 // Resize |window_| to fit top left corner. Magnetism will adjust it to fit
430 // the corner exactly.
431 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
432 window_.get(), gfx::Point(), HTTOPLEFT));
433 ASSERT_TRUE(resizer.get());
434 resizer->Drag(CalculateDragPoint(*resizer, -100 + 2, -200 + 2), 0);
435 resizer->CompleteDrag();
436 }
437 gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(
438 window_.get());
439 {
440 // Resize |window_| to fit bottom right corner. Magnetism will adjust it to
441 // fit the corner exactly.
442 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
443 window_.get(), gfx::Point(), HTBOTTOMRIGHT));
444 ASSERT_TRUE(resizer.get());
445 gfx::Rect bounds = window_->bounds();
446 resizer->Drag(
447 CalculateDragPoint(*resizer,
448 maximized_bounds.right() - bounds.right() - 2,
449 maximized_bounds.bottom() - bounds.bottom() - 2), 0);
450 resizer->CompleteDrag();
451 }
452 // The window should be maximized and should have restore bounds set to its
453 // previous bounds.
454 EXPECT_EQ(maximized_bounds.ToString(), window_->bounds().ToString());
455 wm::WindowState* window_state = wm::GetWindowState(window_.get());
456 EXPECT_TRUE(window_state->IsMaximized());
457 ASSERT_TRUE(window_state->HasRestoreBounds());
458 EXPECT_EQ("0,0 120x230", window_state->GetRestoreBoundsInScreen().ToString());
459 }
460
461 // Tests that dragging a window that has maximized size to top left screen
462 // corner maximizes the window.
463 TEST_F(WorkspaceWindowResizerTest, WindowDraggedToMaximizedBoundsIsMaximized) {
464 // Force an initial layout.
465 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
466 LayoutShelf();
467 gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(
468 window_.get());
469 window_->SetBounds(gfx::Rect(gfx::Point(20, 30), maximized_bounds.size()));
470 window_->SetProperty(aura::client::kCanMaximizeKey, true);
471 // Grab a window and drag it to the top left corner. Do not grab too close to
472 // the window origin to avoid snapping.
473 scoped_ptr<WindowResizer> resizer(CreateResizerForTest(
474 window_.get(), gfx::Point(40, 5), HTCAPTION));
475 ASSERT_TRUE(resizer.get());
476 resizer->Drag(CalculateDragPoint(*resizer, -20, -30), 0);
477 resizer->CompleteDrag();
478
479 // The window should be maximized and should have restore bounds set to its
480 // previous bounds.
481 EXPECT_EQ(maximized_bounds.ToString(), window_->bounds().ToString());
482 wm::WindowState* window_state = wm::GetWindowState(window_.get());
483 EXPECT_TRUE(window_state->IsMaximized());
484 ASSERT_TRUE(window_state->HasRestoreBounds());
485 EXPECT_EQ("20,30 " + maximized_bounds.size().ToString(),
486 window_state->GetRestoreBoundsInScreen().ToString());
487 }
488
423 #if defined(OS_WIN) 489 #if defined(OS_WIN)
424 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 490 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
425 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3 491 #define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3
426 #else 492 #else
427 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3 493 #define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3
428 #endif 494 #endif
429 495
430 // Assertions around attached window resize dragging from the bottom with 3 496 // Assertions around attached window resize dragging from the bottom with 3
431 // windows. 497 // windows.
432 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) { 498 TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) {
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 // Drag even more to snap to the edge. 1928 // Drag even more to snap to the edge.
1863 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1929 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1864 gfx::Point(400, kRootHeight - 25), 1930 gfx::Point(400, kRootHeight - 25),
1865 base::TimeDelta::FromMilliseconds(10), 1931 base::TimeDelta::FromMilliseconds(10),
1866 5); 1932 5);
1867 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1933 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1868 touch_resize_window_->bounds().ToString()); 1934 touch_resize_window_->bounds().ToString());
1869 } 1935 }
1870 1936
1871 } // namespace ash 1937 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698