Index: ash/wm/workspace/multi_window_resize_controller_unittest.cc |
diff --git a/ash/wm/workspace/multi_window_resize_controller_unittest.cc b/ash/wm/workspace/multi_window_resize_controller_unittest.cc |
index f4875ee6c7105271aeb47cb02eafeb20c2fbbdc6..ada064f721eb8af6dae02b2c24f53ed5021888e1 100644 |
--- a/ash/wm/workspace/multi_window_resize_controller_unittest.cc |
+++ b/ash/wm/workspace/multi_window_resize_controller_unittest.cc |
@@ -4,8 +4,6 @@ |
#include "ash/wm/workspace/multi_window_resize_controller.h" |
-#include "ash/ash_constants.h" |
-#include "ash/frame/custom_frame_view_ash.h" |
#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
#include "ash/test/shell_test_api.h" |
@@ -19,33 +17,8 @@ |
#include "ui/events/test/event_generator.h" |
#include "ui/gfx/screen.h" |
#include "ui/views/widget/widget.h" |
-#include "ui/views/widget/widget_delegate.h" |
namespace ash { |
- |
-namespace { |
- |
-// WidgetDelegate for a resizable widget which creates a NonClientFrameView |
-// which is actually used in Ash. |
-class TestWidgetDelegate : public views::WidgetDelegateView { |
- public: |
- TestWidgetDelegate() {} |
- ~TestWidgetDelegate() override {} |
- |
- bool CanResize() const override { |
- return true; |
- } |
- |
- views::NonClientFrameView* CreateNonClientFrameView( |
- views::Widget* widget) override { |
- return new CustomFrameViewAsh(widget); |
- } |
- |
- private: |
- DISALLOW_COPY_AND_ASSIGN(TestWidgetDelegate); |
-}; |
- |
-} // namespace |
class MultiWindowResizeControllerTest : public test::AshTestBase { |
public: |
@@ -84,6 +57,10 @@ |
bool HasPendingShow() { |
return resize_controller_->show_timer_.IsRunning(); |
+ } |
+ |
+ bool HasPendingHide() { |
+ return resize_controller_->hide_timer_.IsRunning(); |
} |
void Hide() { |
@@ -132,11 +109,13 @@ |
generator.MoveMouseTo(w1->bounds().CenterPoint()); |
EXPECT_TRUE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Force a show now. |
ShowNow(); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
EXPECT_FALSE(IsOverWindows(gfx::Point(200, 200))); |
@@ -144,79 +123,7 @@ |
resize_controller_->MouseMovedOutOfHost(); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_FALSE(IsShowing()); |
-} |
- |
-// Test the behavior of IsOverWindows(). |
-TEST_F(MultiWindowResizeControllerTest, IsOverWindows) { |
- // Create the following layout: |
- // __________________ |
- // | w1 | w2 | |
- // | |________| |
- // | | w3 | |
- // |________|________| |
- scoped_ptr<views::Widget> w1(new views::Widget); |
- views::Widget::InitParams params1; |
- params1.delegate = new TestWidgetDelegate; |
- params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
- params1.bounds = gfx::Rect(100, 200); |
- params1.context = CurrentContext(); |
- w1->Init(params1); |
- w1->Show(); |
- |
- scoped_ptr<views::Widget> w2(new views::Widget); |
- views::Widget::InitParams params2; |
- params2.delegate = new TestWidgetDelegate; |
- params2.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
- params2.bounds = gfx::Rect(100, 0, 100, 100); |
- params2.context = CurrentContext(); |
- w2->Init(params2); |
- w2->Show(); |
- |
- scoped_ptr<views::Widget> w3(new views::Widget); |
- views::Widget::InitParams params3; |
- params3.delegate = new TestWidgetDelegate; |
- params3.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
- params3.bounds = gfx::Rect(100, 100, 100, 100); |
- params3.context = CurrentContext(); |
- w3->Init(params3); |
- w3->Show(); |
- |
- ui::test::EventGenerator& generator = GetEventGenerator(); |
- generator.MoveMouseTo(gfx::Point(100, 150)); |
- EXPECT_TRUE(HasPendingShow()); |
- EXPECT_TRUE(IsShowing()); |
- ShowNow(); |
- EXPECT_TRUE(IsShowing()); |
- |
- // Check that the multi-window resize handle does not hide while the mouse is |
- // over a window's resize area. A window's resize area extends outside the |
- // window's bounds. |
- EXPECT_TRUE(w3->IsActive()); |
- ASSERT_LT(kResizeInsideBoundsSize, kResizeOutsideBoundsSize); |
- |
- EXPECT_TRUE(IsOverWindows(gfx::Point(100, 150))); |
- EXPECT_TRUE(IsOverWindows(gfx::Point(100 - kResizeOutsideBoundsSize, 150))); |
- EXPECT_FALSE( |
- IsOverWindows(gfx::Point(100 - kResizeOutsideBoundsSize - 1, 150))); |
- EXPECT_TRUE( |
- IsOverWindows(gfx::Point(100 + kResizeInsideBoundsSize - 1, 150))); |
- EXPECT_FALSE(IsOverWindows(gfx::Point(100 + kResizeInsideBoundsSize, 150))); |
- EXPECT_FALSE( |
- IsOverWindows(gfx::Point(100 + kResizeOutsideBoundsSize - 1, 150))); |
- |
- w1->Activate(); |
- EXPECT_TRUE(IsOverWindows(gfx::Point(100, 150))); |
- EXPECT_TRUE(IsOverWindows(gfx::Point(100 - kResizeInsideBoundsSize, 150))); |
- EXPECT_FALSE( |
- IsOverWindows(gfx::Point(100 - kResizeInsideBoundsSize - 1, 150))); |
- EXPECT_FALSE(IsOverWindows(gfx::Point(100 - kResizeOutsideBoundsSize, 150))); |
- EXPECT_TRUE( |
- IsOverWindows(gfx::Point(100 + kResizeOutsideBoundsSize - 1, 150))); |
- EXPECT_FALSE(IsOverWindows(gfx::Point(100 + kResizeOutsideBoundsSize, 150))); |
- |
- // Check that the multi-window resize handles eventually hide if the mouse |
- // moves between |w1| and |w2|. |
- EXPECT_FALSE(IsOverWindows(gfx::Point(100, 50))); |
+ EXPECT_FALSE(HasPendingHide()); |
} |
// Makes sure deleting a window hides. |
@@ -233,11 +140,13 @@ |
generator.MoveMouseTo(w1->bounds().CenterPoint()); |
EXPECT_TRUE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Force a show now. |
ShowNow(); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Move the mouse over the resize widget. |
ASSERT_TRUE(resize_widget()); |
@@ -245,6 +154,7 @@ |
generator.MoveMouseTo(bounds.x() + 1, bounds.y() + 1); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Move the resize widget |
generator.PressLeftButton(); |
@@ -255,6 +165,7 @@ |
EXPECT_TRUE(resize_widget() == NULL); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_FALSE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
EXPECT_FALSE(HasTarget(w1.get())); |
} |
@@ -272,11 +183,13 @@ |
generator.MoveMouseTo(w1->bounds().CenterPoint()); |
EXPECT_TRUE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Force a show now. |
ShowNow(); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Move the mouse over the resize widget. |
ASSERT_TRUE(resize_widget()); |
@@ -284,6 +197,7 @@ |
generator.MoveMouseTo(bounds.x() + 1, bounds.y() + 1); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// Move the resize widget |
generator.PressLeftButton(); |
@@ -293,6 +207,7 @@ |
EXPECT_TRUE(resize_widget()); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
EXPECT_EQ("0,0 110x100", w1->bounds().ToString()); |
EXPECT_EQ("110,0 100x100", w2->bounds().ToString()); |
} |
@@ -316,11 +231,13 @@ |
generator.MoveMouseTo(w1->bounds().CenterPoint()); |
EXPECT_TRUE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
EXPECT_FALSE(HasTarget(w3.get())); |
ShowNow(); |
EXPECT_FALSE(HasPendingShow()); |
EXPECT_TRUE(IsShowing()); |
+ EXPECT_FALSE(HasPendingHide()); |
// w3 should be picked up when resize is started. |
gfx::Rect bounds(resize_widget()->GetWindowBoundsInScreen()); |