summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 22:01:03 +0000
committerpam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-20 22:01:03 +0000
commit77bc673bf31c32bfdcb1bf139c3a58eace23e3ea (patch)
treea737cc649d4f38a2b96ca2de8d1da4fda0e36451 /chrome/test
parent8c2ea0e34721a2b0bfd8e003937b0617adfddf96 (diff)
downloadchromium_src-77bc673bf31c32bfdcb1bf139c3a58eace23e3ea.zip
chromium_src-77bc673bf31c32bfdcb1bf139c3a58eace23e3ea.tar.gz
chromium_src-77bc673bf31c32bfdcb1bf139c3a58eace23e3ea.tar.bz2
When restoring a closed tab using either ctrl-shift-T or the context menu, put
it back into the window it came from, at the tabstrip index it occupied before, and activate (select) both the window and the tab. Restoring a tab from the New Tab Page replaces the NTP, as before. If the window the tab was in no longer exists, put the tab at the end of the current window's tabstrip. This behavior may change in a later patch. BUG=5278 TEST=Open two windows, with >1 tabs each. Close a tab, not the one at the end, in one of the windows. Switch to the other window and choose "Undo Closed Tab" from the tabstrip context menu, or type ctrl-shift-T. The tab should be restored where it was, and activated (selected and brought to the front). Review URL: http://codereview.chromium.org/69015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automation/automation_messages_internal.h4
-rw-r--r--chrome/test/automation/browser_proxy.cc2
-rw-r--r--chrome/test/automation/browser_proxy.h2
-rw-r--r--chrome/test/automation/tab_proxy.cc12
-rw-r--r--chrome/test/automation/tab_proxy.h3
-rw-r--r--chrome/test/ui/ui_test.cc10
-rw-r--r--chrome/test/ui/ui_test.h3
7 files changed, 34 insertions, 2 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index ca48ad6..16b0a42 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -889,4 +889,8 @@ IPC_BEGIN_MESSAGES(Automation)
// Tab load complete
IPC_MESSAGE_ROUTED1(AutomationMsg_TabLoaded, GURL)
+ // This message requests the tabstrip index of the tab with the given handle.
+ // The return value contains the index, which will be -1 on failure.
+ IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TabIndex, int, int)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc
index 8757a5a..d8240a0 100644
--- a/chrome/test/automation/browser_proxy.cc
+++ b/chrome/test/automation/browser_proxy.cc
@@ -364,7 +364,7 @@ bool BrowserProxy::SetBooleanPreference(const std::wstring& name,
return result;
}
-WindowProxy* BrowserProxy::GetWindow() {
+WindowProxy* BrowserProxy::GetWindow() const {
if (!is_valid())
return false;
diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h
index 1e3508b..68d75bae 100644
--- a/chrome/test/automation/browser_proxy.h
+++ b/chrome/test/automation/browser_proxy.h
@@ -103,7 +103,7 @@ class BrowserProxy : public AutomationResourceProxy {
// retreive view bounds, simulate clicks and key press events. The caller
// owns the returned WindowProxy.
// On failure, returns NULL.
- WindowProxy* GetWindow();
+ WindowProxy* GetWindow() const;
// Returns an AutocompleteEdit for this browser's window. It can be used to
// manipulate the omnibox. The caller owns the returned pointer.
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 088bd69..811f926 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -30,6 +30,18 @@ bool TabProxy::GetTabTitle(std::wstring* title) const {
return succeeded;
}
+bool TabProxy::GetTabIndex(int* index) const {
+ if (!is_valid())
+ return false;
+
+ if (!index) {
+ NOTREACHED();
+ return false;
+ }
+
+ return sender_->Send(new AutomationMsg_TabIndex(0, handle_, index));
+}
+
bool TabProxy::IsShelfVisible(bool* is_visible) {
if (!is_valid())
return false;
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 4bdb4a2..86f8149 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -42,6 +42,9 @@ class TabProxy : public AutomationResourceProxy {
// Gets the title of the tab.
bool GetTabTitle(std::wstring* title) const;
+ // Gets the tabstrip index of the tab.
+ bool GetTabIndex(int* index) const;
+
// Gets the number of constrained window for this tab.
bool GetConstrainedWindowCount(int* count) const;
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index ddea594..620637e 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -566,6 +566,16 @@ std::wstring UITest::GetActiveTabTitle() {
return title;
}
+int UITest::GetActiveTabIndex() {
+ scoped_ptr<TabProxy> tab_proxy(GetActiveTab());
+ if (!tab_proxy.get())
+ return -1;
+
+ int index;
+ EXPECT_TRUE(tab_proxy->GetTabIndex(&index));
+ return index;
+}
+
bool UITest::IsBrowserRunning() {
return CrashAwareSleep(0);
}
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 3b37b98..e3a7c79 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -103,6 +103,9 @@ class UITest : public testing::Test {
// Returns the title of the currently active tab.
std::wstring GetActiveTabTitle();
+ // Returns the tabstrip index of the currently active tab, or -1 on error.
+ int GetActiveTabIndex();
+
// 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
// window or if the browser process died by itself.