Index: ash/wm/workspace/workspace_event_handler_unittest.cc |
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc |
index f02830a89f8b15b0791457cd6d2d37522aa22423..f38169438a4893446c550738fe30d54f21174de5 100644 |
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc |
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc |
@@ -30,6 +30,36 @@ |
namespace ash { |
namespace internal { |
+namespace { |
+ |
+// Simulates that a child of the window handled a given event. Allows for |
+// early exits from EventDispatch::ProcessEvent, which would otherwise |
+// dispatch the events a second time to the WorkspaceEventHandler. |
+class EventConsumingTestWindowDelegate |
+ : public aura::test::TestWindowDelegate { |
+ public: |
+ EventConsumingTestWindowDelegate() {} |
+ virtual ~EventConsumingTestWindowDelegate() {} |
+ |
+ // ui::EventHandler |
+ virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
+ event->SetHandled(); |
+ } |
+ |
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
+ event->SetHandled(); |
+ } |
+ |
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
+ event->SetHandled(); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(EventConsumingTestWindowDelegate); |
+}; |
+ |
+} // namespace |
+ |
class WorkspaceEventHandlerTest : public test::AshTestBase { |
public: |
WorkspaceEventHandlerTest() {} |
@@ -150,7 +180,7 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { |
// Verify the double clicking the resize edge works on 2nd display too. |
UpdateDisplay("200x200,400x300"); |
gfx::Rect work_area2 = ScreenUtil::GetSecondaryDisplay().work_area(); |
- restored_bounds.SetRect(220,20, 50, 50); |
+ restored_bounds.SetRect(220, 20, 50, 50); |
window->SetBoundsInScreen(restored_bounds, ScreenUtil::GetSecondaryDisplay()); |
aura::Window* second_root = Shell::GetAllRootWindows()[1]; |
EXPECT_EQ(second_root, window->GetRootWindow()); |
@@ -455,5 +485,63 @@ TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) { |
aura::client::WINDOW_MOVE_SOURCE_MOUSE); |
} |
+// Verifies that double clicking in the header does not maximize if the target |
+// component has changed. |
+TEST_F(WorkspaceEventHandlerTest, |
+ DoubleClickTwoDifferentTargetsDoesntMaximize) { |
+ EventConsumingTestWindowDelegate wd; |
varkha
2014/04/03 04:13:21
nit: Maybe wd -> delegate, probably in the other m
jonross
2014/04/07 15:49:30
Done.
|
+ scoped_ptr<aura::Window> window( |
+ CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40))); |
+ window->SetProperty(aura::client::kCanMaximizeKey, true); |
+ |
+ wm::WindowState* window_state = wm::GetWindowState(window.get()); |
+ gfx::Rect restore_bounds = window->bounds(); |
+ gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
+ window.get()); |
+ |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+ |
+ // First click will go to a client |
+ wd.set_window_component(HTCLIENT); |
+ aura::Window* root = Shell::GetPrimaryRootWindow(); |
+ aura::test::EventGenerator generator(root, window.get()); |
+ generator.ClickLeftButton(); |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+ |
+ // Second click will go to the header |
+ wd.set_window_component(HTCAPTION); |
+ generator.DoubleClickLeftButton(); |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+} |
+ |
+// Verifies that double tapping in the header does not maximize if the target |
+// component has changed. |
+TEST_F(WorkspaceEventHandlerTest, DoubleTapTwoDifferentTargetsDoesntMaximize) { |
+ EventConsumingTestWindowDelegate wd; |
+ scoped_ptr<aura::Window> window( |
+ CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40))); |
+ window->SetProperty(aura::client::kCanMaximizeKey, true); |
+ |
+ wm::WindowState* window_state = wm::GetWindowState(window.get()); |
+ gfx::Rect restore_bounds = window->bounds(); |
+ gfx::Rect work_area_in_parent = ScreenUtil::GetDisplayWorkAreaBoundsInParent( |
+ window.get()); |
+ |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+ |
+ // First click will go to a client |
varkha
2014/04/03 04:13:21
s/click/tap
jonross
2014/04/07 15:49:30
Done.
|
+ wd.set_window_component(HTCLIENT); |
+ aura::Window* root = Shell::GetPrimaryRootWindow(); |
+ aura::test::EventGenerator generator(root, window.get()); |
+ generator.GestureTapAt(gfx::Point(25, 25)); |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+ |
+ // Second click will go to the header |
varkha
2014/04/03 04:13:21
s/click/tap
jonross
2014/04/07 15:49:30
Done.
|
+ wd.set_window_component(HTCAPTION); |
+ generator.GestureTapAt(gfx::Point(25, 25)); |
+ EXPECT_FALSE(window_state->IsMaximized()); |
+} |
+ |
+ |
} // namespace internal |
} // namespace ash |