summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc136
1 files changed, 82 insertions, 54 deletions
diff --git a/chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc b/chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc
index 67a0066eef8..9fe809420be 100644
--- a/chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc
+++ b/chromium/third_party/blink/renderer/core/exported/web_plugin_container_test.cc
@@ -36,10 +36,10 @@
#include "build/build_config.h"
#include "cc/layers/layer.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/blink/public/common/frame/frame_owner_element_type.h"
+#include "third_party/blink/public/common/input/web_coalesced_input_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/public/common/input/web_pointer_event.h"
-#include "third_party/blink/public/platform/web_coalesced_input_event.h"
+#include "third_party/blink/public/mojom/frame/frame_owner_element_type.mojom-blink.h"
#include "third_party/blink/public/platform/web_url_loader_mock_factory.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
@@ -199,13 +199,14 @@ class TestPluginWithEditableText : public FakeWebPlugin {
};
class TestPluginWebFrameClient : public frame_test_helpers::TestWebFrameClient {
- WebLocalFrame* CreateChildFrame(WebLocalFrame* parent,
- WebTreeScopeType scope,
- const WebString& name,
- const WebString& fallback_name,
- const FramePolicy&,
- const WebFrameOwnerProperties&,
- FrameOwnerElementType owner_type) override {
+ WebLocalFrame* CreateChildFrame(
+ WebLocalFrame* parent,
+ mojom::blink::TreeScopeType scope,
+ const WebString& name,
+ const WebString& fallback_name,
+ const FramePolicy&,
+ const WebFrameOwnerProperties&,
+ mojom::blink::FrameOwnerElementType owner_type) override {
return CreateLocalChild(*parent, scope,
std::make_unique<TestPluginWebFrameClient>());
}
@@ -276,7 +277,7 @@ void CreateAndHandleKeyboardEvent(WebElement* plugin_container_one_element,
WebInputEvent::Modifiers modifier_key,
int key_code) {
WebKeyboardEvent web_keyboard_event(
- WebInputEvent::kRawKeyDown, modifier_key,
+ WebInputEvent::Type::kRawKeyDown, modifier_key,
WebInputEvent::GetStaticTimeStampForTests());
web_keyboard_event.windows_key_code = key_code;
KeyboardEvent* key_event = KeyboardEvent::Create(web_keyboard_event, nullptr);
@@ -287,11 +288,12 @@ void CreateAndHandleKeyboardEvent(WebElement* plugin_container_one_element,
void ExecuteContextMenuCommand(WebViewImpl* web_view,
const WebString& command_name) {
auto event = frame_test_helpers::CreateMouseEvent(
- WebMouseEvent::kMouseDown, WebMouseEvent::Button::kRight,
+ WebMouseEvent::Type::kMouseDown, WebMouseEvent::Button::kRight,
IntPoint(30, 30), 0);
event.click_count = 1;
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
EXPECT_TRUE(
web_view->MainFrame()->ToWebLocalFrame()->ExecuteCommand(command_name));
}
@@ -406,13 +408,14 @@ TEST_F(WebPluginContainerTest, CopyFromContextMenu) {
ClearClipboardBuffer(*local_frame);
auto event = frame_test_helpers::CreateMouseEvent(
- WebMouseEvent::kMouseDown, WebMouseEvent::Button::kRight,
+ WebMouseEvent::Type::kMouseDown, WebMouseEvent::Button::kRight,
IntPoint(30, 30), 0);
event.click_count = 1;
// Now, let's try a more complex scenario:
// 1) open the context menu. This will focus the plugin.
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
// 2) document blurs the plugin, because it can.
web_view->FocusedElement()->blur();
// 3) Copy should still operate on the context node, even though the focus had
@@ -642,7 +645,7 @@ class EventTestPlugin : public FakeWebPlugin {
public:
explicit EventTestPlugin(const WebPluginParams& params)
: FakeWebPlugin(params),
- last_event_type_(WebInputEvent::kUndefined),
+ last_event_type_(WebInputEvent::Type::kUndefined),
last_event_modifiers_(WebInputEvent::kNoModifiers) {}
WebInputEventResult HandleInputEvent(
@@ -653,7 +656,7 @@ class EventTestPlugin : public FakeWebPlugin {
last_event_type_ = event.GetType();
last_event_modifiers_ = event.GetModifiers();
if (WebInputEvent::IsMouseEventType(event.GetType()) ||
- event.GetType() == WebInputEvent::kMouseWheel) {
+ event.GetType() == WebInputEvent::Type::kMouseWheel) {
const WebMouseEvent& mouse_event =
static_cast<const WebMouseEvent&>(event);
last_event_location_ = IntPoint(mouse_event.PositionInWidget().x(),
@@ -678,7 +681,9 @@ class EventTestPlugin : public FakeWebPlugin {
int GetLastEventModifiers() { return last_event_modifiers_; }
- void ClearLastEventType() { last_event_type_ = WebInputEvent::kUndefined; }
+ void ClearLastEventType() {
+ last_event_type_ = WebInputEvent::Type::kUndefined;
+ }
size_t GetCoalescedEventCount() { return coalesced_event_count_; }
@@ -708,7 +713,7 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebGestureEvent event(WebInputEvent::kGestureLongPress,
+ WebGestureEvent event(WebInputEvent::Type::kGestureLongPress,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests(),
WebGestureDevice::kTouchscreen);
@@ -717,10 +722,12 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
// plugin doesn't receive it.
event.SetPositionInWidget(gfx::PointF());
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kUndefined, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kUndefined,
+ test_plugin->GetLastInputEventType());
// Next, send an event that does hit the plugin, and verify it does receive
// it.
@@ -728,10 +735,11 @@ TEST_F(WebPluginContainerTest, GestureLongPressReachesPlugin) {
event.SetPositionInWidget(
gfx::PointF(rect.x + rect.width / 2, rect.y + rect.height / 2));
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kGestureLongPress,
+ EXPECT_EQ(WebInputEvent::Type::kGestureLongPress,
test_plugin->GetLastInputEventType());
}
@@ -753,17 +761,19 @@ TEST_F(WebPluginContainerTest, MouseEventButtons) {
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
WebMouseEvent event = frame_test_helpers::CreateMouseEvent(
- WebMouseEvent::kMouseMove, WebMouseEvent::Button::kNoButton,
+ WebMouseEvent::Type::kMouseMove, WebMouseEvent::Button::kNoButton,
IntPoint(30, 30),
WebInputEvent::kMiddleButtonDown | WebInputEvent::kShiftKey);
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kMouseMove, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseMove,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(WebInputEvent::kMiddleButtonDown | WebInputEvent::kShiftKey,
test_plugin->GetLastEventModifiers());
}
@@ -785,17 +795,19 @@ TEST_F(WebPluginContainerTest, MouseWheelEventTranslated) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebMouseWheelEvent event(WebInputEvent::kMouseWheel,
+ WebMouseWheelEvent event(WebInputEvent::Type::kMouseWheel,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kMouseWheel, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseWheel,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y());
}
@@ -824,7 +836,7 @@ TEST_F(WebPluginContainerTest, TouchEventScrolled) {
WebRect rect = plugin_container_one_element.BoundsInViewport();
WebPointerEvent event(
- WebInputEvent::kPointerDown,
+ WebInputEvent::Type::kPointerDown,
WebPointerProperties(
1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
@@ -832,11 +844,13 @@ TEST_F(WebPluginContainerTest, TouchEventScrolled) {
gfx::PointF(rect.x + rect.width / 2, rect.y + rect.height / 2)),
1.0f, 1.0f);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
web_view->MainFrameWidget()->DispatchBufferedTouchEvents();
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kTouchStart,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y());
}
@@ -866,7 +880,7 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
{
WebRect rect = plugin_container_one_element.BoundsInViewport();
WebPointerEvent event(
- WebInputEvent::kPointerDown,
+ WebInputEvent::Type::kPointerDown,
WebPointerProperties(
1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
@@ -874,7 +888,7 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
gfx::PointF(rect.x + rect.width / 2, rect.y + rect.height / 2)),
1.0f, 1.0f);
- WebCoalescedInputEvent coalesced_event(event);
+ WebCoalescedInputEvent coalesced_event(event, ui::LatencyInfo());
web_view->MainFrameWidget()->HandleInputEvent(coalesced_event);
web_view->MainFrameWidget()->DispatchBufferedTouchEvents();
@@ -882,7 +896,8 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
EXPECT_EQ(static_cast<const size_t>(1),
test_plugin->GetCoalescedEventCount());
- EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kTouchStart,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y());
}
@@ -890,7 +905,7 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
{
WebRect rect = plugin_container_one_element.BoundsInViewport();
WebPointerEvent event1(
- WebInputEvent::kPointerMove,
+ WebInputEvent::Type::kPointerMove,
WebPointerProperties(1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
gfx::PointF(rect.x + rect.width / 2 + 1,
@@ -899,10 +914,10 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
rect.y + rect.height / 2 + 1)),
1.0f, 1.0f);
- WebCoalescedInputEvent coalesced_event(event1);
+ WebCoalescedInputEvent coalesced_event(event1, ui::LatencyInfo());
WebPointerEvent event2(
- WebInputEvent::kPointerMove,
+ WebInputEvent::Type::kPointerMove,
WebPointerProperties(1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
gfx::PointF(rect.x + rect.width / 2 + 2,
@@ -911,7 +926,7 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
rect.y + rect.height / 2 + 2)),
1.0f, 1.0f);
WebPointerEvent event3(
- WebInputEvent::kPointerMove,
+ WebInputEvent::Type::kPointerMove,
WebPointerProperties(1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
gfx::PointF(rect.x + rect.width / 2 + 3,
@@ -929,7 +944,8 @@ TEST_F(WebPluginContainerTest, TouchEventScrolledWithCoalescedTouches) {
EXPECT_EQ(static_cast<const size_t>(3),
test_plugin->GetCoalescedEventCount());
- EXPECT_EQ(WebInputEvent::kTouchMove, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kTouchMove,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2 + 1, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2 + 1, test_plugin->GetLastEventLocation().Y());
}
@@ -957,17 +973,19 @@ TEST_F(WebPluginContainerTest, MouseWheelEventScrolled) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebMouseWheelEvent event(WebInputEvent::kMouseWheel,
+ WebMouseWheelEvent event(WebInputEvent::Type::kMouseWheel,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kMouseWheel, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseWheel,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y());
}
@@ -994,16 +1012,19 @@ TEST_F(WebPluginContainerTest, MouseEventScrolled) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers,
+ WebMouseEvent event(WebInputEvent::Type::kMouseMove,
+ WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
- EXPECT_EQ(WebInputEvent::kMouseMove, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseMove,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 2, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 2, test_plugin->GetLastEventLocation().Y());
}
@@ -1033,18 +1054,21 @@ TEST_F(WebPluginContainerTest, MouseEventZoomed) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebMouseEvent event(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers,
+ WebMouseEvent event(WebInputEvent::Type::kMouseMove,
+ WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
// rect.width/height divided by 4 because the rect is in viewport bounds and
// there is a scale of 2 set.
- EXPECT_EQ(WebInputEvent::kMouseMove, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseMove,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 4, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 4, test_plugin->GetLastEventLocation().Y());
}
@@ -1074,19 +1098,21 @@ TEST_F(WebPluginContainerTest, MouseWheelEventZoomed) {
->Plugin();
EventTestPlugin* test_plugin = static_cast<EventTestPlugin*>(plugin);
- WebMouseWheelEvent event(WebInputEvent::kMouseWheel,
+ WebMouseWheelEvent event(WebInputEvent::Type::kMouseWheel,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
WebRect rect = plugin_container_one_element.BoundsInViewport();
event.SetPositionInWidget(rect.x + rect.width / 2, rect.y + rect.height / 2);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
RunPendingTasks();
// rect.width/height divided by 4 because the rect is in viewport bounds and
// there is a scale of 2 set.
- EXPECT_EQ(WebInputEvent::kMouseWheel, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kMouseWheel,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 4, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 4, test_plugin->GetLastEventLocation().Y());
}
@@ -1118,7 +1144,7 @@ TEST_F(WebPluginContainerTest, TouchEventZoomed) {
WebRect rect = plugin_container_one_element.BoundsInViewport();
WebPointerEvent event(
- WebInputEvent::kPointerDown,
+ WebInputEvent::Type::kPointerDown,
WebPointerProperties(
1, WebPointerProperties::PointerType::kTouch,
WebPointerProperties::Button::kLeft,
@@ -1126,13 +1152,15 @@ TEST_F(WebPluginContainerTest, TouchEventZoomed) {
gfx::PointF(rect.x + rect.width / 2, rect.y + rect.height / 2)),
1.0f, 1.0f);
- web_view->MainFrameWidget()->HandleInputEvent(WebCoalescedInputEvent(event));
+ web_view->MainFrameWidget()->HandleInputEvent(
+ WebCoalescedInputEvent(event, ui::LatencyInfo()));
web_view->MainFrameWidget()->DispatchBufferedTouchEvents();
RunPendingTasks();
// rect.width/height divided by 4 because the rect is in viewport bounds and
// there is a scale of 2 set.
- EXPECT_EQ(WebInputEvent::kTouchStart, test_plugin->GetLastInputEventType());
+ EXPECT_EQ(WebInputEvent::Type::kTouchStart,
+ test_plugin->GetLastInputEventType());
EXPECT_EQ(rect.width / 4, test_plugin->GetLastEventLocation().X());
EXPECT_EQ(rect.height / 4, test_plugin->GetLastEventLocation().Y());
}