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

Side by Side Diff: ash/wm/dock/docked_window_resizer_unittest.cc

Issue 141053002: Avoids updating dock alignment when drag is cancelled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoids updating dock alignment when drag is cancelled (test) Created 6 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/dock/docked_window_resizer.h" 5 #include "ash/wm/dock/docked_window_resizer.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 DragEnd(); 617 DragEnd();
618 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 618 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
619 window->parent()->id()); 619 window->parent()->id());
620 } 620 }
621 621
622 // Tests that reverting drag restores undocked state if a window was not docked. 622 // Tests that reverting drag restores undocked state if a window was not docked.
623 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) { 623 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
624 if (!SupportsHostWindowResize()) 624 if (!SupportsHostWindowResize())
625 return; 625 return;
626 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 626 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
627 aura::Window* dock_container = Shell::GetContainer(
628 window->GetRootWindow(),
629 kShellWindowId_DockedContainer);
630 DockedWindowLayoutManager* manager =
631 static_cast<DockedWindowLayoutManager*>(dock_container->layout_manager());
627 int previous_container_id = window->parent()->id(); 632 int previous_container_id = window->parent()->id();
628 // Drag the window out but revert the drag 633 // Drag the window out but revert the drag
629 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 634 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
630 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y()); 635 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y());
631 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id()); 636 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
632 DragRevert(); 637 DragRevert();
633 EXPECT_EQ(previous_container_id, window->parent()->id()); 638 EXPECT_EQ(previous_container_id, window->parent()->id());
639 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
640
641 // Drag a window to the left so that it overlaps the screen edge.
642 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
643 window.get(),
644 window->bounds().width()/2 + 10,
645 0));
646 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y());
647 DragEnd();
648 // The window now overlaps the left screen edge but is not docked.
649 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
650 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
pkotwicz 2014/01/16 21:43:27 Nit: It may be useful to test that the window is a
varkha 2014/01/16 23:34:14 Done.
651
652 // Drag the window further left and revert the drag.
653 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromWindowOrigin(
654 window.get(),
655 window->bounds().width()/2 + 10,
656 0));
657 DragMove(-10, 10);
658 DragRevert();
659 // The window should be in default container and not docked.
660 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
661 // Docked area alignment should be cleared.
662 EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager));
634 } 663 }
635 664
636 // Move a docked window to the second display 665 // Move a docked window to the second display
637 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { 666 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
638 if (!SupportsMultipleDisplays()) 667 if (!SupportsMultipleDisplays())
639 return; 668 return;
640 669
641 UpdateDisplay("800x800,800x800"); 670 UpdateDisplay("800x800,800x800");
642 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 671 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
643 EXPECT_EQ(2, static_cast<int>(root_windows.size())); 672 EXPECT_EQ(2, static_cast<int>(root_windows.size()));
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 EXPECT_TRUE(window_state->IsSnapped()); 1513 EXPECT_TRUE(window_state->IsSnapped());
1485 } 1514 }
1486 1515
1487 // Tests run twice - on both panels and normal windows 1516 // Tests run twice - on both panels and normal windows
1488 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1517 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1489 DockedWindowResizerTest, 1518 DockedWindowResizerTest,
1490 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, 1519 testing::Values(ui::wm::WINDOW_TYPE_NORMAL,
1491 ui::wm::WINDOW_TYPE_PANEL)); 1520 ui::wm::WINDOW_TYPE_PANEL));
1492 } // namespace internal 1521 } // namespace internal
1493 } // namespace ash 1522 } // namespace ash
OLDNEW
« ash/wm/dock/docked_window_layout_manager.cc ('K') | « ash/wm/dock/docked_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698