Index: chrome/test/base/interactive_test_utils.h |
diff --git a/chrome/test/base/interactive_test_utils.h b/chrome/test/base/interactive_test_utils.h |
index f0ccc770f2a8cfae8ca6437cdfc83364527badf7..b61116b00995850e9fdeeefee6b093c7d6b6fcc5 100644 |
--- a/chrome/test/base/interactive_test_utils.h |
+++ b/chrome/test/base/interactive_test_utils.h |
@@ -8,10 +8,7 @@ |
#include "chrome/browser/ui/view_ids.h" |
#include "chrome/test/base/ui_test_utils.h" |
#include "ui/base/test/ui_controls.h" |
- |
-namespace gfx { |
-class Point; |
-} |
+#include "ui/gfx/geometry/point.h" |
#if defined(TOOLKIT_VIEWS) |
namespace views { |
@@ -21,6 +18,59 @@ class View; |
namespace ui_test_utils { |
+#if defined(OS_MACOSX) |
+// Moves the mouse to the |from| position, presses left mouse button, |
+// then moves mouse to the |to| position and releases left mouse button. |
+// |steps| indicates number of intermediate points that are interpolated between |
+// |from| and |to|. |
+void DragAndDrop(const gfx::Point& from, const gfx::Point& to, int steps = 1); |
+ |
+class DragAndDropOperation { |
+ public: |
+ enum class Type { |
+ Move, |
+ MoveWithoutAck, |
+ MouseDown, |
+ MouseUp, |
+ SetMousePositionOverride, |
+ UnsetMousePositionOverride, |
+ DebugDelay |
+ }; |
+ |
+ static DragAndDropOperation Move(const gfx::Point& p); |
+ // Doesn't wait for the event to finish processing, instead it waits for |
+ // |delay|. |
+ static DragAndDropOperation MoveWithoutAck(const gfx::Point& p, |
+ const base::TimeDelta& delay); |
+ static DragAndDropOperation MouseDown(); |
+ static DragAndDropOperation MouseUp(); |
+ static DragAndDropOperation SetMousePositionOverride(const gfx::Point& p); |
+ static DragAndDropOperation UnsetMousePositionOverride(); |
+ static DragAndDropOperation DebugDelay(); |
+ |
+ Type type() const { return type_; } |
+ const gfx::Point& point() const { return point_; } |
+ const base::TimeDelta& delay() const { return delay_; } |
+ |
+ private: |
+ DragAndDropOperation(Type type, |
+ const gfx::Point& p, |
+ const base::TimeDelta& delay = base::TimeDelta()) |
+ : type_(type), point_(p), delay_(delay) {} |
+ |
+ Type type_; |
+ gfx::Point point_; |
+ base::TimeDelta delay_; |
+}; |
+ |
+// Performs a series of drag-and-drop operations on a background thread, while |
+// spinning a RunLoop on the main thread. If there are nested eventloops on the |
+// main thread's queue, our helper RunLoop won't quit and we'll get stuck. |
+// BridgedNativeWidget::RunMoveLoop() creates a RunLoop, so we need to ensure |
+// that Drag'n'Drop is finished before trying to return from the function. |
+void DragAndDrop(const std::list<DragAndDropOperation>& operations); |
+#endif // OS_MACOSX |
+ |
// Brings the native window for |browser| to the foreground. Returns true on |
// success. |
bool BringBrowserWindowToFront(const Browser* browser) WARN_UNUSED_RESULT; |