Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / apps / shaped_app_window_targeter_unittest.cc
index e1ee418..59fc29c 100644 (file)
@@ -96,7 +96,7 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) {
   // receive events outside of its bounds. Verify that this window-targeter is
   // active unless the window has a custom shape.
   gfx::Insets inset(-30, -30, -30, -30);
-  root_window()->set_event_targeter(scoped_ptr<ui::EventTargeter>(
+  root_window()->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
       new wm::EasyResizeWindowTargeter(root_window(), inset, inset)));
 
   aura::Window* window = widget()->GetNativeWindow();
@@ -149,3 +149,55 @@ TEST_F(ShapedAppWindowTargeterTest, HitTestOnlyForShapedWindow) {
     EXPECT_EQ(window, move.target());
   }
 }
+
+// Tests targeting of events on a window with an EasyResizeWindowTargeter
+// installed on its container.
+TEST_F(ShapedAppWindowTargeterTest, ResizeInsetsWithinBounds) {
+  aura::Window* window = widget()->GetNativeWindow();
+  {
+    // An event in the center of the window should always have
+    // |window| as its target.
+    ui::MouseEvent move(ui::ET_MOUSE_MOVED,
+                        gfx::Point(80, 80), gfx::Point(80, 80),
+                        ui::EF_NONE, ui::EF_NONE);
+    ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
+    ASSERT_FALSE(details.dispatcher_destroyed);
+    EXPECT_EQ(window, move.target());
+  }
+  {
+    // Without an EasyResizeTargeter on the container, an event
+    // inside the window and within 5px of an edge should have
+    // |window| as its target.
+    ui::MouseEvent move(ui::ET_MOUSE_MOVED,
+                        gfx::Point(32, 37), gfx::Point(32, 37),
+                        ui::EF_NONE, ui::EF_NONE);
+    ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
+    ASSERT_FALSE(details.dispatcher_destroyed);
+    EXPECT_EQ(window, move.target());
+  }
+
+  // The EasyResizeTargeter specifies an inset of 5px within the window.
+  app_window_views()->InstallEasyResizeTargeterOnContainer();
+
+  {
+    // An event in the center of the window should always have
+    // |window| as its target.
+    ui::MouseEvent move(ui::ET_MOUSE_MOVED,
+                        gfx::Point(80, 80), gfx::Point(80, 80),
+                        ui::EF_NONE, ui::EF_NONE);
+    ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
+    ASSERT_FALSE(details.dispatcher_destroyed);
+    EXPECT_EQ(window, move.target());
+  }
+  {
+    // With an EasyResizeTargeter on the container, an event
+    // inside the window and within 5px of an edge should have
+    // root_window() as its target.
+    ui::MouseEvent move(ui::ET_MOUSE_MOVED,
+                        gfx::Point(32, 37), gfx::Point(32, 37),
+                        ui::EF_NONE, ui::EF_NONE);
+    ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
+    ASSERT_FALSE(details.dispatcher_destroyed);
+    EXPECT_EQ(root_window(), move.target());
+  }
+}