#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "content/public/common/page_zoom.h"
-#include "content/shell/renderer/test_runner/WebTestDelegate.h"
#include "content/shell/renderer/test_runner/mock_spell_check.h"
#include "content/shell/renderer/test_runner/test_interfaces.h"
+#include "content/shell/renderer/test_runner/web_test_delegate.h"
#include "content/shell/renderer/test_runner/web_test_proxy.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
const int kMultipleClickRadiusPixels = 5;
const char kSubMenuDepthIdentifier[] = "_";
const char kSubMenuIdentifier[] = " >";
+const char kSeparatorIdentifier[] = "---------";
bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) {
return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) >
void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems,
const std::string& prefix, std::vector<std::string>* strings) {
for (size_t i = 0; i < customItems.size(); ++i) {
- if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
+ if (customItems[i].type == blink::WebMenuItemInfo::Separator) {
+ strings->push_back(prefix + kSeparatorIdentifier);
+ } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
strings->push_back(prefix + customItems[i].label.utf8() +
kSubMenuIdentifier);
PopulateCustomItems(customItems[i].subMenuItems, prefix +
button_number_(button_number),
modifiers_(modifiers) {}
- virtual void runIfValid() OVERRIDE {
- m_object->MouseDown(button_number_, modifiers_);
+ virtual void RunIfValid() OVERRIDE {
+ object_->MouseDown(button_number_, modifiers_);
}
private:
button_number_(button_number),
modifiers_(modifiers) {}
- virtual void runIfValid() OVERRIDE {
- m_object->MouseUp(button_number_, modifiers_);
+ virtual void RunIfValid() OVERRIDE {
+ object_->MouseUp(button_number_, modifiers_);
}
private:
modifiers_(modifiers),
location_(location) {}
- virtual void runIfValid() OVERRIDE {
- m_object->KeyDown(code_str_, modifiers_, location_);
+ virtual void RunIfValid() OVERRIDE {
+ object_->KeyDown(code_str_, modifiers_, location_);
}
private:
last_button_type_ = WebMouseEvent::ButtonNone;
touch_points_.clear();
last_context_menu_data_.reset();
- task_list_.revokeAll();
+ task_list_.RevokeAll();
current_gesture_location_ = WebPoint(0, 0);
mouse_event_queue_.clear();
code = ui::VKEY_RMENU;
} else if ("numLock" == code_str) {
code = ui::VKEY_NUMLOCK;
+ } else if ("backspace" == code_str) {
+ code = ui::VKEY_BACK;
+ } else if ("escape" == code_str) {
+ code = ui::VKEY_ESCAPE;
} else {
// Compare the input string with the function-key names defined by the
// DOM spec (i.e. "F1",...,"F24"). If the input string is a function-key
// We just simulate the same behavior here.
std::string edit_command;
if (GetEditCommand(event_down, &edit_command))
- delegate_->setEditCommand(edit_command, "");
+ delegate_->SetEditCommand(edit_command, "");
view_->handleInputEvent(event_down);
FinishDragAndDrop(event, blink::WebDragOperationNone);
}
- delegate_->clearEditCommand();
+ delegate_->ClearEditCommand();
if (generate_char) {
WebKeyboardEvent event_char = event_up;
break;
}
}
- delegate_->printMessage(std::string("Filename being dragged: ") +
+ delegate_->PrintMessage(std::string("Filename being dragged: ") +
filename.utf8().data() + "\n");
}
for (size_t i = 0; i < files.size(); ++i) {
WebDragData::Item item;
item.storageType = WebDragData::Item::StorageTypeFilename;
- item.filenameData = delegate_->getAbsoluteWebStringFromUTF8Path(files[i]);
+ item.filenameData = delegate_->GetAbsoluteWebStringFromUTF8Path(files[i]);
current_drag_data_.addItem(item);
absolute_filenames[i] = item.filenameData;
}
current_drag_data_.setFilesystemId(
- delegate_->registerIsolatedFileSystem(absolute_filenames));
+ delegate_->RegisterIsolatedFileSystem(absolute_filenames));
current_drag_effects_allowed_ = blink::WebDragOperationCopy;
// Provide a drag source.
void EventSender::AddTouchPoint(gin::Arguments* args) {
double x;
double y;
- args->GetNext(&x);
- args->GetNext(&y);
+ if (!args->GetNext(&x) || !args->GetNext(&y)) {
+ args->ThrowError();
+ return;
+ }
WebTouchPoint touch_point;
touch_point.state = WebTouchPoint::StatePressed;
double x;
double y;
- args->GetNext(&x);
- args->GetNext(&y);
+ if (!args->GetNext(&x) || !args->GetNext(&y)) {
+ args->ThrowError();
+ return;
+ }
WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y));
int modifiers = 0;
}
void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) {
- delegate_->postTask(new MouseDownTask(this, button_number, modifiers));
- delegate_->postTask(new MouseUpTask(this, button_number, modifiers));
+ delegate_->PostTask(new MouseDownTask(this, button_number, modifiers));
+ delegate_->PostTask(new MouseUpTask(this, button_number, modifiers));
}
void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str,
int modifiers,
KeyLocationCode location) {
- delegate_->postTask(new KeyDownTask(this, code_str, modifiers, location));
+ delegate_->PostTask(new KeyDownTask(this, code_str, modifiers, location));
}
double EventSender::GetCurrentEventTimeSec() {
- return (delegate_->getCurrentTimeInMillisecond() + time_offset_ms_) / 1000.0;
+ return (delegate_->GetCurrentTimeInMillisecond() + time_offset_ms_) / 1000.0;
}
void EventSender::DoLeapForward(int milliseconds) {
gin::Arguments* args) {
double x;
double y;
- args->GetNext(&x);
- args->GetNext(&y);
- WebPoint point(x, y);
+ if (!args->GetNext(&x) || !args->GetNext(&y)) {
+ args->ThrowError();
+ return;
+ }
WebGestureEvent event;
event.type = type;
current_gesture_location_.y + event.data.scrollUpdate.deltaY;
break;
case WebInputEvent::GestureScrollBegin:
- current_gesture_location_ = WebPoint(point.x, point.y);
+ current_gesture_location_ = WebPoint(x, y);
event.x = current_gesture_location_.x;
event.y = current_gesture_location_.y;
break;
event.x = current_gesture_location_.x;
event.y = current_gesture_location_.y;
break;
- case WebInputEvent::GestureTap:
+ case WebInputEvent::GestureTap:
{
float tap_count = 1;
float width = 30;
event.data.tap.tapCount = tap_count;
event.data.tap.width = width;
event.data.tap.height = height;
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
break;
}
case WebInputEvent::GestureTapUnconfirmed:
} else {
event.data.tap.tapCount = 1;
}
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
break;
case WebInputEvent::GestureTapDown:
{
return;
}
}
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
event.data.tapDown.width = width;
event.data.tapDown.height = height;
break;
}
}
}
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
event.data.showPress.width = width;
event.data.showPress.height = height;
break;
}
case WebInputEvent::GestureTapCancel:
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
break;
case WebInputEvent::GestureLongPress:
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
if (!args->PeekNext().IsEmpty()) {
float width;
if (!args->GetNext(&width)) {
}
break;
case WebInputEvent::GestureLongTap:
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
if (!args->PeekNext().IsEmpty()) {
float width;
if (!args->GetNext(&width)) {
}
break;
case WebInputEvent::GestureTwoFingerTap:
- event.x = point.x;
- event.y = point.y;
+ event.x = x;
+ event.y = y;
if (!args->PeekNext().IsEmpty()) {
float first_finger_width;
if (!args->GetNext(&first_finger_width)) {
WebMouseEvent mouse_event;
InitMouseEvent(WebInputEvent::MouseDown,
pressed_button_,
- point,
+ WebPoint(x, y),
GetCurrentEventTimeSec(),
click_count_,
0,