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

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

Issue 11088005: Automate more Better Session Restore tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nicer api 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
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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/prefs/session_startup_pref.h" 9 #include "chrome/browser/prefs/session_startup_pref.h"
10 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/browser_tabstrip.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/dom_storage_context.h"
17 #include "content/public/browser/storage_partition.h"
15 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
17 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
18 21
19 namespace { 22 namespace {
20 23
21 // The tests server is started separately for each test function (including PRE_ 24 // The tests server is started separately for each test function (including PRE_
22 // functions). We need a test server which always uses the same port, so that 25 // functions). We need a test server which always uses the same port, so that
23 // the pages can be accessed with the same URLs after restoring the browser 26 // the pages can be accessed with the same URLs after restoring the browser
24 // session. 27 // session.
(...skipping 21 matching lines...) Expand all
46 title_storing_(ASCIIToUTF16("STORING")), 49 title_storing_(ASCIIToUTF16("STORING")),
47 title_error_write_failed_(ASCIIToUTF16("ERROR_WRITE_FAILED")), 50 title_error_write_failed_(ASCIIToUTF16("ERROR_WRITE_FAILED")),
48 title_error_empty_(ASCIIToUTF16("ERROR_EMPTY")) { 51 title_error_empty_(ASCIIToUTF16("ERROR_EMPTY")) {
49 CHECK(test_server_.Start()); 52 CHECK(test_server_.Start());
50 } 53 }
51 protected: 54 protected:
52 void StoreDataWithPage(const std::string& filename) { 55 void StoreDataWithPage(const std::string& filename) {
53 GURL url = test_server_.GetURL("files/session_restore/" + filename); 56 GURL url = test_server_.GetURL("files/session_restore/" + filename);
54 content::WebContents* web_contents = 57 content::WebContents* web_contents =
55 chrome::GetActiveWebContents(browser()); 58 chrome::GetActiveWebContents(browser());
56 string16 expected_title(title_storing_);
57 content::TitleWatcher title_watcher(web_contents, title_storing_); 59 content::TitleWatcher title_watcher(web_contents, title_storing_);
58 title_watcher.AlsoWaitForTitle(title_pass_); 60 title_watcher.AlsoWaitForTitle(title_pass_);
59 title_watcher.AlsoWaitForTitle(title_error_write_failed_); 61 title_watcher.AlsoWaitForTitle(title_error_write_failed_);
60 title_watcher.AlsoWaitForTitle(title_error_empty_); 62 title_watcher.AlsoWaitForTitle(title_error_empty_);
61 ui_test_utils::NavigateToURL(browser(), url); 63 ui_test_utils::NavigateToURL(browser(), url);
62 string16 final_title = title_watcher.WaitAndGetTitle(); 64 string16 final_title = title_watcher.WaitAndGetTitle();
63 EXPECT_EQ(title_storing_, final_title); 65 EXPECT_EQ(title_storing_, final_title);
64 } 66 }
65 67
66 void CheckReloadedPage() { 68 void CheckReloadedPage() {
(...skipping 26 matching lines...) Expand all
93 SessionStartupPref::SetStartupPref( 95 SessionStartupPref::SetStartupPref(
94 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); 96 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
95 StoreDataWithPage("session_cookies.html"); 97 StoreDataWithPage("session_cookies.html");
96 } 98 }
97 99
98 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionCookies) { 100 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionCookies) {
99 // The browsing session will be continued; just wait for the page to reload 101 // The browsing session will be continued; just wait for the page to reload
100 // and check the stored data. 102 // and check the stored data.
101 CheckReloadedPage(); 103 CheckReloadedPage();
102 } 104 }
105
106 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, PRE_SessionStorage) {
107 // Write the data on disk less lazily.
108 content::BrowserContext::GetDefaultStoragePartition(browser()->profile())->
109 GetDOMStorageContext()->DisableCommitDelayForTesting();
110 SessionStartupPref::SetStartupPref(
111 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
112 StoreDataWithPage("session_storage.html");
113 }
114
115 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionStorage) {
116 CheckReloadedPage();
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698