| Index: chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc
|
| diff --git a/chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc b/chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc
|
| index cf9d080dbf1c12513deb1462b93d5279d6668ef0..a3dbddf941c235d8345f4654995b610f26ff72df 100644
|
| --- a/chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc
|
| +++ b/chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc
|
| @@ -38,6 +38,7 @@
|
| #include "ui/base/dragdrop/drag_drop_types.h"
|
| #include "ui/base/dragdrop/drop_target_event.h"
|
| #include "ui/base/dragdrop/os_exchange_data.h"
|
| +#include "ui/base/test/ui_controls.h"
|
| #include "ui/gfx/geometry/point.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| #include "url/gurl.h"
|
| @@ -383,6 +384,13 @@ class DragAndDropBrowserTest : public InProcessBrowserTest {
|
| public:
|
| DragAndDropBrowserTest(){};
|
|
|
| + // Declarations of test continuations.
|
| + void DragImageToOtherFrame_Step2(const std::string& frame_site,
|
| + const std::string& text,
|
| + const std::string& html,
|
| + int operation,
|
| + bool did_originate_from_renderer);
|
| +
|
| protected:
|
| void SetUpOnMainThread() override {
|
| host_resolver()->AddRule("*", "127.0.0.1");
|
| @@ -471,15 +479,27 @@ class DragAndDropBrowserTest : public InProcessBrowserTest {
|
|
|
| private:
|
| bool SimulateMouseDown() {
|
| - return ui_test_utils::SendMouseEventsSync(ui_controls::LEFT,
|
| - ui_controls::DOWN);
|
| + return ui_controls::SendMouseEvents(ui_controls::LEFT, ui_controls::DOWN);
|
| }
|
|
|
| - bool SimulateMouseMove(const gfx::Point& location_inside_web_contents) {
|
| + gfx::Point GetScreenCoordinates(
|
| + const gfx::Point& location_inside_web_contents) {
|
| gfx::Rect bounds = web_contents()->GetContainerBounds();
|
| + return gfx::Point(bounds.x() + location_inside_web_contents.x(),
|
| + bounds.y() + location_inside_web_contents.y());
|
| + }
|
| +
|
| + bool SimulateMouseMove(const gfx::Point& location_inside_web_contents) {
|
| return ui_test_utils::SendMouseMoveSync(
|
| - gfx::Point(bounds.x() + location_inside_web_contents.x(),
|
| - bounds.y() + location_inside_web_contents.y()));
|
| + GetScreenCoordinates(location_inside_web_contents));
|
| + }
|
| +
|
| + bool SimulateMouseMoveNotifyWhenDone(
|
| + const gfx::Point& location_inside_web_contents,
|
| + const base::Closure& done_callback) {
|
| + gfx::Point screen_location = GetScreenCoordinates(location_inside_web_contents);
|
| + return ui_controls::SendMouseMoveNotifyWhenDone(
|
| + screen_location.x(), screen_location.y(), done_callback);
|
| }
|
|
|
| bool NavigateNamedFrame(const std::string& frame_name,
|
| @@ -589,61 +609,47 @@ IN_PROC_BROWSER_TEST_F(DragAndDropBrowserTest, DropTextFromOutside) {
|
| }
|
| }
|
|
|
| -// The test is disabled on Ozone because of trouble with mouse simulation
|
| -// during the test - see https://crbug.com/665042.
|
| -#if defined(USE_OZONE)
|
| -#define MAYBE_DragStartInFrame DISABLED_DragStartInFrame
|
| -#else
|
| -#define MAYBE_DragStartInFrame DragStartInFrame
|
| -#endif
|
| +struct DragImageToOtherFrame_TestState {
|
| + std::string frame_site;
|
| +
|
| + std::string expected_text;
|
| + std::string expected_html_regex;
|
| + int expected_operation;
|
| +
|
| + std::string expected_drop_effect;
|
| + std::string expected_effect_allowed;
|
| + std::string expected_mime_types;
|
| +
|
| + std::unique_ptr<DOMDragEventWaiter> dragend_event_waiter;
|
| +};
|
| +
|
| +testing::Matcher<std::string> MatchesTestExpectations(
|
| + const DragImageToOtherFrame_TestState& test) {
|
| + auto matches_expected_drop_effect = testing::HasSubstr(base::StringPrintf(
|
| + "\"drop_effect\":\"%s\"", test.expected_drop_effect.c_str()));
|
| +
|
| + auto matches_expected_effect_allowed = testing::HasSubstr(base::StringPrintf(
|
| + "\"effect_allowed\":\"%s\"", test.expected_effect_allowed.c_str()));
|
| +
|
| + auto matches_expected_mime_types = testing::HasSubstr(base::StringPrintf(
|
| + "\"mime_types\":\"%s\"", test.expected_mime_types.c_str()));
|
| +
|
| + return testing::AllOf(matches_expected_drop_effect,
|
| + matches_expected_mime_types);
|
| +}
|
| +
|
| IN_PROC_BROWSER_TEST_F(DragAndDropBrowserTest, MAYBE_DragStartInFrame) {
|
| std::string frame_site = "b.com";
|
| ASSERT_TRUE(NavigateToTestPage("a.com"));
|
| - ASSERT_TRUE(NavigateLeftFrame(frame_site, "image_source.html"));
|
| -
|
| - // Setup test expectations.
|
| - // (dragstart event handler in image_source.html is asking for "copy" only).
|
| - DOMDragEventVerifier expected_dom_event_data;
|
| - expected_dom_event_data.set_expected_drop_effect("none");
|
| - expected_dom_event_data.set_expected_effect_allowed("copy");
|
| - expected_dom_event_data.set_expected_mime_types(
|
| - "Files,text/html,text/uri-list");
|
|
|
| - // Start the drag in the left frame.
|
| - DragStartWaiter drag_start_waiter(web_contents());
|
| - DOMDragEventWaiter dragstart_event_waiter("dragstart", left_frame());
|
| - EXPECT_TRUE(SimulateMouseDownAndDragStartInLeftFrame());
|
| -
|
| - // Verify Javascript event data.
|
| - {
|
| - std::string dragstart_event;
|
| - EXPECT_TRUE(
|
| - dragstart_event_waiter.WaitForNextMatchingEvent(&dragstart_event));
|
| - EXPECT_THAT(dragstart_event, expected_dom_event_data.Matches());
|
| - }
|
| + // Drag-and-drop is not allowed between cross-origin frames in the same page
|
| + // (see https://crbug.com/59081) - this is why left and right frame have to
|
| + // come from the same origin below.
|
| + ASSERT_TRUE(NavigateLeftFrame(frame_site, "image_source.html"));
|
| + ASSERT_TRUE(NavigateRightFrame(frame_site, "drop_target.html"));
|
|
|
| - // Verify data being passed to the OS.
|
| - {
|
| - std::string text;
|
| - std::string html;
|
| - int operation = 0;
|
| - gfx::Point location_inside_web_contents;
|
| - drag_start_waiter.WaitUntilDragStartIsIntercepted(
|
| - &text, &html, &operation, &location_inside_web_contents);
|
| - EXPECT_EQ(embedded_test_server()->GetURL(frame_site,
|
| - "/image_decoding/droids.jpg"),
|
| - text);
|
| - EXPECT_THAT(html,
|
| - testing::MatchesRegex("<img .*src=\""
|
| - "http://.*/image_decoding/droids.jpg"
|
| - "\">"));
|
| - EXPECT_EQ(expected_location_of_drag_start_in_left_frame(),
|
| - location_inside_web_contents);
|
| - EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, operation);
|
| - }
|
| -
|
| - // Try to leave everything in a clean state.
|
| - SimulateMouseUp();
|
| + LOG(ERROR) << "Starting message loop for interactive UI...";
|
| + (new content::MessageLoopRunner)->Run();
|
| }
|
|
|
| } // namespace chrome
|
|
|