Test to make sure a unparented control gets moved to another root window
when a display is disconnected.

BUG=171908
TEST=coverted by test.


Review URL: https://chromiumcodereview.appspot.com/12040086

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179017 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index 06d7a166..09af6d3 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -165,6 +165,17 @@
   EXPECT_EQ("0,0 500x500",
             fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
 
+  views::Widget* unparented_control = new Widget;
+  Widget::InitParams params;
+  params.bounds = gfx::Rect(650, 10, 100, 100);
+  params.context = CurrentContext();
+  params.type = Widget::InitParams::TYPE_CONTROL;
+  unparented_control->Init(params);
+  EXPECT_EQ(root_windows[1],
+            unparented_control->GetNativeView()->GetRootWindow());
+  EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer,
+            unparented_control->GetNativeView()->parent()->id());
+
   // Make sure a window that will delete itself when losing focus
   // will not crash.
   aura::WindowTracker tracker;
@@ -215,6 +226,12 @@
             fullscreen->GetWindowBoundsInScreen().ToString());
   EXPECT_EQ("300,10 100x100",
             fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
+
+  // Test if the unparented widget has moved.
+  EXPECT_EQ(root_windows[0],
+            unparented_control->GetNativeView()->GetRootWindow());
+  EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer,
+            unparented_control->GetNativeView()->parent()->id());
 }
 
 #if defined(OS_WIN)