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

Unified Diff: chrome/browser/ui/search/instant_search_prerenderer_unittest.cc

Issue 141893009: Create a new helper function to extract search terms from the URL irrespective of the availablility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/instant_search_prerenderer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
diff --git a/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc b/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
index d40210aa52177ed83d4d951e35387d81529c7a47..9216c4e7849c00d10e90d05513fd2842ac705d55 100644
--- a/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
+++ b/chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
@@ -238,14 +238,14 @@ TEST_F(InstantSearchPrerendererTest, GetSearchTermsFromPrerenderedPage) {
EXPECT_EQ(GURL("https://www.google.com/instant?ion=1&foo=foo#foo=foo&strk"),
url);
EXPECT_EQ(UTF16ToASCII(prerenderer->get_last_query()),
- UTF16ToASCII(chrome::GetSearchTermsFromURL(profile(), url)));
+ UTF16ToASCII(chrome::ExtractSearchTermsFromURL(profile(), url)));
// Assume the prerendered page prefetched search results for the query
// "flowers".
SetLastQuery(ASCIIToUTF16("flowers"));
EXPECT_EQ("flowers", UTF16ToASCII(prerenderer->get_last_query()));
EXPECT_EQ(UTF16ToASCII(prerenderer->get_last_query()),
- UTF16ToASCII(chrome::GetSearchTermsFromURL(profile(), url)));
+ UTF16ToASCII(chrome::ExtractSearchTermsFromURL(profile(), url)));
}
TEST_F(InstantSearchPrerendererTest, PrefetchSearchResults) {
@@ -336,8 +336,8 @@ TEST_F(InstantSearchPrerendererTest, PrerenderingAllowed) {
// used only when the underlying page doesn't support Instant.
NavigateAndCommitActiveTab(GURL("https://www.google.com/alt#quux=foo&strk"));
active_tab = GetActiveWebContents();
- EXPECT_FALSE(chrome::GetSearchTermsFromURL(profile(), active_tab->GetURL())
- .empty());
+ EXPECT_FALSE(chrome::ExtractSearchTermsFromURL(profile(),
+ active_tab->GetURL()).empty());
EXPECT_FALSE(chrome::ShouldPrefetchSearchResultsOnSRP());
EXPECT_FALSE(prerenderer->IsAllowed(search_type_match, active_tab));
}
@@ -448,3 +448,31 @@ TEST_F(ReuseInstantSearchBasePageTest,
EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
ASCIIToUTF16("joy")));
}
+
+#if !defined(OS_IOS) && !defined(OS_ANDROID)
+class TestUsePrerenderPage : public InstantSearchPrerendererTest {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ // Disable query extraction flag in field trials.
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "EmbeddedSearch",
+ "Group1 strk:20 query_extraction:0 prefetch_results:1"));
+ InstantUnitTestBase::SetUpWithoutQueryExtraction();
+ }
+};
+
+TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) {
+ PrerenderSearchQuery(ASCIIToUTF16("foo"));
+
+ // Open a search results page. Query extraction flag is disabled in field
+ // trials. Search results page URL does not contain search terms replacement
+ // key. Make sure UsePrerenderedPage() extracts the search terms from the URL
+ // and uses the prerendered page contents.
+ GURL url("https://www.google.com/alt#quux=foo");
+ browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
+ content::PAGE_TRANSITION_TYPED,
+ false));
+ EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
+ EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
+}
+#endif
« no previous file with comments | « chrome/browser/ui/search/instant_search_prerenderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698