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

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

Issue 46893003: Undock window when reverting a drag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undock window when reverting a drag Created 7 years, 1 month 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
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | no next file » | 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) 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/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/launcher/launcher_model.h" 9 #include "ash/launcher/launcher_model.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), 556 EXPECT_EQ(w1->GetRootWindow()->bounds().right(),
557 w1->GetBoundsInScreen().right()); 557 w1->GetBoundsInScreen().right());
558 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id()); 558 EXPECT_EQ(internal::kShellWindowId_DockedContainer, w1->parent()->id());
559 559
560 // The second window should be near the left edge but not snapped. 560 // The second window should be near the left edge but not snapped.
561 // Normal window will get side-maximized while panels will not. 561 // Normal window will get side-maximized while panels will not.
562 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x()); 562 EXPECT_EQ(w2->GetRootWindow()->bounds().x(), w2->GetBoundsInScreen().x());
563 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); 563 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id());
564 } 564 }
565 565
566 // Reverting drag 566 // Tests that reverting a drag restores docked state if a window was docked.
567 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) { 567 TEST_P(DockedWindowResizerTest, RevertDragRestoresAttachment) {
568 if (!SupportsHostWindowResize()) 568 if (!SupportsHostWindowResize())
569 return; 569 return;
570 570
571 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 571 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
572 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); 572 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0);
573 573
574 // The window should be attached and snapped to the right edge. 574 // The window should be attached and snapped to the right edge.
575 EXPECT_EQ(window->GetRootWindow()->bounds().right(), 575 EXPECT_EQ(window->GetRootWindow()->bounds().right(),
576 window->GetBoundsInScreen().right()); 576 window->GetBoundsInScreen().right());
577 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 577 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
578 578
579 // Drag the window out but revert the drag 579 // Drag the window out but revert the drag
580 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 580 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
581 DragMove(-50, 0); 581 DragMove(-50, 0);
582 DragRevert(); 582 DragRevert();
583 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id()); 583 EXPECT_EQ(internal::kShellWindowId_DockedContainer, window->parent()->id());
584 584
585 // Detach window. 585 // Detach window.
586 ASSERT_NO_FATAL_FAILURE(DragStart(window.get())); 586 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
587 DragMove(-50, 0); 587 DragMove(-50, 0);
588 DragEnd(); 588 DragEnd();
589 EXPECT_EQ(internal::kShellWindowId_DefaultContainer, 589 EXPECT_EQ(internal::kShellWindowId_DefaultContainer,
590 window->parent()->id()); 590 window->parent()->id());
591 } 591 }
592 592
593 // Tests that reverting drag restores undocked state if a window was not docked.
594 TEST_P(DockedWindowResizerTest, RevertDockedDragRevertsAttachment) {
595 if (!SupportsHostWindowResize())
596 return;
597 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
598 int previous_container_id = window->parent()->id();
599 // Drag the window out but revert the drag
600 ASSERT_NO_FATAL_FAILURE(DragStart(window.get()));
601 DragMove(-50 - window->bounds().x(), 50 - window->bounds().y());
602 EXPECT_EQ(CorrectContainerIdDuringDrag(), window->parent()->id());
603 DragRevert();
604 EXPECT_EQ(previous_container_id, window->parent()->id());
605 }
606
593 // Move a docked window to the second display 607 // Move a docked window to the second display
594 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) { 608 TEST_P(DockedWindowResizerTest, DragAcrossDisplays) {
595 if (!SupportsMultipleDisplays()) 609 if (!SupportsMultipleDisplays())
596 return; 610 return;
597 611
598 UpdateDisplay("800x800,800x800"); 612 UpdateDisplay("800x800,800x800");
599 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 613 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
600 EXPECT_EQ(2, static_cast<int>(root_windows.size())); 614 EXPECT_EQ(2, static_cast<int>(root_windows.size()));
601 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); 615 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(0, 0, 201, 201)));
602 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 616 gfx::Rect initial_bounds = window->GetBoundsInScreen();
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 child->GetBoundsInScreen().origin().ToString()); 1167 child->GetBoundsInScreen().origin().ToString());
1154 } 1168 }
1155 1169
1156 // Tests run twice - on both panels and normal windows 1170 // Tests run twice - on both panels and normal windows
1157 INSTANTIATE_TEST_CASE_P(NormalOrPanel, 1171 INSTANTIATE_TEST_CASE_P(NormalOrPanel,
1158 DockedWindowResizerTest, 1172 DockedWindowResizerTest,
1159 testing::Values(aura::client::WINDOW_TYPE_NORMAL, 1173 testing::Values(aura::client::WINDOW_TYPE_NORMAL,
1160 aura::client::WINDOW_TYPE_PANEL)); 1174 aura::client::WINDOW_TYPE_PANEL));
1161 } // namespace internal 1175 } // namespace internal
1162 } // namespace ash 1176 } // namespace ash
OLDNEW
« no previous file with comments | « 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