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

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

Issue 2542493002: Replace kCanMaximize/Minimize/Resize with kResizeBehavior. (Closed)
Patch Set: Fix int->bool compile issue. Created 4 years 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 (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/common/wm/workspace/workspace_window_resizer.h" 5 #include "ash/common/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/wm/window_positioning_utils.h" 10 #include "ash/common/wm/window_positioning_utils.h"
11 #include "ash/common/wm/window_state.h" 11 #include "ash/common/wm/window_state.h"
12 #include "ash/common/wm/wm_event.h" 12 #include "ash/common/wm/wm_event.h"
13 #include "ash/common/wm/workspace/phantom_window_controller.h" 13 #include "ash/common/wm/workspace/phantom_window_controller.h"
14 #include "ash/common/wm/workspace_controller.h" 14 #include "ash/common/wm/workspace_controller.h"
15 #include "ash/public/cpp/shell_window_ids.h" 15 #include "ash/public/cpp/shell_window_ids.h"
16 #include "ash/screen_util.h" 16 #include "ash/screen_util.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/test/ash_md_test_base.h" 18 #include "ash/test/ash_md_test_base.h"
19 #include "ash/wm/window_state_aura.h" 19 #include "ash/wm/window_state_aura.h"
20 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
24 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/test/test_window_delegate.h" 26 #include "ui/aura/test/test_window_delegate.h"
26 #include "ui/aura/window_event_dispatcher.h" 27 #include "ui/aura/window_event_dispatcher.h"
27 #include "ui/base/hit_test.h" 28 #include "ui/base/hit_test.h"
28 #include "ui/display/manager/display_layout.h" 29 #include "ui/display/manager/display_layout.h"
29 #include "ui/display/manager/display_manager.h" 30 #include "ui/display/manager/display_manager.h"
30 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
31 #include "ui/display/test/display_manager_test_api.h" 32 #include "ui/display/test/display_manager_test_api.h"
32 #include "ui/events/gesture_detection/gesture_configuration.h" 33 #include "ui/events/gesture_detection/gesture_configuration.h"
33 #include "ui/events/test/event_generator.h" 34 #include "ui/events/test/event_generator.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 } 545 }
545 546
546 // Assertions around dragging to the left/right edge of the screen. 547 // Assertions around dragging to the left/right edge of the screen.
547 TEST_P(WorkspaceWindowResizerTest, Edge) { 548 TEST_P(WorkspaceWindowResizerTest, Edge) {
548 // Resize host window to force insets update. 549 // Resize host window to force insets update.
549 UpdateDisplay("800x700"); 550 UpdateDisplay("800x700");
550 // TODO(varkha): Insets are reset after every drag because of 551 // TODO(varkha): Insets are reset after every drag because of
551 // http://crbug.com/292238. 552 // http://crbug.com/292238.
552 // Window is wide enough not to get docked right away. 553 // Window is wide enough not to get docked right away.
553 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 554 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
554 window_->SetProperty(aura::client::kCanMaximizeKey, true); 555 window_->SetProperty(aura::client::kResizeBehaviorKey,
556 ui::mojom::kResizeBehaviorCanResize |
557 ui::mojom::kResizeBehaviorCanMaximize);
555 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 558 wm::WindowState* window_state = wm::GetWindowState(window_.get());
556 559
557 { 560 {
558 gfx::Rect expected_bounds_in_parent( 561 gfx::Rect expected_bounds_in_parent(
559 wm::GetDefaultLeftSnappedWindowBoundsInParent( 562 wm::GetDefaultLeftSnappedWindowBoundsInParent(
560 WmWindowAura::Get(window_.get()))); 563 WmWindowAura::Get(window_.get())));
561 564
562 std::unique_ptr<WindowResizer> resizer( 565 std::unique_ptr<WindowResizer> resizer(
563 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 566 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
564 ASSERT_TRUE(resizer.get()); 567 ASSERT_TRUE(resizer.get());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), 622 EXPECT_EQ("250,0 250x" + base::IntToString(bottom),
620 window_->bounds().ToString()); 623 window_->bounds().ToString());
621 EXPECT_EQ("800,10 400x60", 624 EXPECT_EQ("800,10 400x60",
622 window_state->GetRestoreBoundsInScreen().ToString()); 625 window_state->GetRestoreBoundsInScreen().ToString());
623 } 626 }
624 } 627 }
625 628
626 // Check that non resizable windows will not get resized. 629 // Check that non resizable windows will not get resized.
627 TEST_P(WorkspaceWindowResizerTest, NonResizableWindows) { 630 TEST_P(WorkspaceWindowResizerTest, NonResizableWindows) {
628 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); 631 window_->SetBounds(gfx::Rect(20, 30, 50, 60));
629 window_->SetProperty(aura::client::kCanResizeKey, false); 632 window_->SetProperty(aura::client::kResizeBehaviorKey,
633 ui::mojom::kResizeBehaviorNone);
630 634
631 std::unique_ptr<WindowResizer> resizer( 635 std::unique_ptr<WindowResizer> resizer(
632 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 636 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
633 ASSERT_TRUE(resizer.get()); 637 ASSERT_TRUE(resizer.get());
634 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); 638 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0);
635 resizer->CompleteDrag(); 639 resizer->CompleteDrag();
636 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); 640 EXPECT_EQ("0,30 50x60", window_->bounds().ToString());
637 } 641 }
638 642
639 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) { 643 TEST_P(WorkspaceWindowResizerTest, CancelSnapPhantom) {
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1436 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1433 window2_->Show(); 1437 window2_->Show();
1434 1438
1435 std::unique_ptr<WindowResizer> resizer( 1439 std::unique_ptr<WindowResizer> resizer(
1436 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT)); 1440 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT));
1437 ASSERT_TRUE(resizer.get()); 1441 ASSERT_TRUE(resizer.get());
1438 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1442 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1439 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); 1443 EXPECT_EQ("99,200 21x30", window_->bounds().ToString());
1440 } 1444 }
1441 1445
1442 // Test that the user user moved window flag is getting properly set. 1446 // Test that the user moved window flag is getting properly set.
1443 TEST_P(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { 1447 TEST_P(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) {
1444 window_->SetBounds(gfx::Rect(0, 50, 400, 200)); 1448 window_->SetBounds(gfx::Rect(0, 50, 400, 200));
1445 window_->SetProperty(aura::client::kCanMaximizeKey, true); 1449 window_->SetProperty(aura::client::kResizeBehaviorKey,
1450 ui::mojom::kResizeBehaviorCanMaximize);
1446 1451
1447 std::vector<aura::Window*> no_attached_windows; 1452 std::vector<aura::Window*> no_attached_windows;
1448 // Check that an abort doesn't change anything. 1453 // Check that an abort doesn't change anything.
1449 { 1454 {
1450 std::unique_ptr<WindowResizer> resizer( 1455 std::unique_ptr<WindowResizer> resizer(
1451 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION)); 1456 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1452 ASSERT_TRUE(resizer.get()); 1457 ASSERT_TRUE(resizer.get());
1453 // Move it 100 to the bottom. 1458 // Move it 100 to the bottom.
1454 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); 1459 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
1455 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); 1460 EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 touch_resize_window_->bounds().ToString()); 1886 touch_resize_window_->bounds().ToString());
1882 // Drag even more to snap to the edge. 1887 // Drag even more to snap to the edge.
1883 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1888 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1884 gfx::Point(400, kRootHeight - 25), 1889 gfx::Point(400, kRootHeight - 25),
1885 base::TimeDelta::FromMilliseconds(10), 5); 1890 base::TimeDelta::FromMilliseconds(10), 5);
1886 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1891 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1887 touch_resize_window_->bounds().ToString()); 1892 touch_resize_window_->bounds().ToString());
1888 } 1893 }
1889 1894
1890 } // namespace ash 1895 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_event_handler_unittest.cc ('k') | chrome/browser/chromeos/login/ui/login_web_dialog_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698