summaryrefslogtreecommitdiffstats
path: root/ash/extended_desktop_unittest.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-21 14:27:57 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-21 14:27:57 +0000
commitf059c6946d6c3a29e8d7fc7435ec16a33110eefa (patch)
tree9021517ace5019264959b0ad836845c2d38de2bc /ash/extended_desktop_unittest.cc
parentf6988625efcda9a87181724c0d108928b3c35fb1 (diff)
downloadchromium_src-f059c6946d6c3a29e8d7fc7435ec16a33110eefa.zip
chromium_src-f059c6946d6c3a29e8d7fc7435ec16a33110eefa.tar.gz
chromium_src-f059c6946d6c3a29e8d7fc7435ec16a33110eefa.tar.bz2
Move a window if the sceren bounds being set is in other display.
- Fix StackingController::GetDefaultParent so that it uses the same root window as its transient parent. - Updated WorkspaceWindowResizer to move the dragged window to other display if the new destination matches it. This is short term, temporary solution until better drag&drop is implemented. BUG=123160 TEST=ExtendedDesktopTest.MoveWindow/MoveWindowWithTransient Review URL: https://chromiumcodereview.appspot.com/10795027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/extended_desktop_unittest.cc')
-rw-r--r--ash/extended_desktop_unittest.cc103
1 files changed, 102 insertions, 1 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index d4cce05..179055e 100644
--- a/ash/extended_desktop_unittest.cc
+++ b/ash/extended_desktop_unittest.cc
@@ -24,15 +24,23 @@
namespace ash {
namespace {
-views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
+views::Widget* CreateTestWidgetWithParent(views::Widget* parent,
+ const gfx::Rect& bounds,
+ bool child) {
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.parent_widget = parent;
params.bounds = bounds;
+ params.child = child;
views::Widget* widget = new views::Widget;
widget->Init(params);
widget->Show();
return widget;
}
+views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
+ return CreateTestWidgetWithParent(NULL, bounds, false);
+}
+
class ModalWidgetDelegate : public views::WidgetDelegateView {
public:
ModalWidgetDelegate() {}
@@ -345,6 +353,99 @@ TEST_F(ExtendedDesktopTest, Capture) {
EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
}
+TEST_F(ExtendedDesktopTest, MoveWindow) {
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
+ UpdateDisplay("0+0-1000x600,1001+0-600x400");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
+
+ EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
+
+ d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
+ EXPECT_EQ("1010,10 100x100",
+ d1->GetWindowBoundsInScreen().ToString());
+
+ EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
+
+ d1->SetBounds(gfx::Rect(10, 10, 100, 100));
+ EXPECT_EQ("10,10 100x100",
+ d1->GetWindowBoundsInScreen().ToString());
+
+ EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
+
+ // Make sure the bounds which doesn't fit to the root window
+ // works correctly.
+ d1->SetBounds(gfx::Rect(1560, 30, 100, 100));
+ EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ("1560,30 100x100",
+ d1->GetWindowBoundsInScreen().ToString());
+
+ // Setting outside of root windows will be moved to primary root window.
+ // TODO(oshima): This one probably should pick the closest root window.
+ d1->SetBounds(gfx::Rect(200, 10, 100, 100));
+ EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
+
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
+}
+
+TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
+ UpdateDisplay("0+0-1000x600,1001+0-600x400");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
+ views::Widget* w1_t1 = CreateTestWidgetWithParent(
+ w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
+ // Transient child of the transient child.
+ views::Widget* w1_t11 = CreateTestWidgetWithParent(
+ w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
+
+ views::Widget* w11 = CreateTestWidgetWithParent(
+ w1, gfx::Rect(10, 10, 40, 40), true /* child */);
+ views::Widget* w11_t1 = CreateTestWidgetWithParent(
+ w1, gfx::Rect(1300, 100, 80, 80), false /* transient */);
+
+ EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[0], w11->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[0], w1_t1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[0], w1_t11->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[0], w11_t1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ("50,50 50x50",
+ w1_t1->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ("1200,70 30x30",
+ w1_t11->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ("20,20 40x40",
+ w11->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ("1300,100 80x80",
+ w11_t1->GetWindowBoundsInScreen().ToString());
+
+ w1->SetBounds(gfx::Rect(1100,10,100,100));
+
+ EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w1_t11->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w11->GetNativeView()->GetRootWindow());
+ EXPECT_EQ(root_windows[1], w11_t1->GetNativeView()->GetRootWindow());
+
+ EXPECT_EQ("1110,20 40x40",
+ w11->GetWindowBoundsInScreen().ToString());
+ // Transient window's screen bounds stays the same.
+ EXPECT_EQ("50,50 50x50",
+ w1_t1->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ("1200,70 30x30",
+ w1_t11->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ("1300,100 80x80",
+ w11_t1->GetWindowBoundsInScreen().ToString());
+
+ // Transient window doesn't move between root window unless
+ // its transient parent moves.
+ w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50));
+ EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
+ EXPECT_EQ("10,50 50x50",
+ w1_t1->GetWindowBoundsInScreen().ToString());
+
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
+}
+
namespace internal {
// Test if the Window::ConvertPointToWindow works across root windows.
// TODO(oshima): Move multiple display suport and this test to aura.