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

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: export inner 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/test/data/session_restore/session_storage.html » ('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/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/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_tabstrip.h" 11 #include "chrome/browser/ui/browser_tabstrip.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 #include "webkit/dom_storage/dom_storage_area.h"
18 19
19 namespace { 20 namespace {
20 21
21 // The tests server is started separately for each test function (including PRE_ 22 // 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 23 // 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 24 // the pages can be accessed with the same URLs after restoring the browser
24 // session. 25 // session.
25 class FixedPortTestServer : public net::LocalTestServer { 26 class FixedPortTestServer : public net::LocalTestServer {
26 public: 27 public:
27 explicit FixedPortTestServer(uint16 port) 28 explicit FixedPortTestServer(uint16 port)
(...skipping 18 matching lines...) Expand all
46 title_storing_(ASCIIToUTF16("STORING")), 47 title_storing_(ASCIIToUTF16("STORING")),
47 title_error_write_failed_(ASCIIToUTF16("ERROR_WRITE_FAILED")), 48 title_error_write_failed_(ASCIIToUTF16("ERROR_WRITE_FAILED")),
48 title_error_empty_(ASCIIToUTF16("ERROR_EMPTY")) { 49 title_error_empty_(ASCIIToUTF16("ERROR_EMPTY")) {
49 CHECK(test_server_.Start()); 50 CHECK(test_server_.Start());
50 } 51 }
51 protected: 52 protected:
52 void StoreDataWithPage(const std::string& filename) { 53 void StoreDataWithPage(const std::string& filename) {
53 GURL url = test_server_.GetURL("files/session_restore/" + filename); 54 GURL url = test_server_.GetURL("files/session_restore/" + filename);
54 content::WebContents* web_contents = 55 content::WebContents* web_contents =
55 chrome::GetActiveWebContents(browser()); 56 chrome::GetActiveWebContents(browser());
56 string16 expected_title(title_storing_);
57 content::TitleWatcher title_watcher(web_contents, title_storing_); 57 content::TitleWatcher title_watcher(web_contents, title_storing_);
58 title_watcher.AlsoWaitForTitle(title_pass_); 58 title_watcher.AlsoWaitForTitle(title_pass_);
59 title_watcher.AlsoWaitForTitle(title_error_write_failed_); 59 title_watcher.AlsoWaitForTitle(title_error_write_failed_);
60 title_watcher.AlsoWaitForTitle(title_error_empty_); 60 title_watcher.AlsoWaitForTitle(title_error_empty_);
61 ui_test_utils::NavigateToURL(browser(), url); 61 ui_test_utils::NavigateToURL(browser(), url);
62 string16 final_title = title_watcher.WaitAndGetTitle(); 62 string16 final_title = title_watcher.WaitAndGetTitle();
63 EXPECT_EQ(title_storing_, final_title); 63 EXPECT_EQ(title_storing_, final_title);
64 } 64 }
65 65
66 void CheckReloadedPage() { 66 void CheckReloadedPage() {
(...skipping 26 matching lines...) Expand all
93 SessionStartupPref::SetStartupPref( 93 SessionStartupPref::SetStartupPref(
94 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); 94 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
95 StoreDataWithPage("session_cookies.html"); 95 StoreDataWithPage("session_cookies.html");
96 } 96 }
97 97
98 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionCookies) { 98 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionCookies) {
99 // The browsing session will be continued; just wait for the page to reload 99 // The browsing session will be continued; just wait for the page to reload
100 // and check the stored data. 100 // and check the stored data.
101 CheckReloadedPage(); 101 CheckReloadedPage();
102 } 102 }
103
104 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, PRE_SessionStorage) {
105 // Write the data on disk less lazily.
106 dom_storage::DomStorageArea::DisableCommitDelayForTesting();
107 SessionStartupPref::SetStartupPref(
108 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
109 StoreDataWithPage("session_storage.html");
110 }
111
112 IN_PROC_BROWSER_TEST_F(BetterSessionRestoreTest, SessionStorage) {
113 CheckReloadedPage();
114 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/session_restore/session_storage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698