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

Unified Diff: ash/extended_desktop_unittest.cc

Issue 10795027: Move a window if the sceren bounds being set is in other display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adjust for win_aura Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/screen_position_controller.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/extended_desktop_unittest.cc
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index d4cce054474101e1f742ef6210ff3e9203d75a74..179055e46b86f673cda98e7195385465ffeb8d2c 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.
« no previous file with comments | « ash/display/screen_position_controller.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698