diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 20:03:08 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-22 20:03:08 +0000 |
commit | c714a16415946fe384b4ba341fc67697b9e79af3 (patch) | |
tree | ff4093e3bc03e592f0a6ac804562aadaea2eb977 /chrome/test/ui | |
parent | f74c89669d1c2406e6af03a84eacc18e3c775547 (diff) | |
download | chromium_src-c714a16415946fe384b4ba341fc67697b9e79af3.zip chromium_src-c714a16415946fe384b4ba341fc67697b9e79af3.tar.gz chromium_src-c714a16415946fe384b4ba341fc67697b9e79af3.tar.bz2 |
Restore closed tabs into new windows when necessary, and track the windows they
came from so they're restored together (into the same new window) when
appropriate.
Fix safety check on tab index when restoring: make it check the correct
browser.
Change some ASSERTs to EXPECTs in the unit test for greater coverage.
BUG=5278
TEST=Open a window with two tabs, close both (closing the window), then
restore both. Make sure both restored tabs are in the same window. Open
a window with multiple tabs, close a tab, then close the window using
its close box. Restore both and make sure the tab goes back into the window.
Review URL: http://codereview.chromium.org/92001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui')
-rw-r--r-- | chrome/test/ui/ui_test.cc | 22 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 37 |
2 files changed, 41 insertions, 18 deletions
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 620637e..d5ac11d 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -458,8 +458,14 @@ void UITest::CleanupAppProcesses() { #endif } -TabProxy* UITest::GetActiveTab() { - scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); +TabProxy* UITest::GetActiveTab(int window_index) { + EXPECT_GE(window_index, 0); + int window_count; + // Use EXPECT rather than ASSERT here because ASSERT_* returns void. + EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); + EXPECT_GT(window_count, window_index); + scoped_ptr<BrowserProxy> window_proxy(automation()-> + GetBrowserWindow(window_index)); if (!window_proxy.get()) return NULL; @@ -545,8 +551,8 @@ bool UITest::WaitForBookmarkBarVisibilityChange(BrowserProxy* browser, } #endif // defined(OS_WIN) -GURL UITest::GetActiveTabURL() { - scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); +GURL UITest::GetActiveTabURL(int window_index) { + scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); if (!tab_proxy.get()) return GURL(); @@ -556,9 +562,9 @@ GURL UITest::GetActiveTabURL() { return url; } -std::wstring UITest::GetActiveTabTitle() { +std::wstring UITest::GetActiveTabTitle(int window_index) { std::wstring title; - scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); + scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); if (!tab_proxy.get()) return title; @@ -566,8 +572,8 @@ std::wstring UITest::GetActiveTabTitle() { return title; } -int UITest::GetActiveTabIndex() { - scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); +int UITest::GetActiveTabIndex(int window_index) { + scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); if (!tab_proxy.get()) return -1; diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index e3a7c79..ff9a87b 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -96,15 +96,28 @@ class UITest : public testing::Test { // This method doesn't return until the navigation is complete. void NavigateToURL(const GURL& url); - // Returns the URL of the currently active tab. If there is no active tab, - // or some other error, the returned URL will be empty. - GURL GetActiveTabURL(); + // Returns the URL of the currently active tab. Only looks in the first + // window, for backward compatibility. If there is no active tab, or some + // other error, the returned URL will be empty. + GURL GetActiveTabURL() { return GetActiveTabURL(0); } - // Returns the title of the currently active tab. - std::wstring GetActiveTabTitle(); + // Like above, but looks at the window at the given index. + GURL GetActiveTabURL(int window_index); - // Returns the tabstrip index of the currently active tab, or -1 on error. - int GetActiveTabIndex(); + // Returns the title of the currently active tab. Only looks in the first + // window, for backward compatibility. + std::wstring GetActiveTabTitle() { return GetActiveTabTitle(0); } + + // Like above, but looks at the window at the given index. + std::wstring GetActiveTabTitle(int window_index); + + // Returns the tabstrip index of the currently active tab in the window at + // the given index, or -1 on error. Only looks in the first window, for + // backward compatibility. + int GetActiveTabIndex() { return GetActiveTabIndex(0); } + + // Like above, but looks at the window at the given index. + int GetActiveTabIndex(int window_index); // Returns true when the browser process is running, independent if any // renderer process exists or not. It will returns false if an user closed the @@ -410,9 +423,13 @@ class UITest : public testing::Test { void CleanupAppProcesses(); // Returns the proxy for the currently active tab, or NULL if there is no - // tab or there was some kind of error. The returned pointer MUST be - // deleted by the caller if non-NULL. - TabProxy* GetActiveTab(); + // tab or there was some kind of error. Only looks at the first window, for + // backward compatibility. The returned pointer MUST be deleted by the + // caller if non-NULL. + TabProxy* GetActiveTab() { return GetActiveTab(0); } + + // Like above, but looks at the window at the given index. + TabProxy* GetActiveTab(int window_index); // ********* Member variables ********* |