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

Side by Side Diff: chrome/browser/sessions/session_restore_browsertest.cc

Issue 11054025: [Sync] Add HTTP status codes to NavigationEntry and TabNavigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto 11096037 Created 8 years, 2 months 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 | « no previous file | chrome/browser/sessions/session_types.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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/defaults.h" 10 #include "chrome/browser/defaults.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 // And the first url should be url. 252 // And the first url should be url.
253 EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL()); 253 EXPECT_EQ(url, chrome::GetWebContentsAt(new_browser, 0)->GetURL());
254 } 254 }
255 #endif // !OS_CHROMEOS 255 #endif // !OS_CHROMEOS
256 256
257 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) { 257 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
258 GURL url1(ui_test_utils::GetTestUrl( 258 GURL url1(ui_test_utils::GetTestUrl(
259 FilePath(FilePath::kCurrentDirectory), 259 FilePath(FilePath::kCurrentDirectory),
260 FilePath(FILE_PATH_LITERAL("title1.html")))); 260 FilePath(FILE_PATH_LITERAL("title1.html"))));
261 GURL url2(ui_test_utils::GetTestUrl( 261 GURL url2("about:version");
262 FilePath(FilePath::kCurrentDirectory),
263 FilePath(FILE_PATH_LITERAL("title2.html"))));
264 GURL url3(ui_test_utils::GetTestUrl( 262 GURL url3(ui_test_utils::GetTestUrl(
265 FilePath(FilePath::kCurrentDirectory), 263 FilePath(FilePath::kCurrentDirectory),
266 FilePath(FILE_PATH_LITERAL("title3.html")))); 264 FilePath(FILE_PATH_LITERAL("title3.html"))));
267 265
268 // Add and navigate three tabs. 266 // Add and navigate three tabs.
269 ui_test_utils::NavigateToURL(browser(), url1); 267 ui_test_utils::NavigateToURL(browser(), url1);
270 { 268 {
271 content::WindowedNotificationObserver observer( 269 content::WindowedNotificationObserver observer(
272 content::NOTIFICATION_LOAD_STOP, 270 content::NOTIFICATION_LOAD_STOP,
273 content::NotificationService::AllSources()); 271 content::NotificationService::AllSources());
(...skipping 19 matching lines...) Expand all
293 // Expect a window with three tabs. 291 // Expect a window with three tabs.
294 ASSERT_EQ(1U, service->entries().size()); 292 ASSERT_EQ(1U, service->entries().size());
295 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); 293 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type);
296 const TabRestoreService::Window* window = 294 const TabRestoreService::Window* window =
297 static_cast<TabRestoreService::Window*>(service->entries().front()); 295 static_cast<TabRestoreService::Window*>(service->entries().front());
298 EXPECT_EQ(3U, window->tabs.size()); 296 EXPECT_EQ(3U, window->tabs.size());
299 297
300 // Find the SessionID for entry2. Since the session service was destroyed, 298 // Find the SessionID for entry2. Since the session service was destroyed,
301 // there is no guarantee that the SessionID for the tab has remained the same. 299 // there is no guarantee that the SessionID for the tab has remained the same.
302 base::Time timestamp; 300 base::Time timestamp;
301 int http_status_code = 0;
303 for (std::vector<TabRestoreService::Tab>::const_iterator it = 302 for (std::vector<TabRestoreService::Tab>::const_iterator it =
304 window->tabs.begin(); it != window->tabs.end(); ++it) { 303 window->tabs.begin(); it != window->tabs.end(); ++it) {
305 const TabRestoreService::Tab& tab = *it; 304 const TabRestoreService::Tab& tab = *it;
306 // If this tab held url2, then restore this single tab. 305 // If this tab held url2, then restore this single tab.
307 if (tab.navigations[0].virtual_url() == url2) { 306 if (tab.navigations[0].virtual_url() == url2) {
308 timestamp = SessionTypesTestHelper::GetTimestamp(tab.navigations[0]); 307 timestamp = SessionTypesTestHelper::GetTimestamp(tab.navigations[0]);
308 http_status_code =
309 SessionTypesTestHelper::GetHttpStatusCode(tab.navigations[0]);
309 service->RestoreEntryById(NULL, tab.id, UNKNOWN); 310 service->RestoreEntryById(NULL, tab.id, UNKNOWN);
310 break; 311 break;
311 } 312 }
312 } 313 }
313 EXPECT_FALSE(timestamp.is_null()); 314 EXPECT_FALSE(timestamp.is_null());
315 EXPECT_EQ(200, http_status_code);
314 316
315 // Make sure that the restored tab is removed from the service. 317 // Make sure that the restored tab is removed from the service.
316 ASSERT_EQ(1U, service->entries().size()); 318 ASSERT_EQ(1U, service->entries().size());
317 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type); 319 ASSERT_EQ(TabRestoreService::WINDOW, service->entries().front()->type);
318 window = static_cast<TabRestoreService::Window*>(service->entries().front()); 320 window = static_cast<TabRestoreService::Window*>(service->entries().front());
319 EXPECT_EQ(2U, window->tabs.size()); 321 EXPECT_EQ(2U, window->tabs.size());
320 322
321 // Make sure that the restored tab was restored with the correct 323 // Make sure that the restored tab was restored with the correct
322 // timestamp. 324 // timestamp and status code.
323 const content::WebContents* contents = 325 const content::WebContents* contents =
324 chrome::GetActiveWebContents(browser()); 326 chrome::GetActiveWebContents(browser());
325 ASSERT_TRUE(contents); 327 ASSERT_TRUE(contents);
326 const content::NavigationEntry* entry = 328 const content::NavigationEntry* entry =
327 contents->GetController().GetActiveEntry(); 329 contents->GetController().GetActiveEntry();
328 ASSERT_TRUE(entry); 330 ASSERT_TRUE(entry);
329 EXPECT_EQ(timestamp, entry->GetTimestamp()); 331 EXPECT_EQ(timestamp, entry->GetTimestamp());
332 EXPECT_EQ(http_status_code, entry->GetHttpStatusCode());
330 } 333 }
331 334
332 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) { 335 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) {
333 GURL url(ui_test_utils::GetTestUrl( 336 GURL url(ui_test_utils::GetTestUrl(
334 FilePath(FilePath::kCurrentDirectory), 337 FilePath(FilePath::kCurrentDirectory),
335 FilePath(FILE_PATH_LITERAL("title1.html")))); 338 FilePath(FILE_PATH_LITERAL("title1.html"))));
336 339
337 // Add a single tab. 340 // Add a single tab.
338 ui_test_utils::NavigateToURL(browser(), url); 341 ui_test_utils::NavigateToURL(browser(), url);
339 342
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 content::NavigationController* controller = 929 content::NavigationController* controller =
927 &chrome::GetActiveWebContents(browser())->GetController(); 930 &chrome::GetActiveWebContents(browser())->GetController();
928 EXPECT_TRUE( 931 EXPECT_TRUE(
929 controller->GetDefaultSessionStorageNamespace()->should_persist()); 932 controller->GetDefaultSessionStorageNamespace()->should_persist());
930 933
931 // Quit and restore. Check that no extra tabs were created. 934 // Quit and restore. Check that no extra tabs were created.
932 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 935 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
933 ASSERT_EQ(1u, BrowserList::size()); 936 ASSERT_EQ(1u, BrowserList::size());
934 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); 937 EXPECT_EQ(1, new_browser->tab_strip_model()->count());
935 } 938 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698