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

Side by Side Diff: chrome/browser/tab_restore_uitest.cc

Issue 11377: Changes tab restore service to handle restoring closed windows as a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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
« no previous file with comments | « chrome/browser/tab_restore_service.cc ('k') | chrome/test/automation/browser_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/win_util.h" 7 #include "base/win_util.h"
8 #include "chrome/app/chrome_dll_resource.h" 8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // Restore the closed tab. 163 // Restore the closed tab.
164 RestoreTab(); 164 RestoreTab();
165 tab.reset(browser_proxy->GetActiveTab()); 165 tab.reset(browser_proxy->GetActiveTab());
166 166
167 // And make sure the URLs match. 167 // And make sure the URLs match.
168 ASSERT_EQ(http_url2, GetActiveTabURL()); 168 ASSERT_EQ(http_url2, GetActiveTabURL());
169 ASSERT_TRUE(tab->GoBack()); 169 ASSERT_TRUE(tab->GoBack());
170 ASSERT_EQ(http_url1, GetActiveTabURL()); 170 ASSERT_EQ(http_url1, GetActiveTabURL());
171 } 171 }
172 172
173
174 // Tests that the SiteInstances used for entries in a restored tab's history 173 // Tests that the SiteInstances used for entries in a restored tab's history
175 // are given appropriate max page IDs, even if the renderer for the entry 174 // are given appropriate max page IDs, even if the renderer for the entry
176 // already exists. (Bug 1204135) 175 // already exists. (Bug 1204135)
177 TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) { 176 TEST_F(TabRestoreUITest, RestoreCrossSiteWithExistingSiteInstance) {
178 const wchar_t kDocRoot[] = L"chrome/test/data"; 177 const wchar_t kDocRoot[] = L"chrome/test/data";
179 TestServer server(kDocRoot); 178 TestServer server(kDocRoot);
180 GURL http_url1(server.TestServerPageW(L"files/title1.html")); 179 GURL http_url1(server.TestServerPageW(L"files/title1.html"));
181 GURL http_url2(server.TestServerPageW(L"files/title2.html")); 180 GURL http_url2(server.TestServerPageW(L"files/title2.html"));
182 181
183 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 182 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 ASSERT_TRUE(tab->GoBack()); 214 ASSERT_TRUE(tab->GoBack());
216 ASSERT_EQ(http_url1, GetActiveTabURL()); 215 ASSERT_EQ(http_url1, GetActiveTabURL());
217 216
218 // Navigating to a new URL should clear the forward list, because the max 217 // Navigating to a new URL should clear the forward list, because the max
219 // page ID of the renderer should have been updated when we restored the tab. 218 // page ID of the renderer should have been updated when we restored the tab.
220 tab->NavigateToURL(http_url2); 219 tab->NavigateToURL(http_url2);
221 ASSERT_FALSE(tab->GoForward()); 220 ASSERT_FALSE(tab->GoForward());
222 ASSERT_EQ(http_url2, GetActiveTabURL()); 221 ASSERT_EQ(http_url2, GetActiveTabURL());
223 } 222 }
224 223
224 TEST_F(TabRestoreUITest, RestoreWindow) {
225 // Create a new window.
226 int window_count;
227 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
228 ASSERT_TRUE(automation()->OpenNewBrowserWindow(SW_HIDE));
229 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(++window_count,
230 kWaitForActionMaxMsec));
231
232 // Create two more tabs, one with url1, the other url2.
233 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
234 int initial_tab_count;
235 ASSERT_TRUE(browser_proxy->GetTabCount(&initial_tab_count));
236 browser_proxy->AppendTab(url1_);
237 ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 1,
238 kWaitForActionMaxMsec));
239 scoped_ptr<TabProxy> new_tab(browser_proxy->GetTab(initial_tab_count));
240 new_tab->NavigateToURL(url1_);
241 browser_proxy->AppendTab(url2_);
242 ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 2,
243 kWaitForActionMaxMsec));
244 new_tab.reset(browser_proxy->GetTab(initial_tab_count + 1));
245 new_tab->NavigateToURL(url2_);
246
247 // Close the window.
248 ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_CLOSEWINDOW));
249 browser_proxy.reset();
250 new_tab.reset();
251 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(window_count - 1,
252 kWaitForActionMaxMsec));
253
254 // Restore the window.
255 browser_proxy.reset(automation()->GetBrowserWindow(0));
256 ASSERT_TRUE(browser_proxy->ApplyAccelerator(IDC_RESTORE_TAB));
257 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(window_count,
258 kWaitForActionMaxMsec));
259
260 browser_proxy.reset(automation()->GetBrowserWindow(1));
261 ASSERT_TRUE(browser_proxy->WaitForTabCountToBecome(initial_tab_count + 2,
262 kWaitForActionMaxMsec));
263
264 scoped_ptr<TabProxy> restored_tab_proxy(
265 browser_proxy->GetTab(initial_tab_count));
266 ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(kWaitForActionMsec));
267 GURL url;
268 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url));
269 ASSERT_TRUE(url == url1_);
270
271 restored_tab_proxy.reset(
272 browser_proxy->GetTab(initial_tab_count + 1));
273 ASSERT_TRUE(restored_tab_proxy->WaitForTabToBeRestored(kWaitForActionMsec));
274 ASSERT_TRUE(restored_tab_proxy->GetCurrentURL(&url));
275 ASSERT_TRUE(url == url2_);
276 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_restore_service.cc ('k') | chrome/test/automation/browser_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698