| 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 "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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 // Deletes a tab being dragged after dragging a tab so that a new window is | 186 // Deletes a tab being dragged after dragging a tab so that a new window is |
| 187 // created. | 187 // created. |
| 188 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteTabWhileDetached) { | 188 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteTabWhileDetached) { |
| 189 // Add another tab. | 189 // Add another tab. |
| 190 AddTabAndResetBrowser(browser()); | 190 AddTabAndResetBrowser(browser()); |
| 191 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 191 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 192 | 192 |
| 193 // Move to the first tab and drag it enough so that it detaches. | 193 // Move to the first tab and drag it enough so that it detaches. |
| 194 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 194 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 195 TabContentsWrapper* to_delete = | 195 TabContents* to_delete = browser()->tab_strip_model()->GetTabContentsAt(0); |
| 196 browser()->tab_strip_model()->GetTabContentsAt(0); | |
| 197 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); | 196 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); |
| 198 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 197 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 199 ui_controls::LEFT, ui_controls::DOWN)); | 198 ui_controls::LEFT, ui_controls::DOWN)); |
| 200 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( | 199 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( |
| 201 gfx::Point(tab_0_center.x(), | 200 gfx::Point(tab_0_center.x(), |
| 202 tab_0_center.y() + tab_strip->height() + 20))); | 201 tab_0_center.y() + tab_strip->height() + 20))); |
| 203 delete to_delete; | 202 delete to_delete; |
| 204 | 203 |
| 205 // Should not be dragging. | 204 // Should not be dragging. |
| 206 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 205 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 207 ASSERT_FALSE(TabDragController::IsActive()); | 206 ASSERT_FALSE(TabDragController::IsActive()); |
| 208 | 207 |
| 209 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | 208 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 210 } | 209 } |
| 211 | 210 |
| 212 namespace { | 211 namespace { |
| 213 | 212 |
| 214 void DeleteSourceDetachedStep2(TabContentsWrapper* tab) { | 213 void DeleteSourceDetachedStep2(TabContents* tab) { |
| 215 // This ends up closing the source window. | 214 // This ends up closing the source window. |
| 216 delete tab; | 215 delete tab; |
| 217 // Cancel the drag. | 216 // Cancel the drag. |
| 218 ui_controls::SendKeyPress(NULL, ui::VKEY_ESCAPE, false, false, false, false); | 217 ui_controls::SendKeyPress(NULL, ui::VKEY_ESCAPE, false, false, false, false); |
| 219 } | 218 } |
| 220 | 219 |
| 221 } // namespace | 220 } // namespace |
| 222 | 221 |
| 223 // Detaches a tab and while detached deletes a tab from the source and releases | 222 // Detaches a tab and while detached deletes a tab from the source and releases |
| 224 // the mouse. | 223 // the mouse. |
| 225 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteSourceDetached) { | 224 IN_PROC_BROWSER_TEST_F(TabDragControllerTest, DeleteSourceDetached) { |
| 226 // Add another tab. | 225 // Add another tab. |
| 227 AddTabAndResetBrowser(browser()); | 226 AddTabAndResetBrowser(browser()); |
| 228 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 227 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 229 | 228 |
| 230 // Move to the first tab and drag it enough so that it detaches. | 229 // Move to the first tab and drag it enough so that it detaches. |
| 231 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 230 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 232 TabContentsWrapper* to_delete = | 231 TabContents* to_delete = browser()->tab_strip_model()->GetTabContentsAt(1); |
| 233 browser()->tab_strip_model()->GetTabContentsAt(1); | |
| 234 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); | 232 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(tab_0_center)); |
| 235 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 233 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 236 ui_controls::LEFT, ui_controls::DOWN)); | 234 ui_controls::LEFT, ui_controls::DOWN)); |
| 237 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( | 235 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync( |
| 238 gfx::Point(tab_0_center.x(), | 236 gfx::Point(tab_0_center.x(), |
| 239 tab_0_center.y() + tab_strip->height() + 20))); | 237 tab_0_center.y() + tab_strip->height() + 20))); |
| 240 delete to_delete; | 238 delete to_delete; |
| 241 | 239 |
| 242 // Should still be dragging. | 240 // Should still be dragging. |
| 243 ASSERT_TRUE(tab_strip->IsDragSessionActive()); | 241 ASSERT_TRUE(tab_strip->IsDragSessionActive()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 343 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 346 browser2, ui::VKEY_ESCAPE, false, false, false, false)); | 344 browser2, ui::VKEY_ESCAPE, false, false, false, false)); |
| 347 | 345 |
| 348 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 346 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 349 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | 347 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 350 ASSERT_FALSE(TabDragController::IsActive()); | 348 ASSERT_FALSE(TabDragController::IsActive()); |
| 351 ASSERT_EQ(2u, BrowserList::size()); | 349 ASSERT_EQ(2u, BrowserList::size()); |
| 352 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 350 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 353 EXPECT_EQ("100", IDString(browser2->tab_strip_model())); | 351 EXPECT_EQ("100", IDString(browser2->tab_strip_model())); |
| 354 } | 352 } |
| OLD | NEW |