| Index: content/shell/test_runner/event_sender.cc
|
| diff --git a/components/test_runner/event_sender.cc b/content/shell/test_runner/event_sender.cc
|
| similarity index 96%
|
| rename from components/test_runner/event_sender.cc
|
| rename to content/shell/test_runner/event_sender.cc
|
| index 01f8a5e9e7d593961184f118d51b18e0decd777a..28520a0f92664701bdac28da800c7e57824937a0 100644
|
| --- a/components/test_runner/event_sender.cc
|
| +++ b/content/shell/test_runner/event_sender.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/test_runner/event_sender.h"
|
| +#include "content/shell/test_runner/event_sender.h"
|
|
|
| #include <stddef.h>
|
|
|
| @@ -19,11 +19,11 @@
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| -#include "components/test_runner/mock_spell_check.h"
|
| -#include "components/test_runner/test_interfaces.h"
|
| -#include "components/test_runner/web_test_delegate.h"
|
| -#include "components/test_runner/web_view_test_proxy.h"
|
| -#include "components/test_runner/web_widget_test_proxy.h"
|
| +#include "content/shell/test_runner/mock_spell_check.h"
|
| +#include "content/shell/test_runner/test_interfaces.h"
|
| +#include "content/shell/test_runner/web_test_delegate.h"
|
| +#include "content/shell/test_runner/web_view_test_proxy.h"
|
| +#include "content/shell/test_runner/web_widget_test_proxy.h"
|
| #include "gin/handle.h"
|
| #include "gin/object_template_builder.h"
|
| #include "gin/wrappable.h"
|
| @@ -192,18 +192,18 @@ int GetWebMouseEventModifierForButton(WebMouseEvent::Button button) {
|
| case WebPointerProperties::Button::X1:
|
| case WebPointerProperties::Button::X2:
|
| case WebPointerProperties::Button::Eraser:
|
| - return 0; // Not implemented yet
|
| + return 0; // Not implemented yet
|
| }
|
| NOTREACHED();
|
| return 0;
|
| }
|
|
|
| -const int kButtonsInModifiers = WebMouseEvent::LeftButtonDown
|
| - | WebMouseEvent::MiddleButtonDown | WebMouseEvent::RightButtonDown;
|
| +const int kButtonsInModifiers = WebMouseEvent::LeftButtonDown |
|
| + WebMouseEvent::MiddleButtonDown |
|
| + WebMouseEvent::RightButtonDown;
|
|
|
| int modifiersWithButtons(int modifiers, int buttons) {
|
| - return (modifiers & ~kButtonsInModifiers)
|
| - | (buttons & kButtonsInModifiers);
|
| + return (modifiers & ~kButtonsInModifiers) | (buttons & kButtonsInModifiers);
|
| }
|
|
|
| void InitMouseEventGeneric(WebMouseEvent::Button b,
|
| @@ -254,7 +254,7 @@ int GetKeyModifier(const std::string& modifier_name) {
|
| #ifndef __APPLE__
|
| || !strcmp(characters, "addSelectionKey")
|
| #endif
|
| - ) {
|
| + ) {
|
| return WebInputEvent::ControlKey;
|
| } else if (!strcmp(characters, "shiftKey") ||
|
| !strcmp(characters, "rangeSelectionKey")) {
|
| @@ -328,8 +328,8 @@ int GetKeyModifiersFromV8(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
| if (value->IsString()) {
|
| modifier_names.push_back(gin::V8ToString(value));
|
| } else if (value->IsArray()) {
|
| - gin::Converter<std::vector<std::string> >::FromV8(
|
| - isolate, value, &modifier_names);
|
| + gin::Converter<std::vector<std::string>>::FromV8(isolate, value,
|
| + &modifier_names);
|
| }
|
| return GetKeyModifiers(modifier_names);
|
| }
|
| @@ -378,23 +378,24 @@ bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) {
|
| }
|
|
|
| void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems,
|
| - const std::string& prefix, std::vector<std::string>* strings) {
|
| + const std::string& prefix,
|
| + std::vector<std::string>* strings) {
|
| for (size_t i = 0; i < customItems.size(); ++i) {
|
| std::string prefixCopy = prefix;
|
| if (!customItems[i].enabled)
|
| - prefixCopy = kDisabledIdentifier + prefix;
|
| + prefixCopy = kDisabledIdentifier + prefix;
|
| if (customItems[i].checked)
|
| - prefixCopy = kCheckedIdentifier + prefix;
|
| + prefixCopy = kCheckedIdentifier + prefix;
|
| if (customItems[i].type == blink::WebMenuItemInfo::Separator) {
|
| strings->push_back(prefixCopy + kSeparatorIdentifier);
|
| } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
|
| strings->push_back(prefixCopy + customItems[i].label.utf8() +
|
| - customItems[i].icon.utf8() + kSubMenuIdentifier);
|
| - PopulateCustomItems(customItems[i].subMenuItems, prefixCopy +
|
| - kSubMenuDepthIdentifier, strings);
|
| + customItems[i].icon.utf8() + kSubMenuIdentifier);
|
| + PopulateCustomItems(customItems[i].subMenuItems,
|
| + prefixCopy + kSubMenuDepthIdentifier, strings);
|
| } else {
|
| strings->push_back(prefixCopy + customItems[i].label.utf8() +
|
| - customItems[i].icon.utf8());
|
| + customItems[i].icon.utf8());
|
| }
|
| }
|
| }
|
| @@ -414,29 +415,20 @@ std::vector<std::string> MakeMenuItemStringsFor(
|
| // These constants are based on Safari's context menu because tests are made
|
| // for it.
|
| static const char* kNonEditableMenuStrings[] = {
|
| - "Back",
|
| - "Reload Page",
|
| - "Open in Dashbaord",
|
| - "<separator>",
|
| - "View Source",
|
| - "Save Page As",
|
| - "Print Page",
|
| - "Inspect Element",
|
| - 0
|
| - };
|
| - static const char* kEditableMenuStrings[] = {
|
| - "Cut",
|
| - "Copy",
|
| - "<separator>",
|
| - "Paste",
|
| - "Spelling and Grammar",
|
| - "Substitutions, Transformations",
|
| - "Font",
|
| - "Speech",
|
| - "Paragraph Direction",
|
| - "<separator>",
|
| - 0
|
| - };
|
| + "Back", "Reload Page", "Open in Dashbaord",
|
| + "<separator>", "View Source", "Save Page As",
|
| + "Print Page", "Inspect Element", 0};
|
| + static const char* kEditableMenuStrings[] = {"Cut",
|
| + "Copy",
|
| + "<separator>",
|
| + "Paste",
|
| + "Spelling and Grammar",
|
| + "Substitutions, Transformations",
|
| + "Font",
|
| + "Speech",
|
| + "Paragraph Direction",
|
| + "<separator>",
|
| + 0};
|
|
|
| // This is possible because mouse events are cancelleable.
|
| if (!context_menu)
|
| @@ -475,10 +467,10 @@ const float kScrollbarPixelsPerTick = 40.0f;
|
| // of the edit command will be stored in |*name|.
|
| bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) {
|
| #if defined(OS_MACOSX)
|
| -// We only cares about Left,Right,Up,Down keys with Command or Command+Shift
|
| -// modifiers. These key events correspond to some special movement and
|
| -// selection editor commands. These keys will be marked as system key, which
|
| -// prevents them from being handled. Thus they must be handled specially.
|
| + // We only cares about Left,Right,Up,Down keys with Command or Command+Shift
|
| + // modifiers. These key events correspond to some special movement and
|
| + // selection editor commands. These keys will be marked as system key, which
|
| + // prevents them from being handled. Thus they must be handled specially.
|
| if ((event.modifiers() & ~WebKeyboardEvent::ShiftKey) !=
|
| WebKeyboardEvent::MetaKey)
|
| return false;
|
| @@ -664,8 +656,7 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
|
| gin::WrapperInfo EventSenderBindings::kWrapperInfo = {gin::kEmbedderNativeGin};
|
|
|
| EventSenderBindings::EventSenderBindings(base::WeakPtr<EventSender> sender)
|
| - : sender_(sender) {
|
| -}
|
| + : sender_(sender) {}
|
|
|
| EventSenderBindings::~EventSenderBindings() {}
|
|
|
| @@ -688,8 +679,8 @@ void EventSenderBindings::Install(base::WeakPtr<EventSender> sender,
|
| global->Set(gin::StringToV8(isolate, "eventSender"), bindings.ToV8());
|
| }
|
|
|
| -gin::ObjectTemplateBuilder
|
| -EventSenderBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
| +gin::ObjectTemplateBuilder EventSenderBindings::GetObjectTemplateBuilder(
|
| + v8::Isolate* isolate) {
|
| return gin::Wrappable<EventSenderBindings>::GetObjectTemplateBuilder(isolate)
|
| .SetMethod("enableDOMUIEventLogging",
|
| &EventSenderBindings::EnableDOMUIEventLogging)
|
| @@ -1344,7 +1335,7 @@ int EventSender::ModifiersForPointer(int pointer_id) {
|
| }
|
|
|
| void EventSender::DoDragDrop(const WebDragData& drag_data,
|
| - WebDragOperationsMask mask) {
|
| + WebDragOperationsMask mask) {
|
| WebMouseEvent raw_event(WebInputEvent::MouseDown,
|
| ModifiersForPointer(kRawMousePointerId),
|
| GetCurrentEventTimeSec());
|
| @@ -1676,8 +1667,8 @@ void EventSender::KeyDown(const std::string& code_str,
|
| WebKeyboardEvent event_down(WebInputEvent::RawKeyDown, modifiers,
|
| GetCurrentEventTimeSec());
|
| event_down.windowsKeyCode = code;
|
| - event_down.domKey = static_cast<int>(
|
| - ui::KeycodeConverter::KeyStringToDomKey(domKeyString));
|
| + event_down.domKey =
|
| + static_cast<int>(ui::KeycodeConverter::KeyStringToDomKey(domKeyString));
|
| event_down.domCode = static_cast<int>(
|
| ui::KeycodeConverter::CodeStringToDomCode(domCodeString));
|
|
|
| @@ -1876,8 +1867,7 @@ void EventSender::CancelTouchPoint(unsigned index) {
|
| touch_point->state = WebTouchPoint::StateCancelled;
|
| }
|
|
|
| -void EventSender::SetTouchModifier(const std::string& key_name,
|
| - bool set_mask) {
|
| +void EventSender::SetTouchModifier(const std::string& key_name, bool set_mask) {
|
| int mask = GetKeyModifier(key_name);
|
|
|
| if (set_mask)
|
| @@ -1957,7 +1947,7 @@ void EventSender::GestureFlingStart(float x,
|
| if (!max_start_velocity) {
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| isolate->ThrowException(v8::Exception::TypeError(
|
| - gin::StringToV8(isolate, "Invalid max start velocity.")));
|
| + gin::StringToV8(isolate, "Invalid max start velocity.")));
|
| return;
|
| }
|
|
|
| @@ -2025,9 +2015,8 @@ void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) {
|
| // Cancel the current drag operation and throw an error.
|
| KeyDown("Escape", 0, DOMKeyLocationStandard);
|
| v8::Isolate* isolate = blink::mainThreadIsolate();
|
| - isolate->ThrowException(v8::Exception::Error(
|
| - gin::StringToV8(isolate,
|
| - "Nested beginDragWithFiles() not supported.")));
|
| + isolate->ThrowException(v8::Exception::Error(gin::StringToV8(
|
| + isolate, "Nested beginDragWithFiles() not supported.")));
|
| return;
|
| }
|
| current_drag_data_.initialize();
|
| @@ -2049,9 +2038,9 @@ void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) {
|
| WebPoint scaled_last_pos(last_pos.x * scale, last_pos.y * scale);
|
|
|
| // Provide a drag source.
|
| - mainFrameWidget()->dragTargetDragEnter(
|
| - current_drag_data_, scaled_last_pos, scaled_last_pos,
|
| - current_drag_effects_allowed_, 0);
|
| + mainFrameWidget()->dragTargetDragEnter(current_drag_data_, scaled_last_pos,
|
| + scaled_last_pos,
|
| + current_drag_effects_allowed_, 0);
|
| // |is_drag_mode_| saves events and then replays them later. We don't
|
| // need/want that.
|
| is_drag_mode_ = false;
|
| @@ -2083,7 +2072,7 @@ void EventSender::AddTouchPoint(float x, float y, gin::Arguments* args) {
|
|
|
| // Set the touch point pressure to zero if it was not set by the caller
|
| if (std::isnan(touch_point.force))
|
| - touch_point.force = 0.0;
|
| + touch_point.force = 0.0;
|
|
|
| touch_points_.push_back(touch_point);
|
| }
|
| @@ -2225,7 +2214,6 @@ void EventSender::MouseLeave() {
|
| HandleInputEventOnViewOrPopup(event);
|
| }
|
|
|
| -
|
| void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) {
|
| delegate()->PostTask(base::Bind(&EventSender::MouseDown,
|
| weak_factory_.GetWeakPtr(), button_number,
|
| @@ -2254,7 +2242,7 @@ void EventSender::DoLeapForward(int milliseconds) {
|
|
|
| uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) {
|
| uint32_t unique_touch_event_id;
|
| - if(!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id))
|
| + if (!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id))
|
| return unique_touch_event_id;
|
|
|
| return 0;
|
| @@ -2282,8 +2270,8 @@ void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
|
|
|
| for (size_t i = 0; i < touch_points_.size(); ++i) {
|
| WebTouchPoint* touch_point = &touch_points_[i];
|
| - if (touch_point->state == WebTouchPoint::StateReleased
|
| - || touch_point->state == WebTouchPoint::StateCancelled) {
|
| + if (touch_point->state == WebTouchPoint::StateReleased ||
|
| + touch_point->state == WebTouchPoint::StateCancelled) {
|
| touch_points_.erase(touch_points_.begin() + i);
|
| --i;
|
| } else {
|
| @@ -2292,8 +2280,7 @@ void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
|
| }
|
| }
|
|
|
| -void EventSender::GestureEvent(WebInputEvent::Type type,
|
| - gin::Arguments* args) {
|
| +void EventSender::GestureEvent(WebInputEvent::Type type, gin::Arguments* args) {
|
| WebGestureEvent event(type, WebInputEvent::NoModifiers,
|
| GetCurrentEventTimeSec());
|
|
|
| @@ -2325,8 +2312,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| }
|
|
|
| switch (type) {
|
| - case WebInputEvent::GestureScrollUpdate:
|
| - {
|
| + case WebInputEvent::GestureScrollUpdate: {
|
| bool preventPropagation = false;
|
| if (!args->PeekNext().IsEmpty()) {
|
| if (!args->GetNext(&preventPropagation)) {
|
| @@ -2364,8 +2350,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| event.x = current_gesture_location_.x;
|
| event.y = current_gesture_location_.y;
|
| break;
|
| - case WebInputEvent::GesturePinchUpdate:
|
| - {
|
| + case WebInputEvent::GesturePinchUpdate: {
|
| float scale = 1;
|
| if (!args->PeekNext().IsEmpty()) {
|
| if (!args->GetNext(&scale)) {
|
| @@ -2379,8 +2364,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| event.y = current_gesture_location_.y;
|
| break;
|
| }
|
| - case WebInputEvent::GestureTap:
|
| - {
|
| + case WebInputEvent::GestureTap: {
|
| float tap_count = 1;
|
| float width = 30;
|
| float height = 30;
|
| @@ -2423,8 +2407,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| event.x = x;
|
| event.y = y;
|
| break;
|
| - case WebInputEvent::GestureTapDown:
|
| - {
|
| + case WebInputEvent::GestureTapDown: {
|
| float width = 30;
|
| float height = 30;
|
| if (!args->PeekNext().IsEmpty()) {
|
| @@ -2445,8 +2428,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| event.data.tapDown.height = height;
|
| break;
|
| }
|
| - case WebInputEvent::GestureShowPress:
|
| - {
|
| + case WebInputEvent::GestureShowPress: {
|
| float width = 30;
|
| float height = 30;
|
| if (!args->PeekNext().IsEmpty()) {
|
| @@ -2541,8 +2523,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
|
| args->Return(result != WebInputEventResult::NotHandled);
|
| }
|
|
|
| -void EventSender::UpdateClickCountForButton(
|
| - WebMouseEvent::Button button_type) {
|
| +void EventSender::UpdateClickCountForButton(WebMouseEvent::Button button_type) {
|
| if ((GetCurrentEventTimeSec() - last_click_time_sec_ <
|
| kMultipleClickTimeSec) &&
|
| (!OutsideMultiClickRadius(
|
|
|