diff options
author | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 20:09:18 +0000 |
---|---|---|
committer | sidchat@google.com <sidchat@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 20:09:18 +0000 |
commit | fc74c123ef0d28acf73b2ed1937bcfca8a905e96 (patch) | |
tree | 8551f0fa76a67865e9e052033d34c552460fdc2c /chrome/browser/tabs | |
parent | f44bb385a24110f16d1f20b8caece83f70efa25b (diff) | |
download | chromium_src-fc74c123ef0d28acf73b2ed1937bcfca8a905e96.zip chromium_src-fc74c123ef0d28acf73b2ed1937bcfca8a905e96.tar.gz chromium_src-fc74c123ef0d28acf73b2ed1937bcfca8a905e96.tar.bz2 |
Drag tab 2 out of the tab strip.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1049 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r-- | chrome/browser/tabs/tab_dragging_test.cc | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/chrome/browser/tabs/tab_dragging_test.cc b/chrome/browser/tabs/tab_dragging_test.cc index a976d42..37bfcdd 100644 --- a/chrome/browser/tabs/tab_dragging_test.cc +++ b/chrome/browser/tabs/tab_dragging_test.cc @@ -381,3 +381,151 @@ TEST_F(TabDraggingTest, Tab1Tab3Escape) { EXPECT_EQ(tab3_new_url.spec(), tab3_url.spec()); } +// Drag Tab_2 out of the Tab strip. A new window should open with this tab. +TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { + scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + scoped_ptr<WindowProxy> window( + automation()->GetWindowForBrowser(browser.get())); + ASSERT_TRUE(window.get()); + + // Get initial tab count. + int initial_tab_count = 0; + ASSERT_TRUE(browser->GetTabCount(&initial_tab_count)); + ASSERT_TRUE(1 == initial_tab_count); + + // Get Tab_1 which comes with the browser window. + scoped_ptr<TabProxy> tab1(browser->GetTab(0)); + ASSERT_TRUE(tab1.get()); + GURL tab1_url; + ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); + + // Add Tab_2. + GURL tab2_url("about:version"); + ASSERT_TRUE(browser->AppendTab(tab2_url)); + scoped_ptr<TabProxy> tab2(browser->GetTab(1)); + ASSERT_TRUE(tab2.get()); + + // Add Tab_3. + GURL tab3_url("about:plugins"); + ASSERT_TRUE(browser->AppendTab(tab3_url)); + scoped_ptr<TabProxy> tab3(browser->GetTab(2)); + ASSERT_TRUE(tab3.get()); + + // Make sure 3 tabs are opened. + int final_tab_count = 0; + ASSERT_TRUE(browser->WaitForTabCountToChange(initial_tab_count, + &final_tab_count, + 10000)); + ASSERT_TRUE(final_tab_count == initial_tab_count + 2); + + // Make sure all the tab URL specs are different. + ASSERT_TRUE(tab1_url != tab2_url); + ASSERT_TRUE(tab1_url != tab3_url); + ASSERT_TRUE(tab2_url != tab3_url); + + // Get bounds for the tabs. + gfx::Rect bounds1; + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_0, &bounds1, false)); + EXPECT_LT(0, bounds1.x()); + EXPECT_LT(0, bounds1.width()); + EXPECT_LT(0, bounds1.height()); + + gfx::Rect bounds2; + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_1, &bounds2, false)); + EXPECT_LT(0, bounds2.width()); + EXPECT_LT(0, bounds2.height()); + EXPECT_LT(bounds1.x(), bounds2.x()); + EXPECT_EQ(bounds2.y(), bounds1.y()); + + gfx::Rect bounds3; + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_2, &bounds3, false)); + EXPECT_LT(0, bounds3.width()); + EXPECT_LT(0, bounds3.height()); + EXPECT_LT(bounds2.x(), bounds3.x()); + EXPECT_EQ(bounds3.y(), bounds2.y()); + + // Get url Bar bounds. + gfx::Rect urlbar_bounds; + ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, + false)); + EXPECT_LT(0, urlbar_bounds.x()); + EXPECT_LT(0, urlbar_bounds.y()); + EXPECT_LT(0, urlbar_bounds.width()); + EXPECT_LT(0, urlbar_bounds.height()); + + // TEST: Move Tab_2 down, out of the tab strip. + // This should result in the following: + // 1- Tab_3 shift left in place of Tab_2 in Window 1 + // 2- Tab_1 to remain in its place + // 3- Tab_2 openes in a new window + // + // ____________ ____________ ____________ + // / \ / \ / \ + // | Tab_1 | Tab_2 | Tab_3 | + // ---- ---- ---- ---- ---- ---- ---- ---- ---- + // x + // | + // | (Drag this below, out of tab strip) + // V + // ____________ + // / X \ + // | Tab_2 | (New Window) + // ---- ---- ---- ---- ---- ---- ---- + + POINT start; + POINT end; + start.x = bounds2.x() + bounds2.width()/2; + start.y = bounds2.y() + bounds2.height()/2; + end.x = start.x; + end.y = start.y + 3*urlbar_bounds.height(); + + // Simulate tab drag. + ASSERT_TRUE(browser->SimulateDrag(start, end, + ChromeViews::Event::EF_LEFT_BUTTON_DOWN, + false)); + + // Now, first make sure that the old window has only two tabs remaining. + int new_tab_count = 0; + ASSERT_TRUE(browser->GetTabCount(&new_tab_count)); + ASSERT_EQ(2, new_tab_count); + + // Get the two tabs - they are called Tab_1 and Tab_2 in the old window. + tab1.reset(browser->GetTab(0)); + ASSERT_TRUE(tab1.get()); + GURL tab1_new_url; + ASSERT_TRUE(tab1->GetCurrentURL(&tab1_new_url)); + + tab2.reset(browser->GetTab(1)); + ASSERT_TRUE(tab2.get()); + GURL tab2_new_url; + ASSERT_TRUE(tab2->GetCurrentURL(&tab2_new_url)); + + // Now check for proper shifting of tabs; i.e., Tab_3 in window 1 should + // shift left to the position of Tab_2; Tab_1 should stay where it was. + EXPECT_EQ(tab1_new_url.spec(), tab1_url.spec()); + EXPECT_EQ(tab2_new_url.spec(), tab3_url.spec()); + + // Now check to make sure a new window has opened. + scoped_ptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); + ASSERT_TRUE(browser2.get()); + scoped_ptr<WindowProxy> window2( + automation()->GetWindowForBrowser(browser2.get())); + ASSERT_TRUE(window2.get()); + + // Make sure that the new window has only one tab. + int tab_count_window_2 = 0; + ASSERT_TRUE(browser2->GetTabCount(&tab_count_window_2)); + ASSERT_EQ(1, tab_count_window_2); + + // Get Tab_1_2 which should be Tab_1 in Window 2. + scoped_ptr<TabProxy> tab1_2(browser2->GetTab(0)); + ASSERT_TRUE(tab1_2.get()); + GURL tab1_2_url; + ASSERT_TRUE(tab1_2->GetCurrentURL(&tab1_2_url)); + + // Tab_1_2 of Window 2 should essentially be Tab_2 of Window 1. + EXPECT_EQ(tab1_2_url.spec(), tab2_url.spec()); + EXPECT_NE(tab1_2_url.spec(), tab1_url.spec()); + EXPECT_NE(tab1_2_url.spec(), tab3_url.spec()); +} |