diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:48:06 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 16:48:06 +0000 |
commit | 74bad4b4c067b980ceb9d5b80c82ef67cc55826d (patch) | |
tree | 9cfc1d548ac07103615e3061bbc11dc6736e2b86 | |
parent | ce5c4504531cfd32972dfd123f98183c3706951a (diff) | |
download | chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.zip chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.tar.gz chromium_src-74bad4b4c067b980ceb9d5b80c82ef67cc55826d.tar.bz2 |
Adding a test for a testing that the bug http://crbug.com/9791 is really fixed.
Removing the interstitial UI tests: they test the same functionalities as the unit-tests but are flacky and
most of them have been disabled (a new unit-test for the "show interstitial and then navigate back" has been added to cover for a case that the unit-tests were not covering).
TEST=Run the unit-tests.
BUG=6729,3327
Review URL: http://codereview.chromium.org/109038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15416 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/interstitial_page_uitest.cc | 161 | ||||
-rw-r--r-- | chrome/browser/tab_contents/web_contents_unittest.cc | 76 | ||||
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/test/ui/ui_tests.vcproj | 48 |
4 files changed, 96 insertions, 190 deletions
diff --git a/chrome/browser/interstitial_page_uitest.cc b/chrome/browser/interstitial_page_uitest.cc deleted file mode 100644 index 844a92a..0000000 --- a/chrome/browser/interstitial_page_uitest.cc +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> - -#include "chrome/test/automation/tab_proxy.h" -#include "chrome/test/automation/browser_proxy.h" -#include "chrome/test/ui/ui_test.h" -#include "net/url_request/url_request_unittest.h" - -namespace { - -const wchar_t kDocRoot[] = L"chrome/test/data"; - -const std::string kInterstitialPageHTMLText = - "<html><head><title>Interstitial page</title></head><body><h1>This is an" - "interstitial page</h1></body></html>"; - - -class InterstitialPageTest : public UITest { - protected: - InterstitialPageTest() { - show_window_ = true; - } - - TabProxy* GetActiveTabProxy() { - scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); - EXPECT_TRUE(browser_proxy.get()); - - int active_tab_index = 0; - EXPECT_TRUE(browser_proxy->GetActiveTabIndex(&active_tab_index)); - return browser_proxy->GetTab(active_tab_index); - } - - void NavigateTab(TabProxy* tab_proxy, const GURL& url) { - ASSERT_TRUE(tab_proxy->NavigateToURL(url)); - } - - void AppendTab(const GURL& url) { - scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); - EXPECT_TRUE(browser_proxy.get()); - EXPECT_TRUE(browser_proxy->AppendTab(url)); - } -}; - -// Shows and hides an interstitial page. -// Note that we cannot rely on the page title in this case (and we use the page -// type instead) as showing an interstitial without creating a navigation entry -// causes the actual navigation entry (title) to be modified by the content of -// the interstitial. -// This test is disabled as it occasionally makes the ui tests stop running. -// See bug 6729. -TEST_F(InterstitialPageTest, DISABLED_TestShowHideInterstitial) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot, NULL); - ASSERT_TRUE(NULL != server.get()); - - ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); - NavigateTab(tab.get(), - server->TestServerPageW(L"files/interstitial_page/google.html")); - NavigationEntry::PageType page_type; - EXPECT_TRUE(tab->GetPageType(&page_type)); - EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); - - tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); - EXPECT_TRUE(tab->GetPageType(&page_type)); - EXPECT_EQ(NavigationEntry::INTERSTITIAL_PAGE, page_type); - - tab->HideInterstitialPage(); - EXPECT_TRUE(tab->GetPageType(&page_type)); - EXPECT_EQ(NavigationEntry::NORMAL_PAGE, page_type); -} - -// Shows an interstitial page then goes back. -// TODO(creis): We are disabling this test for now. We need to revisit -// whether the interstitial page should actually commit a NavigationEntry, -// because this clears the forward list and changes the meaning of back. It -// seems like the interstitial should not affect the NavigationController, -// who will remain in a pending state until the user either proceeds or cancels -// the interstitial. In the mean time, we are treating Back like cancelling -// the interstitial, which breaks this test because no notification occurs. -TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenBack) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot, NULL); - ASSERT_TRUE(NULL != server.get()); - - ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); - NavigateTab(tab.get(), - server->TestServerPageW(L"files/interstitial_page/google.html")); - EXPECT_EQ(L"Google", GetActiveTabTitle()); - - tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); - EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); - - tab->GoBack(); - EXPECT_EQ(L"Google", GetActiveTabTitle()); -} - -// Shows an interstitial page then navigates to a new URL. -// Flacky on Windows 2000 bot. Disabled for now bug #1173138. -TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenNavigate) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot, NULL); - ASSERT_TRUE(NULL != server.get()); - - ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); - NavigateTab(tab.get(), - server->TestServerPageW(L"files/interstitial_page/google.html")); - EXPECT_EQ(L"Google", GetActiveTabTitle()); - - tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); - EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); - - tab->NavigateToURL( - server->TestServerPageW(L"files/interstitial_page/shopping.html")); - EXPECT_EQ(L"Google Product Search", GetActiveTabTitle()); -} - -// Shows an interstitial page then closes the tab (to make sure we don't crash). -// This test is disabled as it occasionally makes the ui tests stop running. -// See bug 6729. -TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenCloseTab) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot, NULL); - ASSERT_TRUE(NULL != server.get()); - - // Create 2 tabs so closing one does not close the browser. - AppendTab(server->TestServerPageW(L"files/interstitial_page/google.html")); - ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); - EXPECT_EQ(L"Google", GetActiveTabTitle()); - - tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); - EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); - tab->Close(); -} - -// Shows an interstitial page then closes the browser (to make sure we don't -// crash). -// This test is disabled. See bug #1119448. -TEST_F(InterstitialPageTest, DISABLED_TestShowInterstitialThenCloseBrowser) { - scoped_refptr<HTTPTestServer> server = - HTTPTestServer::CreateServer(kDocRoot, NULL); - ASSERT_TRUE(NULL != server.get()); - - ::scoped_ptr<TabProxy> tab(GetActiveTabProxy()); - tab->NavigateToURL( - server->TestServerPageW(L"files/interstitial_page/google.html")); - EXPECT_EQ(L"Google", GetActiveTabTitle()); - - tab->ShowInterstitialPage(kInterstitialPageHTMLText, action_timeout_ms()); - EXPECT_EQ(L"Interstitial page", GetActiveTabTitle()); - - scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); - EXPECT_TRUE(browser_proxy.get()); - bool application_closed; - EXPECT_TRUE(CloseBrowser(browser_proxy.get(), &application_closed)); - EXPECT_TRUE(application_closed); -} - -} // namespace diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index e9367e6..97e09a5 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -902,6 +902,38 @@ TEST_F(TabContentsTest, ShowInterstitialThenNavigate) { EXPECT_EQ(TestInterstitialPage::CANCELED, state); } +// Test navigating to a page that shows an interstitial, then going back. +TEST_F(TabContentsTest, ShowInterstitialThenGoBack) { + // Navigate to a page so we have a navigation entry in the controller. + GURL url1("http://www.google.com"); + rvh()->SendNavigate(1, url1); + EXPECT_EQ(1, controller().entry_count()); + + // Show interstitial. + TestInterstitialPage::InterstitialState state = + TestInterstitialPage::UNDECIDED; + bool deleted = false; + GURL interstitial_url("http://interstitial"); + TestInterstitialPage* interstitial = + new TestInterstitialPage(contents(), true, interstitial_url, + &state, &deleted); + TestInterstitialPageStateGuard state_guard(interstitial); + interstitial->Show(); + interstitial->TestDidNavigate(2, interstitial_url); + + // While the interstitial is showing, go back. + controller().GoBack(); + rvh()->SendNavigate(1, url1); + + // Make sure we are back to the original page and that the interstitial is + // gone. + EXPECT_TRUE(deleted); + EXPECT_EQ(TestInterstitialPage::CANCELED, state); + NavigationEntry* entry = controller().GetActiveEntry(); + ASSERT_TRUE(entry); + EXPECT_EQ(url1.spec(), entry->url().spec()); +} + // Test navigating to a page that shows an interstitial, then close the tab. TEST_F(TabContentsTest, ShowInterstitialThenCloseTab) { // Show interstitial. @@ -1117,3 +1149,47 @@ TEST_F(TabContentsTest, InterstitialCrasher) { EXPECT_TRUE(deleted); EXPECT_EQ(TestInterstitialPage::CANCELED, state); } + +// Tests that showing an interstitial as a result of a browser initiated +// navigation while an interstitial is showing does not remove the pending +// entry (see http://crbug.com/9791). +TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) { + const char kUrl[] = "http://www.badguys.com/"; + const GURL kGURL(kUrl); + + // Start a navigation to a page + contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED); + + // Simulate that navigation triggering an interstitial. + TestInterstitialPage::InterstitialState state = + TestInterstitialPage::UNDECIDED; + bool deleted = false; + TestInterstitialPage* interstitial = + new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); + TestInterstitialPageStateGuard state_guard(interstitial); + interstitial->Show(); + interstitial->TestDidNavigate(1, kGURL); + + // Initiate a new navigation from the browser that also triggers an + // interstitial. + contents()->controller().LoadURL(kGURL, GURL(), PageTransition::TYPED); + TestInterstitialPage::InterstitialState state2 = + TestInterstitialPage::UNDECIDED; + bool deleted2 = false; + TestInterstitialPage* interstitial2 = + new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); + TestInterstitialPageStateGuard state_guard2(interstitial2); + interstitial2->Show(); + interstitial2->TestDidNavigate(1, kGURL); + + // Make sure we still have an entry. + NavigationEntry* entry = contents()->controller().pending_entry(); + ASSERT_TRUE(entry); + EXPECT_EQ(kUrl, entry->url().spec()); + + // And that the first interstitial is gone, but not the second. + EXPECT_TRUE(deleted); + EXPECT_EQ(TestInterstitialPage::CANCELED, state); + EXPECT_FALSE(deleted2); + EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); +} diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index d2a9820..b472122 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2228,7 +2228,6 @@ 'browser/history/redirect_uitest.cc', 'browser/iframe_uitest.cc', 'browser/images_uitest.cc', - 'browser/interstitial_page_uitest.cc', 'browser/locale_tests_uitest.cc', 'browser/login_prompt_uitest.cc', 'browser/metrics/metrics_service_uitest.cc', diff --git a/chrome/test/ui/ui_tests.vcproj b/chrome/test/ui/ui_tests.vcproj index ea13ea6..b72989e 100644 --- a/chrome/test/ui/ui_tests.vcproj +++ b/chrome/test/ui/ui_tests.vcproj @@ -146,55 +146,55 @@ Name="Common" > <File - RelativePath=".\npapi_test_helper.cc" + RelativePath="..\chrome_process_util.cc" > </File> <File - RelativePath=".\npapi_test_helper.h" + RelativePath="..\chrome_process_util.h" > </File> <File - RelativePath="..\..\tools\build\win\precompiled_wtl.cc" + RelativePath="..\chrome_process_util_win.cc" > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="1" - /> - </FileConfiguration> </File> <File - RelativePath="..\..\tools\build\win\precompiled_wtl.h" + RelativePath=".\javascript_test_util.cc" > </File> <File - RelativePath=".\run_all_unittests.cc" + RelativePath=".\javascript_test_util.h" > </File> <File - RelativePath="..\chrome_process_util.cc" + RelativePath=".\npapi_test_helper.cc" > </File> <File - RelativePath="..\chrome_process_util.h" + RelativePath=".\npapi_test_helper.h" > </File> <File - RelativePath="..\chrome_process_util_win.cc" + RelativePath="..\..\tools\build\win\precompiled_wtl.cc" > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> </File> <File - RelativePath="..\testing_browser_process.h" + RelativePath="..\..\tools\build\win\precompiled_wtl.h" > </File> <File - RelativePath=".\javascript_test_util.cc" + RelativePath=".\run_all_unittests.cc" > </File> <File - RelativePath=".\javascript_test_util.h" + RelativePath="..\testing_browser_process.h" > </File> <File @@ -418,7 +418,7 @@ Name="TestAutomatedUI" > <File - RelativePath="..\automated_ui_tests\automated_ui_test_base.cc" + RelativePath="..\automated_ui_tests\automated_ui_test_base.cc" > </File> <File @@ -463,14 +463,6 @@ </File> </Filter> <Filter - Name="TestInterstitialPage" - > - <File - RelativePath="..\..\browser\interstitial_page_uitest.cc" - > - </File> - </Filter> - <Filter Name="TestSSL" > <File |