Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 21 #include "components/test_runner/mock_spell_check.h" | 22 #include "components/test_runner/mock_spell_check.h" |
| 22 #include "components/test_runner/test_interfaces.h" | 23 #include "components/test_runner/test_interfaces.h" |
| 23 #include "components/test_runner/web_test_delegate.h" | 24 #include "components/test_runner/web_test_delegate.h" |
| 24 #include "components/test_runner/web_view_test_proxy.h" | 25 #include "components/test_runner/web_view_test_proxy.h" |
| 25 #include "components/test_runner/web_widget_test_proxy.h" | 26 #include "components/test_runner/web_widget_test_proxy.h" |
| 26 #include "gin/handle.h" | 27 #include "gin/handle.h" |
| 27 #include "gin/object_template_builder.h" | 28 #include "gin/object_template_builder.h" |
| 28 #include "gin/wrappable.h" | 29 #include "gin/wrappable.h" |
| 30 #include "net/base/filename_util.h" | |
| 31 #include "third_party/WebKit/public/platform/URLConversion.h" | |
| 29 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h" | 32 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h" |
| 30 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 33 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 31 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" | 34 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" |
| 32 #include "third_party/WebKit/public/platform/WebPointerProperties.h" | 35 #include "third_party/WebKit/public/platform/WebPointerProperties.h" |
| 33 #include "third_party/WebKit/public/platform/WebString.h" | 36 #include "third_party/WebKit/public/platform/WebString.h" |
| 34 #include "third_party/WebKit/public/platform/WebTouchEvent.h" | 37 #include "third_party/WebKit/public/platform/WebTouchEvent.h" |
| 35 #include "third_party/WebKit/public/platform/WebVector.h" | 38 #include "third_party/WebKit/public/platform/WebVector.h" |
| 36 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 39 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 37 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 40 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 38 #include "third_party/WebKit/public/web/WebKit.h" | 41 #include "third_party/WebKit/public/web/WebKit.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 55 using blink::WebLocalFrame; | 58 using blink::WebLocalFrame; |
| 56 using blink::WebMenuItemInfo; | 59 using blink::WebMenuItemInfo; |
| 57 using blink::WebMouseEvent; | 60 using blink::WebMouseEvent; |
| 58 using blink::WebMouseWheelEvent; | 61 using blink::WebMouseWheelEvent; |
| 59 using blink::WebPagePopup; | 62 using blink::WebPagePopup; |
| 60 using blink::WebPoint; | 63 using blink::WebPoint; |
| 61 using blink::WebPointerProperties; | 64 using blink::WebPointerProperties; |
| 62 using blink::WebString; | 65 using blink::WebString; |
| 63 using blink::WebTouchEvent; | 66 using blink::WebTouchEvent; |
| 64 using blink::WebTouchPoint; | 67 using blink::WebTouchPoint; |
| 68 using blink::WebURL; | |
| 65 using blink::WebVector; | 69 using blink::WebVector; |
| 66 using blink::WebView; | 70 using blink::WebView; |
| 67 | 71 |
| 68 namespace test_runner { | 72 namespace test_runner { |
| 69 | 73 |
| 70 namespace { | 74 namespace { |
| 71 | 75 |
| 72 const int kRawMousePointerId = -1; | 76 const int kRawMousePointerId = -1; |
| 73 const char* const kPointerTypeStringUnknown = ""; | 77 const char* const kPointerTypeStringUnknown = ""; |
| 74 const char* const kPointerTypeStringMouse = "mouse"; | 78 const char* const kPointerTypeStringMouse = "mouse"; |
| (...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1883 } | 1887 } |
| 1884 | 1888 |
| 1885 void EventSender::SetTouchCancelable(bool cancelable) { | 1889 void EventSender::SetTouchCancelable(bool cancelable) { |
| 1886 touch_cancelable_ = cancelable; | 1890 touch_cancelable_ = cancelable; |
| 1887 } | 1891 } |
| 1888 | 1892 |
| 1889 void EventSender::DumpFilenameBeingDragged() { | 1893 void EventSender::DumpFilenameBeingDragged() { |
| 1890 if (current_drag_data_.isNull()) | 1894 if (current_drag_data_.isNull()) |
| 1891 return; | 1895 return; |
| 1892 | 1896 |
| 1893 WebString filename; | |
| 1894 WebVector<WebDragData::Item> items = current_drag_data_.items(); | 1897 WebVector<WebDragData::Item> items = current_drag_data_.items(); |
| 1895 for (size_t i = 0; i < items.size(); ++i) { | 1898 for (size_t i = 0; i < items.size(); ++i) { |
| 1896 if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) { | 1899 if (items[i].storageType == WebDragData::Item::StorageTypeBinaryData) { |
| 1897 filename = items[i].title; | 1900 WebURL url = items[i].binaryDataSourceURL; |
| 1898 break; | 1901 WebString filename_extension = items[i].binaryDataFilenameExtension; |
| 1902 WebString content_disposition = items[i].binaryDataContentDisposition; | |
| 1903 base::FilePath filename = | |
| 1904 net::GenerateFileName(url, content_disposition.utf8(), | |
| 1905 std::string(), // referrer_charset | |
| 1906 std::string(), // suggested_name | |
| 1907 std::string(), // mime_type | |
| 1908 std::string()); // default_name | |
| 1909 #if defined(OS_WIN) | |
| 1910 filename = filename.ReplaceExtension(filename_extension.utf16()); | |
| 1911 #else | |
| 1912 filename = filename.ReplaceExtension(filename_extension.utf8()); | |
|
kinuko
2017/02/06 22:24:58
nit: could we use WebStringToFilePath(filename_ext
dcheng
2017/02/08 00:01:05
I considered this, but a FilePath isn't really "ju
| |
| 1913 #endif | |
| 1914 delegate()->PrintMessage(std::string("Filename being dragged: ") + | |
| 1915 filename.AsUTF8Unsafe() + "\n"); | |
| 1916 return; | |
| 1899 } | 1917 } |
| 1900 } | 1918 } |
| 1901 delegate()->PrintMessage(std::string("Filename being dragged: ") + | |
| 1902 filename.utf8().data() + "\n"); | |
| 1903 } | 1919 } |
| 1904 | 1920 |
| 1905 void EventSender::GestureFlingCancel() { | 1921 void EventSender::GestureFlingCancel() { |
| 1906 WebGestureEvent event(WebInputEvent::GestureFlingCancel, | 1922 WebGestureEvent event(WebInputEvent::GestureFlingCancel, |
| 1907 WebInputEvent::NoModifiers, GetCurrentEventTimeSec()); | 1923 WebInputEvent::NoModifiers, GetCurrentEventTimeSec()); |
| 1908 // Generally it won't matter what device we use here, and since it might | 1924 // Generally it won't matter what device we use here, and since it might |
| 1909 // be cumbersome to expect all callers to specify a device, we'll just | 1925 // be cumbersome to expect all callers to specify a device, we'll just |
| 1910 // choose Touchpad here. | 1926 // choose Touchpad here. |
| 1911 event.sourceDevice = blink::WebGestureDeviceTouchpad; | 1927 event.sourceDevice = blink::WebGestureDeviceTouchpad; |
| 1912 | 1928 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2901 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); | 2917 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); |
| 2902 } | 2918 } |
| 2903 | 2919 |
| 2904 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( | 2920 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( |
| 2905 const WebInputEvent& event) { | 2921 const WebInputEvent& event) { |
| 2906 return delegate()->TransformScreenToWidgetCoordinates( | 2922 return delegate()->TransformScreenToWidgetCoordinates( |
| 2907 web_widget_test_proxy_base_, event); | 2923 web_widget_test_proxy_base_, event); |
| 2908 } | 2924 } |
| 2909 | 2925 |
| 2910 } // namespace test_runner | 2926 } // namespace test_runner |
| OLD | NEW |