Index: trunk/src/ash/wm/workspace/workspace_window_resizer_unittest.cc |
=================================================================== |
--- trunk/src/ash/wm/workspace/workspace_window_resizer_unittest.cc (revision 244088) |
+++ trunk/src/ash/wm/workspace/workspace_window_resizer_unittest.cc (working copy) |
@@ -30,6 +30,37 @@ |
#include "ui/gfx/screen.h" |
#include "ui/views/widget/widget.h" |
+namespace gfx { |
+ |
+// Class to provide access to SlideAnimation internals for testing. |
+// TODO: this should be next to SlideAnimation, not here. |
+class SlideAnimation::TestApi { |
+ public: |
+ explicit TestApi(SlideAnimation* animation) : animation_(animation) {} |
+ |
+ void SetStartTime(base::TimeTicks ticks) { |
+ animation_->SetStartTime(ticks); |
+ } |
+ |
+ void Step(base::TimeTicks ticks) { |
+ animation_->Step(ticks); |
+ } |
+ |
+ void RunTillComplete() { |
+ SetStartTime(base::TimeTicks()); |
+ Step(base::TimeTicks() + |
+ base::TimeDelta::FromMilliseconds(animation_->GetSlideDuration())); |
+ EXPECT_EQ(1.0, animation_->GetCurrentValue()); |
+ } |
+ |
+ private: |
+ SlideAnimation* animation_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TestApi); |
+}; |
+ |
+} |
+ |
namespace ash { |
namespace internal { |
namespace { |
@@ -188,6 +219,12 @@ |
touch_outer_insets); |
} |
+ // Simulate running the animation. |
+ void RunAnimationTillComplete(gfx::SlideAnimation* animation) { |
+ gfx::SlideAnimation::TestApi test_api(animation); |
+ test_api.RunTillComplete(); |
+ } |
+ |
TestWindowDelegate delegate_; |
TestWindowDelegate delegate2_; |
TestWindowDelegate delegate3_; |
@@ -1868,5 +1905,111 @@ |
touch_resize_window_->bounds().ToString()); |
} |
+TEST_F(WorkspaceWindowResizerTest, PhantomWindowShow) { |
+ if (!SupportsMultipleDisplays()) |
+ return; |
+ |
+ UpdateDisplay("500x400,500x400"); |
+ window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), |
+ Shell::GetScreen()->GetPrimaryDisplay()); |
+ aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
+ EXPECT_EQ(root_windows[0], window_->GetRootWindow()); |
+ |
+ scoped_ptr<WindowResizer> resizer(CreateResizerForTest( |
+ window_.get(), gfx::Point(), HTCAPTION)); |
+ ASSERT_TRUE(resizer.get()); |
+ EXPECT_FALSE(snap_phantom_window_controller()); |
+ |
+ // The pointer is on the edge but not shared. The snap phantom window |
+ // controller should be non-NULL. |
+ resizer->Drag(CalculateDragPoint(*resizer, -1, 0), 0); |
+ EXPECT_TRUE(snap_phantom_window_controller()); |
+ PhantomWindowController* phantom_controller(snap_phantom_window_controller()); |
+ |
+ // phantom widget only in the left screen. |
+ phantom_controller->Show(gfx::Rect(100, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ |
+ // Move phantom widget into the right screen. Test that 2 widgets got created. |
+ phantom_controller->Show(gfx::Rect(600, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[1], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_start_->GetNativeWindow()-> |
+ GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Move phantom widget only in the right screen. Start widget should close. |
+ phantom_controller->Show(gfx::Rect(700, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[1], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Move phantom widget into the left screen. Start widget should open. |
+ phantom_controller->Show(gfx::Rect(100, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ EXPECT_EQ( |
+ root_windows[1], |
+ phantom_controller->phantom_widget_start_->GetNativeWindow()-> |
+ GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Move phantom widget while in the left screen. Start widget should close. |
+ phantom_controller->Show(gfx::Rect(200, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Move phantom widget spanning both screens with most of the window in the |
+ // right screen. Two widgets are created. |
+ phantom_controller->Show(gfx::Rect(495, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[1], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_start_->GetNativeWindow()-> |
+ GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Move phantom widget back into the left screen. Phantom widgets should swap. |
+ phantom_controller->Show(gfx::Rect(200, 100, 50, 60)); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_); |
+ EXPECT_TRUE(phantom_controller->phantom_widget_start_); |
+ EXPECT_EQ( |
+ root_windows[0], |
+ phantom_controller->phantom_widget_->GetNativeWindow()->GetRootWindow()); |
+ EXPECT_EQ( |
+ root_windows[1], |
+ phantom_controller->phantom_widget_start_->GetNativeWindow()-> |
+ GetRootWindow()); |
+ RunAnimationTillComplete(phantom_controller->animation_.get()); |
+ |
+ // Hide phantom controller. Both widgets should close. |
+ phantom_controller->Hide(); |
+ EXPECT_FALSE(phantom_controller->phantom_widget_); |
+ EXPECT_FALSE(phantom_controller->phantom_widget_start_); |
+} |
+ |
} // namespace internal |
} // namespace ash |