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..3b94a731ce9aaa60e7bcbd01679cbb02043342da 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,46 @@ 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); |
tapted
2016/06/01 11:29:55
nit: move below DragAndDropSequnce (it's usually n
themblsha
2016/06/03 17:42:07
Done.
|
+ |
+// Represents an operation in a sequence of simulated drag and drop events |
+// executed asynchronously by DragAndDropSequence. |
+class DragAndDropOperation { |
+ public: |
+ enum class Type { |
+ Move, |
+ MouseDown, |
+ MouseUp |
+ }; |
+ |
+ static DragAndDropOperation Move(const gfx::Point& p); |
+ static DragAndDropOperation MouseDown(); |
+ static DragAndDropOperation MouseUp(); |
+ |
+ Type type() const { return type_; } |
+ const gfx::Point& point() const { return point_; } |
+ |
+ private: |
+ DragAndDropOperation(Type type, const gfx::Point& p) |
+ : type_(type), point_(p) {} |
+ |
+ Type type_; |
+ gfx::Point point_; |
+}; |
+ |
+// Performs a series of drag and drop operations while spinning a RunLoop on the |
+// main thread. If there are nested eventloops on the main thread's queue, our |
tapted
2016/06/01 11:29:55
I don't think we need the sentence "If there are n
themblsha
2016/06/03 17:42:07
Done.
|
+// helper RunLoop won't quit and we'll get stuck. |
+// BridgedNativeWidget::RunMoveLoop() creates a RunLoop, so we need to ensure |
+// that sequence is finished before trying to return from the function. |
+void DragAndDropSequence(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; |