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

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

Issue 10540100: TabContentsWrapper -> TabContents, part 48. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/property_bag.h" 10 #include "base/property_bag.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/tabs/tab.h" 17 #include "chrome/browser/ui/views/tabs/tab.h"
18 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" 18 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" 19 #include "chrome/browser/ui/views/tabs/tab_strip.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 // Should have canceled dragging. 328 // Should have canceled dragging.
329 ASSERT_FALSE(tab_strip->IsDragSessionActive()); 329 ASSERT_FALSE(tab_strip->IsDragSessionActive());
330 ASSERT_FALSE(TabDragController::IsActive()); 330 ASSERT_FALSE(TabDragController::IsActive());
331 331
332 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); 332 EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
333 } 333 }
334 334
335 namespace { 335 namespace {
336 336
337 void DeleteWhileDetachedStep2(TabContentsWrapper* tab) { 337 void DeleteWhileDetachedStep2(TabContents* tab) {
338 delete tab; 338 delete tab;
339 } 339 }
340 340
341 } // namespace 341 } // namespace
342 342
343 // Deletes a tab being dragged after dragging a tab so that a new window is 343 // Deletes a tab being dragged after dragging a tab so that a new window is
344 // created. 344 // created.
345 IN_PROC_BROWSER_TEST_F(DetachToBrowserTabDragControllerTest, 345 IN_PROC_BROWSER_TEST_F(DetachToBrowserTabDragControllerTest,
346 DeleteTabWhileDetached) { 346 DeleteTabWhileDetached) {
347 // Add another tab. 347 // Add another tab.
348 AddTabAndResetBrowser(browser()); 348 AddTabAndResetBrowser(browser());
349 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 349 TabStrip* tab_strip = GetTabStripForBrowser(browser());
350 350
351 // Move to the first tab and drag it enough so that it detaches. 351 // Move to the first tab and drag it enough so that it detaches.
352 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); 352 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
353 TabContentsWrapper* to_delete = 353 TabContents* to_delete =
354 browser()->tab_strip_model()->GetTabContentsAt(0); 354 browser()->tab_strip_model()->GetTabContentsAt(0);
355 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); 355 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center));
356 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( 356 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
357 ui_controls::LEFT, ui_controls::DOWN)); 357 ui_controls::LEFT, ui_controls::DOWN));
358 ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone( 358 ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone(
359 tab_0_center.x(), tab_0_center.y() + tab_strip->height() + 20, 359 tab_0_center.x(), tab_0_center.y() + tab_strip->height() + 20,
360 base::Bind(&DeleteWhileDetachedStep2, to_delete))); 360 base::Bind(&DeleteWhileDetachedStep2, to_delete)));
361 // Schedule observer to quit message loop when done dragging. This has to be 361 // Schedule observer to quit message loop when done dragging. This has to be
362 // async so the message loop can run. 362 // async so the message loop can run.
363 QuitWhenNotDragging(); 363 QuitWhenNotDragging();
364 MessageLoop::current()->Run(); 364 MessageLoop::current()->Run();
365 365
366 // Should not be dragging. 366 // Should not be dragging.
367 ASSERT_FALSE(tab_strip->IsDragSessionActive()); 367 ASSERT_FALSE(tab_strip->IsDragSessionActive());
368 ASSERT_FALSE(TabDragController::IsActive()); 368 ASSERT_FALSE(TabDragController::IsActive());
369 369
370 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); 370 EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
371 } 371 }
372 372
373 namespace { 373 namespace {
374 374
375 void DeleteSourceDetachedStep2(TabContentsWrapper* tab) { 375 void DeleteSourceDetachedStep2(TabContents* tab) {
376 // This ends up closing the source window. 376 // This ends up closing the source window.
377 delete tab; 377 delete tab;
378 // Cancel the drag. 378 // Cancel the drag.
379 ui_controls::SendKeyPress(NULL, ui::VKEY_ESCAPE, false, false, false, false); 379 ui_controls::SendKeyPress(NULL, ui::VKEY_ESCAPE, false, false, false, false);
380 } 380 }
381 381
382 } // namespace 382 } // namespace
383 383
384 // Detaches a tab and while detached deletes a tab from the source so that the 384 // Detaches a tab and while detached deletes a tab from the source so that the
385 // source window closes then presses escape to cancel the drag. 385 // source window closes then presses escape to cancel the drag.
386 IN_PROC_BROWSER_TEST_F(DetachToBrowserTabDragControllerTest, 386 IN_PROC_BROWSER_TEST_F(DetachToBrowserTabDragControllerTest,
387 DeleteSourceDetached) { 387 DeleteSourceDetached) {
388 // Add another tab. 388 // Add another tab.
389 AddTabAndResetBrowser(browser()); 389 AddTabAndResetBrowser(browser());
390 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 390 TabStrip* tab_strip = GetTabStripForBrowser(browser());
391 391
392 // Move to the first tab and drag it enough so that it detaches. 392 // Move to the first tab and drag it enough so that it detaches.
393 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); 393 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
394 TabContentsWrapper* to_delete = 394 TabContents* to_delete = browser()->tab_strip_model()->GetTabContentsAt(1);
395 browser()->tab_strip_model()->GetTabContentsAt(1);
396 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); 395 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center));
397 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( 396 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
398 ui_controls::LEFT, ui_controls::DOWN)); 397 ui_controls::LEFT, ui_controls::DOWN));
399 ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone( 398 ASSERT_TRUE(ui_controls::SendMouseMoveNotifyWhenDone(
400 tab_0_center.x(), tab_0_center.y() + tab_strip->height() + 20, 399 tab_0_center.x(), tab_0_center.y() + tab_strip->height() + 20,
401 base::Bind(&DeleteSourceDetachedStep2, to_delete))); 400 base::Bind(&DeleteSourceDetachedStep2, to_delete)));
402 // Schedule observer to quit message loop when done dragging. This has to be 401 // Schedule observer to quit message loop when done dragging. This has to be
403 // async so the message loop can run. 402 // async so the message loop can run.
404 QuitWhenNotDragging(); 403 QuitWhenNotDragging();
405 MessageLoop::current()->Run(); 404 MessageLoop::current()->Run();
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 649
651 // Release the mouse, stopping the drag session. 650 // Release the mouse, stopping the drag session.
652 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( 651 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
653 ui_controls::LEFT, ui_controls::UP)); 652 ui_controls::LEFT, ui_controls::UP));
654 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); 653 ASSERT_FALSE(tab_strip2->IsDragSessionActive());
655 ASSERT_FALSE(tab_strip->IsDragSessionActive()); 654 ASSERT_FALSE(tab_strip->IsDragSessionActive());
656 ASSERT_FALSE(TabDragController::IsActive()); 655 ASSERT_FALSE(TabDragController::IsActive());
657 EXPECT_EQ("0 100", IDString(browser2->tab_strip_model())); 656 EXPECT_EQ("0 100", IDString(browser2->tab_strip_model()));
658 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); 657 EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
659 } 658 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698