diff options
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r-- | webkit/tools/test_shell/drag_delegate.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/drop_delegate.cc | 21 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.cc | 55 | ||||
-rw-r--r-- | webkit/tools/test_shell/event_sending_controller.h | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_mac.mm | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_win.cc | 8 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_webview_delegate.cc | 16 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 2 |
10 files changed, 81 insertions, 52 deletions
diff --git a/webkit/tools/test_shell/drag_delegate.cc b/webkit/tools/test_shell/drag_delegate.cc index eeb5522..1759a68 100644 --- a/webkit/tools/test_shell/drag_delegate.cc +++ b/webkit/tools/test_shell/drag_delegate.cc @@ -6,8 +6,11 @@ #include <atltypes.h> +#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "webkit/glue/webview.h" +using WebKit::WebPoint; + namespace { void GetCursorPositions(HWND hwnd, CPoint* client, CPoint* screen) { @@ -30,12 +33,14 @@ void TestDragDelegate::OnDragSourceDrop() { CPoint client; CPoint screen; GetCursorPositions(source_hwnd_, &client, &screen); - webview_->DragSourceEndedAt(client.x, client.y, screen.x, screen.y); + webview_->DragSourceEndedAt(WebPoint(client.x, client.y), + WebPoint(screen.x, screen.y)); } void TestDragDelegate::OnDragSourceMove() { CPoint client; CPoint screen; GetCursorPositions(source_hwnd_, &client, &screen); - webview_->DragSourceMovedTo(client.x, client.y, screen.x, screen.y); + webview_->DragSourceMovedTo(WebPoint(client.x, client.y), + WebPoint(screen.x, screen.y)); } diff --git a/webkit/tools/test_shell/drop_delegate.cc b/webkit/tools/test_shell/drop_delegate.cc index 77d6679..fed2514 100644 --- a/webkit/tools/test_shell/drop_delegate.cc +++ b/webkit/tools/test_shell/drop_delegate.cc @@ -4,10 +4,15 @@ #include "webkit/tools/test_shell/drop_delegate.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/webview.h" +using WebKit::WebPoint; + // BaseDropTarget methods ---------------------------------------------------- + DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, DWORD key_state, POINT cursor_position, @@ -17,8 +22,10 @@ DWORD TestDropDelegate::OnDragEnter(IDataObject* data_object, POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - bool valid = webview_->DragTargetDragEnter(drop_data, client_pt.x, - client_pt.y, cursor_position.x, cursor_position.y); + bool valid = webview_->DragTargetDragEnter( + drop_data.ToDragData(), drop_data.identity, + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y)); return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; } @@ -28,8 +35,9 @@ DWORD TestDropDelegate::OnDragOver(IDataObject* data_object, DWORD effect) { POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - bool valid = webview_->DragTargetDragOver(client_pt.x, - client_pt.y, cursor_position.x, cursor_position.y); + bool valid = webview_->DragTargetDragOver( + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y)); return valid ? DROPEFFECT_COPY : DROPEFFECT_NONE; } @@ -43,8 +51,9 @@ DWORD TestDropDelegate::OnDrop(IDataObject* data_object, DWORD effect) { POINT client_pt = cursor_position; ScreenToClient(GetHWND(), &client_pt); - webview_->DragTargetDrop(client_pt.x, client_pt.y, - cursor_position.x, cursor_position.y); + webview_->DragTargetDrop( + WebPoint(client_pt.x, client_pt.y), + WebPoint(cursor_position.x, cursor_position.y)); // webkit win port always returns DROPEFFECT_NONE return DROPEFFECT_NONE; diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc index d0849ba..5808bd3 100644 --- a/webkit/tools/test_shell/event_sending_controller.cc +++ b/webkit/tools/test_shell/event_sending_controller.cc @@ -28,7 +28,8 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/time.h" -#include "webkit/glue/webdropdata.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" +#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell.h" @@ -43,9 +44,11 @@ using WebKit::WebInputEventFactory; using base::Time; using base::TimeTicks; +using WebKit::WebDragData; using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; using WebKit::WebMouseEvent; +using WebKit::WebPoint; TestShell* EventSendingController::shell_ = NULL; gfx::Point EventSendingController::last_mouse_pos_; @@ -56,7 +59,7 @@ int EventSendingController::last_button_number_ = -1; namespace { -static scoped_ptr<WebDropData> drag_data_object; +static WebDragData current_drag_data; static bool replaying_saved_events = false; static std::queue<WebMouseEvent> mouse_event_queue; @@ -179,8 +182,8 @@ EventSendingController::EventSendingController(TestShell* shell) void EventSendingController::Reset() { // The test should have finished a drag and the mouse button state. - DCHECK(!drag_data_object.get()); - drag_data_object.reset(); + DCHECK(current_drag_data.isNull()); + current_drag_data.reset(); pressed_button_ = WebMouseEvent::ButtonNone; dragMode.Set(true); #if defined(OS_WIN) @@ -198,16 +201,15 @@ void EventSendingController::Reset() { last_button_number_ = -1; } -/* static */ WebView* EventSendingController::webview() { +// static +WebView* EventSendingController::webview() { return shell_->webView(); } -/* static */ void EventSendingController::DoDragDrop(const WebDropData& data_obj) { - WebDropData* drop_data_copy = new WebDropData; - *drop_data_copy = data_obj; - drag_data_object.reset(drop_data_copy); - - webview()->DragTargetDragEnter(data_obj, 0, 0, 0, 0); +// static +void EventSendingController::DoDragDrop(const WebDragData& drag_data) { + current_drag_data = drag_data; + webview()->DragTargetDragEnter(drag_data, 0, WebPoint(), WebPoint()); // Finish processing events. ReplaySavedEvents(); @@ -234,6 +236,7 @@ int EventSendingController::GetButtonNumberFromSingleArg( return button_code; } + // // Implemented javascript methods. // @@ -302,17 +305,20 @@ void EventSendingController::mouseUp( pressed_button_ = WebMouseEvent::ButtonNone; // If we're in a drag operation, complete it. - if (drag_data_object.get()) { - bool valid = webview()->DragTargetDragOver(e.x, e.y, e.globalX, - e.globalY); + if (!current_drag_data.isNull()) { + WebPoint client_point(e.x, e.y); + WebPoint screen_point(e.globalX, e.globalY); + + bool valid = webview()->DragTargetDragOver(client_point, screen_point); if (valid) { - webview()->DragSourceEndedAt(e.x, e.y, e.globalX, e.globalY); - webview()->DragTargetDrop(e.x, e.y, e.globalX, e.globalY); + webview()->DragSourceEndedAt(client_point, screen_point); + webview()->DragTargetDrop(client_point, screen_point); } else { - webview()->DragSourceEndedAt(e.x, e.y, e.globalX, e.globalY); + webview()->DragSourceEndedAt(client_point, screen_point); webview()->DragTargetDragLeave(); } - drag_data_object.reset(); + + current_drag_data.reset(); } } @@ -337,12 +343,17 @@ void EventSendingController::mouseMoveTo( } } -/* static */ void EventSendingController::DoMouseMove(const WebMouseEvent& e) { +// static +void EventSendingController::DoMouseMove(const WebMouseEvent& e) { webview()->HandleInputEvent(&e); - if (pressed_button_ != WebMouseEvent::ButtonNone && drag_data_object.get()) { - webview()->DragSourceMovedTo(e.x, e.y, e.globalX, e.globalY); - webview()->DragTargetDragOver(e.x, e.y, e.globalX, e.globalY); + if (pressed_button_ != WebMouseEvent::ButtonNone && + !current_drag_data.isNull()) { + WebPoint client_point(e.x, e.y); + WebPoint screen_point(e.globalX, e.globalY); + + webview()->DragSourceMovedTo(client_point, screen_point); + webview()->DragTargetDragOver(client_point, screen_point); } } diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h index d6d62d5..7123692 100644 --- a/webkit/tools/test_shell/event_sending_controller.h +++ b/webkit/tools/test_shell/event_sending_controller.h @@ -24,9 +24,9 @@ class TestShell; class WebView; -struct WebDropData; namespace WebKit { +class WebDragData; class WebMouseEvent; } @@ -40,7 +40,7 @@ class EventSendingController : public CppBoundClass { void Reset(); // Simulate drag&drop system call. - static void DoDragDrop(const WebDropData& drag_data); + static void DoDragDrop(const WebKit::WebDragData& drag_data); // JS callback methods. void mouseDown(const CppArgumentList& args, CppVariant* result); diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 1041bdd..40cd1c1 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -651,7 +651,7 @@ string16 GetLocalizedString(int message_id) { res.length() / 2); } -std::string GetDataResource(int resource_id) { +StringPiece GetDataResource(int resource_id) { switch (resource_id) { case IDR_FEED_PREVIEW: // It is necessary to return a feed preview template that contains @@ -667,7 +667,7 @@ std::string GetDataResource(int resource_id) { resource_id = IDR_TEXTAREA_RESIZER_TESTSHELL; break; } - return TestShell::NetResourceProvider(resource_id).as_string(); + return TestShell::NetResourceProvider(resource_id); } bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index c62dab7..de558dd 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -649,7 +649,7 @@ string16 GetLocalizedString(int message_id) { res.length() / 2); } -std::string GetDataResource(int resource_id) { +StringPiece GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -673,7 +673,7 @@ std::string GetDataResource(int resource_id) { // a {{URL}} substring where the feed URL should go; see the code // that computes feed previews in feed_preview.cc:MakeFeedPreview. // This fixes issue #932714. - return std::string("Feed preview for {{URL}}"); + return "Feed preview for {{URL}}"; case IDR_TEXTAREA_RESIZER: { // Use webkit's text area resizer image. static std::string resize_corner_data; @@ -693,13 +693,13 @@ std::string GetDataResource(int resource_id) { case IDR_SEARCH_CANCEL_PRESSED: case IDR_SEARCH_MAGNIFIER: case IDR_SEARCH_MAGNIFIER_RESULTS: - return TestShell::NetResourceProvider(resource_id).as_string(); + return TestShell::NetResourceProvider(resource_id); default: break; } - return std::string(); + return StringPiece(); } bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index ac3dcfc..6bba743 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -6,7 +6,7 @@ #define WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_WEBKIT_INIT_H_ #include "base/string_util.h" -#include "third_party/WebKit/WebKit/chromium/public/WebCString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" @@ -83,7 +83,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { virtual void prefetchHostName(const WebKit::WebString&) { } - virtual WebKit::WebCString loadResource(const char* name) { + virtual WebKit::WebData loadResource(const char* name) { if (!strcmp(name, "deleteButton")) { // Create a red 30x30 square. const char red_square[] = @@ -98,7 +98,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { "\x18\x50\xb9\x33\x47\xf9\xa8\x01\x32\xd4\xc2\x03\x00\x33\x84\x0d" "\x02\x3a\x91\xeb\xa5\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60" "\x82"; - return WebKit::WebCString(red_square, arraysize(red_square)); + return WebKit::WebData(red_square, arraysize(red_square)); } return webkit_glue::WebKitClientImpl::loadResource(name); } diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index fdd2fe9..c118ceb 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -697,7 +697,7 @@ string16 GetLocalizedString(int message_id) { } // TODO(tc): Convert this to using resources from test_shell.rc. -std::string GetDataResource(int resource_id) { +StringPiece GetDataResource(int resource_id) { switch (resource_id) { case IDR_BROKENIMAGE: { // Use webkit's broken image icon (16x16) @@ -718,7 +718,7 @@ std::string GetDataResource(int resource_id) { // a {{URL}} substring where the feed URL should go; see the code // that computes feed previews in feed_preview.cc:MakeFeedPreview. // This fixes issue #932714. - return std::string("Feed preview for {{URL}}"); + return "Feed preview for {{URL}}"; case IDR_TEXTAREA_RESIZER: { // Use webkit's text area resizer image. static std::string resize_corner_data; @@ -738,13 +738,13 @@ std::string GetDataResource(int resource_id) { case IDR_SEARCH_CANCEL_PRESSED: case IDR_SEARCH_MAGNIFIER: case IDR_SEARCH_MAGNIFIER_RESULTS: - return NetResourceProvider(resource_id).as_string(); + return NetResourceProvider(resource_id); default: break; } - return std::string(); + return StringPiece(); } HCURSOR LoadCursor(int cursor_id) { diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index fe33461..af7a662 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -17,8 +17,10 @@ #include "base/string_util.h" #include "base/trace_event.h" #include "net/base/net_errors.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" #include "webkit/glue/weberror.h" @@ -40,7 +42,9 @@ #include "webkit/tools/test_shell/drop_delegate.h" #endif +using WebKit::WebDragData; using WebKit::WebScreenInfo; +using WebKit::WebString; namespace { @@ -69,8 +73,8 @@ std::wstring UrlSuitableForTestResult(const std::wstring& url) { // Adds a file called "DRTFakeFile" to |data_object| (CF_HDROP). Use to fake // dragging a file. -void AddDRTFakeFileToDataObject(WebDropData* drop_data) { - drop_data->filenames.push_back(L"DRTFakeFile"); +void AddDRTFakeFileToDataObject(WebDragData* drag_data) { + drag_data->appendFileName(WebString::fromUTF8("DRTFakeFile")); } // Get a debugging string from a WebNavigationType. @@ -480,17 +484,17 @@ void TestWebViewDelegate::SetStatusbarText(WebView* webview, } void TestWebViewDelegate::StartDragging(WebView* webview, - const WebDropData& drop_data) { + const WebDragData& drag_data) { if (WebKit::layoutTestMode()) { - WebDropData mutable_drop_data = drop_data; + WebDragData mutable_drag_data = drag_data; if (shell_->layout_test_controller()->ShouldAddFileToPasteboard()) { // Add a file called DRTFakeFile to the drag&drop clipboard. - AddDRTFakeFileToDataObject(&mutable_drop_data); + AddDRTFakeFileToDataObject(&mutable_drag_data); } // When running a test, we need to fake a drag drop operation otherwise // Windows waits for real mouse events to know when the drag is over. - EventSendingController::DoDragDrop(mutable_drop_data); + EventSendingController::DoDragDrop(mutable_drag_data); } else { // TODO(tc): Drag and drop is disabled in the test shell because we need // to be able to convert from WebDragData to an IDataObject. diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 5481376..94e1f83 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -107,7 +107,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, unsigned int line_no, const std::wstring& source_id); virtual void StartDragging(WebView* webview, - const WebDropData& drop_data); + const WebKit::WebDragData& drag_data); virtual void ShowContextMenu(WebView* webview, ContextNode node, int x, |