Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc

Issue 404213003: [WIP] Allow scroll events to permanently change the default gesture handler in RootView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: friend test Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 static_cast<TestDesktopBrowserFrameAura*>( 314 static_cast<TestDesktopBrowserFrameAura*>(
315 BrowserView::GetBrowserViewForBrowser(browser())->GetWidget()-> 315 BrowserView::GetBrowserViewForBrowser(browser())->GetWidget()->
316 native_widget_private()); 316 native_widget_private());
317 // Invoke ReleaseCaptureOnDrag() so that when the drag happens and focus 317 // Invoke ReleaseCaptureOnDrag() so that when the drag happens and focus
318 // changes capture is released and the drag cancels. 318 // changes capture is released and the drag cancels.
319 frame->ReleaseCaptureOnNextClear(); 319 frame->ReleaseCaptureOnNextClear();
320 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); 320 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center));
321 EXPECT_FALSE(tab_strip->IsDragSessionActive()); 321 EXPECT_FALSE(tab_strip->IsDragSessionActive());
322 } 322 }
323 323
324 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, GestureEndShouldEndDragTest) { 324 // Tests that a tab dragging session begins and ends at the correct times
325 // when dispatching gestures.
326 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DragWithGesture) {
325 AddTabAndResetBrowser(browser()); 327 AddTabAndResetBrowser(browser());
326 328
327 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 329 TabStrip* tab_strip = GetTabStripForBrowser(browser());
328 330
329 Tab* tab1 = tab_strip->tab_at(1); 331 Tab* tab1 = tab_strip->tab_at(1);
330 gfx::Point tab_1_center(tab1->width() / 2, tab1->height() / 2); 332 gfx::Point tab_1_center(tab1->width() / 2, tab1->height() / 2);
331 333
332 ui::GestureEvent gesture_begin( 334 EXPECT_FALSE(TabDragController::IsActive());
335 EXPECT_FALSE(tab_strip->IsDragSessionActive());
336
337 // A ui::ET_GESTURE_TAP_DOWN dispatched on the tab should set the
338 // drag controller as active and initiate the drag session.
339 ui::GestureEvent gesture_tap_down(
333 tab_1_center.x(), 340 tab_1_center.x(),
334 tab_1_center.x(), 341 tab_1_center.x(),
335 0, 342 0,
336 base::TimeDelta(), 343 base::TimeDelta(),
337 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f)); 344 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f));
338 tab_strip->MaybeStartDrag(tab1, gesture_begin, 345 tab1->OnGestureEvent(&gesture_tap_down);
339 tab_strip->GetSelectionModel());
340 EXPECT_TRUE(TabDragController::IsActive()); 346 EXPECT_TRUE(TabDragController::IsActive());
347 EXPECT_TRUE(tab_strip->IsDragSessionActive());
341 348
342 ui::GestureEvent gesture_end( 349 // We should remain in the drag session if a ui::ET_GESTURE_SCROLL_BEGIN
350 // and a ui::ET_GESTURE_SCROLL_UPDATE are dispatched to the tab strip.
351 ui::GestureEvent gesture_scroll_begin(
343 tab_1_center.x(), 352 tab_1_center.x(),
344 tab_1_center.x(), 353 tab_1_center.x(),
345 0, 354 0,
346 base::TimeDelta(), 355 base::TimeDelta(),
347 ui::GestureEventDetails(ui::ET_GESTURE_END, 0.0f, 0.0f)); 356 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0.0f, 0.0f));
348 tab_strip->OnGestureEvent(&gesture_end); 357 ui::GestureEvent gesture_scroll_update(
358 tab_1_center.x(),
359 tab_1_center.x(),
360 0,
361 base::TimeDelta(),
362 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, 0.0f, 0.0f));
363 tab_strip->OnGestureEvent(&gesture_scroll_begin);
364 EXPECT_TRUE(TabDragController::IsActive());
365 EXPECT_TRUE(tab_strip->IsDragSessionActive());
366 tab_strip->OnGestureEvent(&gesture_scroll_update);
367 EXPECT_TRUE(TabDragController::IsActive());
368 EXPECT_TRUE(tab_strip->IsDragSessionActive());
369
370 // A ui::ET_GESTURE_SCROLL_END dispatched to the tab strip should end the
371 // drag session.
372 ui::GestureEvent gesture_scroll_end(
373 tab_1_center.x(),
374 tab_1_center.x(),
375 0,
376 base::TimeDelta(),
377 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0.0f, 0.0f));
378 tab_strip->OnGestureEvent(&gesture_scroll_end);
349 EXPECT_FALSE(TabDragController::IsActive()); 379 EXPECT_FALSE(TabDragController::IsActive());
350 EXPECT_FALSE(tab_strip->IsDragSessionActive()); 380 EXPECT_FALSE(tab_strip->IsDragSessionActive());
351 } 381 }
352 382
353 #endif 383 #endif
354 384
355 class DetachToBrowserTabDragControllerTest 385 class DetachToBrowserTabDragControllerTest
356 : public TabDragControllerTest, 386 : public TabDragControllerTest,
357 public ::testing::WithParamInterface<const char*> { 387 public ::testing::WithParamInterface<const char*> {
358 public: 388 public:
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 DetachToBrowserTabDragControllerTest, 2240 DetachToBrowserTabDragControllerTest,
2211 ::testing::Values("mouse", "touch")); 2241 ::testing::Values("mouse", "touch"));
2212 INSTANTIATE_TEST_CASE_P(TabDragging, 2242 INSTANTIATE_TEST_CASE_P(TabDragging,
2213 DetachToBrowserTabDragControllerTestTouch, 2243 DetachToBrowserTabDragControllerTestTouch,
2214 ::testing::Values("touch")); 2244 ::testing::Values("touch"));
2215 #elif defined(USE_ASH) 2245 #elif defined(USE_ASH)
2216 INSTANTIATE_TEST_CASE_P(TabDragging, 2246 INSTANTIATE_TEST_CASE_P(TabDragging,
2217 DetachToBrowserTabDragControllerTest, 2247 DetachToBrowserTabDragControllerTest,
2218 ::testing::Values("mouse")); 2248 ::testing::Values("mouse"));
2219 #endif 2249 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698