OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ | 5 #ifndef CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ |
6 #define CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ | 6 #define CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ |
7 | 7 |
8 #include "chrome/browser/ui/view_ids.h" | 8 #include "chrome/browser/ui/view_ids.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "ui/base/test/ui_controls.h" | 10 #include "ui/base/test/ui_controls.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Moves the mouse to the |from| position, presses left mouse button, | 22 // Moves the mouse to the |from| position, presses left mouse button, |
23 // then moves mouse to the |to| position and releases left mouse button. | 23 // then moves mouse to the |to| position and releases left mouse button. |
24 // |steps| indicates number of intermediate points that are interpolated between | 24 // |steps| indicates number of intermediate points that are interpolated between |
25 // |from| and |to|. | 25 // |from| and |to|. |
26 void DragAndDrop(const gfx::Point& from, const gfx::Point& to, int steps = 1); | 26 void DragAndDrop(const gfx::Point& from, const gfx::Point& to, int steps = 1); |
27 | 27 |
28 class DragAndDropOperation { | 28 class DragAndDropOperation { |
29 public: | 29 public: |
30 enum class Type { | 30 enum class Type { |
31 Move, | 31 Move, |
32 MoveWithoutAck, | |
33 MouseDown, | 32 MouseDown, |
34 MouseUp, | 33 MouseUp, |
35 SetMousePositionOverride, | 34 SetMousePositionOverride, |
36 UnsetMousePositionOverride, | 35 UnsetMousePositionOverride, |
37 DebugDelay | 36 DebugDelay |
38 }; | 37 }; |
39 | 38 |
40 static DragAndDropOperation Move(const gfx::Point& p); | 39 static DragAndDropOperation Move(const gfx::Point& p); |
41 // Doesn't wait for the event to finish processing, instead it waits for | |
42 // |delay|. | |
43 static DragAndDropOperation MoveWithoutAck(const gfx::Point& p, | |
44 const base::TimeDelta& delay); | |
45 static DragAndDropOperation MouseDown(); | 40 static DragAndDropOperation MouseDown(); |
46 static DragAndDropOperation MouseUp(); | 41 static DragAndDropOperation MouseUp(); |
47 static DragAndDropOperation SetMousePositionOverride(const gfx::Point& p); | 42 static DragAndDropOperation SetMousePositionOverride(const gfx::Point& p); |
48 static DragAndDropOperation UnsetMousePositionOverride(); | 43 static DragAndDropOperation UnsetMousePositionOverride(); |
| 44 // comment |
49 static DragAndDropOperation DebugDelay(); | 45 static DragAndDropOperation DebugDelay(); |
50 | 46 |
51 Type type() const { return type_; } | 47 Type type() const { return type_; } |
52 const gfx::Point& point() const { return point_; } | 48 const gfx::Point& point() const { return point_; } |
53 const base::TimeDelta& delay() const { return delay_; } | |
54 | 49 |
55 private: | 50 private: |
56 DragAndDropOperation(Type type, | 51 DragAndDropOperation(Type type, const gfx::Point& p) |
57 const gfx::Point& p, | 52 : type_(type), point_(p) {} |
58 const base::TimeDelta& delay = base::TimeDelta()) | |
59 : type_(type), point_(p), delay_(delay) {} | |
60 | 53 |
61 Type type_; | 54 Type type_; |
62 gfx::Point point_; | 55 gfx::Point point_; |
63 base::TimeDelta delay_; | |
64 }; | 56 }; |
65 | 57 |
66 // Performs a series of drag-and-drop operations on a background thread, while | 58 // Performs a series of drag-and-drop operations on a background thread, while |
67 // spinning a RunLoop on the main thread. If there are nested eventloops on the | 59 // spinning a RunLoop on the main thread. If there are nested eventloops on the |
68 // main thread's queue, our helper RunLoop won't quit and we'll get stuck. | 60 // main thread's queue, our helper RunLoop won't quit and we'll get stuck. |
69 // BridgedNativeWidget::RunMoveLoop() creates a RunLoop, so we need to ensure | 61 // BridgedNativeWidget::RunMoveLoop() creates a RunLoop, so we need to ensure |
70 // that Drag'n'Drop is finished before trying to return from the function. | 62 // that Drag'n'Drop is finished before trying to return from the function. |
71 void DragAndDrop(const std::list<DragAndDropOperation>& operations); | 63 void DragAndDrop(const std::list<DragAndDropOperation>& operations); |
72 #endif // OS_MACOSX | 64 #endif // OS_MACOSX |
73 | 65 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // ui_controls_linux.cc and ui_controls_mac.cc | 185 // ui_controls_linux.cc and ui_controls_mac.cc |
194 void ClickTask(ui_controls::MouseButton button, | 186 void ClickTask(ui_controls::MouseButton button, |
195 int state, | 187 int state, |
196 const base::Closure& followup); | 188 const base::Closure& followup); |
197 | 189 |
198 } // namespace internal | 190 } // namespace internal |
199 | 191 |
200 } // namespace ui_test_utils | 192 } // namespace ui_test_utils |
201 | 193 |
202 #endif // CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ | 194 #endif // CHROME_TEST_BASE_INTERACTIVE_TEST_UTILS_H_ |
OLD | NEW |