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 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" |
6 | 6 |
7 #include "ash/wm/property_util.h" | 7 #include "ash/wm/property_util.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 public: | 70 public: |
71 QuitDraggingObserver() { | 71 QuitDraggingObserver() { |
72 registrar_.Add(this, chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE, | 72 registrar_.Add(this, chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE, |
73 content::NotificationService::AllSources()); | 73 content::NotificationService::AllSources()); |
74 } | 74 } |
75 | 75 |
76 virtual void Observe(int type, | 76 virtual void Observe(int type, |
77 const content::NotificationSource& source, | 77 const content::NotificationSource& source, |
78 const content::NotificationDetails& details) OVERRIDE { | 78 const content::NotificationDetails& details) OVERRIDE { |
79 DCHECK_EQ(chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE, type); | 79 DCHECK_EQ(chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE, type); |
80 MessageLoopForUI::current()->Quit(); | 80 base::MessageLoopForUI::current()->Quit(); |
81 delete this; | 81 delete this; |
82 } | 82 } |
83 | 83 |
84 private: | 84 private: |
85 virtual ~QuitDraggingObserver() {} | 85 virtual ~QuitDraggingObserver() {} |
86 | 86 |
87 content::NotificationRegistrar registrar_; | 87 content::NotificationRegistrar registrar_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(QuitDraggingObserver); | 89 DISALLOW_COPY_AND_ASSIGN(QuitDraggingObserver); |
90 }; | 90 }; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 #endif | 259 #endif |
260 return true; | 260 return true; |
261 } | 261 } |
262 | 262 |
263 bool DragInputToNotifyWhenDone(int x, | 263 bool DragInputToNotifyWhenDone(int x, |
264 int y, | 264 int y, |
265 const base::Closure& task) { | 265 const base::Closure& task) { |
266 if (input_source() == INPUT_SOURCE_MOUSE) | 266 if (input_source() == INPUT_SOURCE_MOUSE) |
267 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); | 267 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); |
268 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) | 268 #if defined(USE_ASH) && !defined(OS_WIN) // TODO(win_ash) |
269 MessageLoop::current()->PostTask(FROM_HERE, task); | 269 base::MessageLoop::current()->PostTask(FROM_HERE, task); |
270 event_generator_->MoveTouch(gfx::Point(x, y)); | 270 event_generator_->MoveTouch(gfx::Point(x, y)); |
271 #else | 271 #else |
272 NOTREACHED(); | 272 NOTREACHED(); |
273 #endif | 273 #endif |
274 return true; | 274 return true; |
275 } | 275 } |
276 | 276 |
277 bool ReleaseInput() { | 277 bool ReleaseInput() { |
278 if (input_source() == INPUT_SOURCE_MOUSE) { | 278 if (input_source() == INPUT_SOURCE_MOUSE) { |
279 return ui_test_utils::SendMouseEventsSync( | 279 return ui_test_utils::SendMouseEventsSync( |
(...skipping 10 matching lines...) Expand all Loading... |
290 bool ReleaseMouseAsync() { | 290 bool ReleaseMouseAsync() { |
291 return input_source() == INPUT_SOURCE_MOUSE && | 291 return input_source() == INPUT_SOURCE_MOUSE && |
292 ui_controls::SendMouseEvents(ui_controls::LEFT, ui_controls::UP); | 292 ui_controls::SendMouseEvents(ui_controls::LEFT, ui_controls::UP); |
293 } | 293 } |
294 | 294 |
295 void QuitWhenNotDragging() { | 295 void QuitWhenNotDragging() { |
296 if (input_source() == INPUT_SOURCE_MOUSE) { | 296 if (input_source() == INPUT_SOURCE_MOUSE) { |
297 // Schedule observer to quit message loop when done dragging. This has to | 297 // Schedule observer to quit message loop when done dragging. This has to |
298 // be async so the message loop can run. | 298 // be async so the message loop can run. |
299 test::QuitWhenNotDraggingImpl(); | 299 test::QuitWhenNotDraggingImpl(); |
300 MessageLoop::current()->Run(); | 300 base::MessageLoop::current()->Run(); |
301 } else { | 301 } else { |
302 // Touch events are sync, so we know we're not in a drag session. But some | 302 // Touch events are sync, so we know we're not in a drag session. But some |
303 // tests rely on the browser fully closing, which is async. So, run all | 303 // tests rely on the browser fully closing, which is async. So, run all |
304 // pending tasks. | 304 // pending tasks. |
305 base::RunLoop run_loop; | 305 base::RunLoop run_loop; |
306 run_loop.RunUntilIdle(); | 306 run_loop.RunUntilIdle(); |
307 } | 307 } |
308 } | 308 } |
309 | 309 |
310 void AddBlankTabAndShow(Browser* browser) { | 310 void AddBlankTabAndShow(Browser* browser) { |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 } | 1259 } |
1260 | 1260 |
1261 bool DragTabAndExecuteTaskWhenDone(const gfx::Point& position, | 1261 bool DragTabAndExecuteTaskWhenDone(const gfx::Point& position, |
1262 const base::Closure& task) { | 1262 const base::Closure& task) { |
1263 return ui_controls::SendMouseMoveNotifyWhenDone( | 1263 return ui_controls::SendMouseMoveNotifyWhenDone( |
1264 position.x(), position.y(), task); | 1264 position.x(), position.y(), task); |
1265 } | 1265 } |
1266 | 1266 |
1267 void QuitWhenNotDragging() { | 1267 void QuitWhenNotDragging() { |
1268 test::QuitWhenNotDraggingImpl(); | 1268 test::QuitWhenNotDraggingImpl(); |
1269 MessageLoop::current()->Run(); | 1269 base::MessageLoop::current()->Run(); |
1270 } | 1270 } |
1271 | 1271 |
1272 private: | 1272 private: |
1273 DISALLOW_COPY_AND_ASSIGN( | 1273 DISALLOW_COPY_AND_ASSIGN( |
1274 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); | 1274 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest); |
1275 }; | 1275 }; |
1276 | 1276 |
1277 // Invoked from the nested message loop. | 1277 // Invoked from the nested message loop. |
1278 void CancelDragTabToWindowInSeparateDisplayStep3( | 1278 void CancelDragTabToWindowInSeparateDisplayStep3( |
1279 TabStrip* tab_strip, | 1279 TabStrip* tab_strip, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 1402 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
1403 ::testing::Values("mouse")); | 1403 ::testing::Values("mouse")); |
1404 INSTANTIATE_TEST_CASE_P(TabDragging, | 1404 INSTANTIATE_TEST_CASE_P(TabDragging, |
1405 DetachToBrowserTabDragControllerTest, | 1405 DetachToBrowserTabDragControllerTest, |
1406 ::testing::Values("mouse", "touch")); | 1406 ::testing::Values("mouse", "touch")); |
1407 #else | 1407 #else |
1408 INSTANTIATE_TEST_CASE_P(TabDragging, | 1408 INSTANTIATE_TEST_CASE_P(TabDragging, |
1409 DetachToBrowserTabDragControllerTest, | 1409 DetachToBrowserTabDragControllerTest, |
1410 ::testing::Values("mouse")); | 1410 ::testing::Values("mouse")); |
1411 #endif | 1411 #endif |
OLD | NEW |