diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 17:48:58 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 17:48:58 +0000 |
commit | 5cba5533b1c119c16d7f580debba17c023d49943 (patch) | |
tree | 641090a854eced04e9f3f784038a14760c260611 /chrome/browser/history | |
parent | 8d9a7abe4dcca2cb6879ba7f8406ed1e9c58c67d (diff) | |
download | chromium_src-5cba5533b1c119c16d7f580debba17c023d49943.zip chromium_src-5cba5533b1c119c16d7f580debba17c023d49943.tar.gz chromium_src-5cba5533b1c119c16d7f580debba17c023d49943.tar.bz2 |
Convert history ui_test to browser_tests.
BUG=121574
Review URL: https://chromiumcodereview.appspot.com/10125001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/history_browsertest.cc | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/chrome/browser/history/history_browsertest.cc b/chrome/browser/history/history_browsertest.cc index 272dbbb..a9f7d35 100644 --- a/chrome/browser/history/history_browsertest.cc +++ b/chrome/browser/history/history_browsertest.cc @@ -5,11 +5,14 @@ #include <vector> #include "base/bind.h" +#include "base/command_line.h" #include "base/message_loop.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/history/history.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" @@ -80,8 +83,14 @@ class HistoryEnumerator : public HistoryService::URLEnumerator { DISALLOW_COPY_AND_ASSIGN(HistoryEnumerator); }; +} // namespace + class HistoryBrowserTest : public InProcessBrowserTest { protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + command_line->AppendSwitch(switches::kEnableFileCookies); + } + PrefService* GetPrefs() { return GetProfile()->GetPrefs(); } @@ -120,6 +129,22 @@ class HistoryBrowserTest : public InProcessBrowserTest { std::vector<GURL> urls(GetHistoryContents()); EXPECT_EQ(0U, urls.size()); } + + void LoadAndWaitForURL(const GURL& url) { + string16 expected_title(ASCIIToUTF16("OK")); + ui_test_utils::TitleWatcher title_watcher( + browser()->GetSelectedWebContents(), expected_title); + title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); + ui_test_utils::NavigateToURL(browser(), url); + EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); + } + + void LoadAndWaitForFile(const char* filename) { + GURL url = ui_test_utils::GetTestUrl( + FilePath().AppendASCII("History"), + FilePath().AppendASCII(filename)); + LoadAndWaitForURL(url); + } }; // Test that the browser history is saved (default setting). @@ -210,4 +235,52 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryDisabledThenEnabled) { } } -} // namespace +IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength1) { + // Test the history length for the following page transitions. + // -open-> Page 1. + LoadAndWaitForFile("history_length_test_page_1.html"); +} + +IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength2) { + // Test the history length for the following page transitions. + // -open-> Page 2 -redirect-> Page 3. + LoadAndWaitForFile("history_length_test_page_2.html"); +} + +IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, VerifyHistoryLength3) { + // Test the history length for the following page transitions. + // -open-> Page 1 -> open Page 2 -redirect Page 3. open Page 4 + // -navigate_backward-> Page 3 -navigate_backward->Page 1 + // -navigate_forward-> Page 3 -navigate_forward-> Page 4 + LoadAndWaitForFile("history_length_test_page_1.html"); + LoadAndWaitForFile("history_length_test_page_2.html"); + LoadAndWaitForFile("history_length_test_page_4.html"); +} + +IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, + ConsiderRedirectAfterGestureAsUserInitiated) { + // Test the history length for the following page transition. + // + // -open-> Page 11 -slow_redirect-> Page 12. + // + // If redirect occurs after a user gesture, e.g., mouse click, the + // redirect is more likely to be user-initiated rather than automatic. + // Therefore, Page 11 should be in the history in addition to Page 12. + LoadAndWaitForFile("history_length_test_page_11.html"); + + ui_test_utils::SimulateMouseClick( + browser()->GetSelectedWebContents(), 20, 20); + LoadAndWaitForFile("history_length_test_page_11.html"); +} + +IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, + ConsiderSlowRedirectAsUserInitiated) { + // Test the history length for the following page transition. + // + // -open-> Page 21 -redirect-> Page 22. + // + // If redirect occurs more than 5 seconds later after the page is loaded, + // the redirect is likely to be user-initiated. + // Therefore, Page 21 should be in the history in addition to Page 22. + LoadAndWaitForFile("history_length_test_page_21.html"); +} |