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

Side by Side Diff: chrome/browser/ui/search/instant_search_prerenderer_unittest.cc

Issue 2211983002: Remove search::IsQueryExtractionEnabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_prefetch_non_default
Patch Set: remove more tests Created 4 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/search/instant_search_prerenderer.h" 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 TemplateURL* template_url = 340 TemplateURL* template_url =
341 custom_search_type_match.GetTemplateURL(service, false); 341 custom_search_type_match.GetTemplateURL(service, false);
342 EXPECT_TRUE(template_url); 342 EXPECT_TRUE(template_url);
343 EXPECT_TRUE(AutocompleteMatch::IsSearchType(custom_search_type_match.type)); 343 EXPECT_TRUE(AutocompleteMatch::IsSearchType(custom_search_type_match.type));
344 EXPECT_FALSE(prerenderer->IsAllowed(custom_search_type_match, active_tab)); 344 EXPECT_FALSE(prerenderer->IsAllowed(custom_search_type_match, active_tab));
345 345
346 AutocompleteMatch url_type_match(NULL, 1100, true, 346 AutocompleteMatch url_type_match(NULL, 1100, true,
347 AutocompleteMatchType::URL_WHAT_YOU_TYPED); 347 AutocompleteMatchType::URL_WHAT_YOU_TYPED);
348 EXPECT_FALSE(AutocompleteMatch::IsSearchType(url_type_match.type)); 348 EXPECT_FALSE(AutocompleteMatch::IsSearchType(url_type_match.type));
349 EXPECT_FALSE(prerenderer->IsAllowed(url_type_match, active_tab)); 349 EXPECT_FALSE(prerenderer->IsAllowed(url_type_match, active_tab));
350
351 // Search results page supports Instant search. InstantSearchPrerenderer is
352 // used only when the underlying page doesn't support Instant.
353 NavigateAndCommitActiveTab(GURL("https://www.google.com/alt#quux=foo&strk"));
354 active_tab = GetActiveWebContents();
355 EXPECT_FALSE(
356 search::ExtractSearchTermsFromURL(profile(), active_tab->GetURL())
357 .empty());
358 EXPECT_FALSE(prerenderer->IsAllowed(search_type_match, active_tab));
359 } 350 }
360 351
361 TEST_F(InstantSearchPrerendererTest, UsePrerenderPage) { 352 TEST_F(InstantSearchPrerendererTest, UsePrerenderPage) {
362 PrerenderSearchQuery(ASCIIToUTF16("foo")); 353 PrerenderSearchQuery(ASCIIToUTF16("foo"));
363 354
364 // Open a search results page. A prerendered page exists for |url|. Make sure 355 // Open a search results page. A prerendered page exists for |url|. Make sure
365 // the browser swaps the current tab contents with the prerendered contents. 356 // the browser swaps the current tab contents with the prerendered contents.
366 GURL url("https://www.google.com/alt#quux=foo&strk"); 357 GURL url("https://www.google.com/alt#quux=foo&strk");
367 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, 358 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
368 ui::PAGE_TRANSITION_TYPED, 359 ui::PAGE_TRANSITION_TYPED,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 465
475 // When the Instant search base page hasn't finished loading, 466 // When the Instant search base page hasn't finished loading,
476 // InstantSearchPrerenderer cannot commit any search query to the base page. 467 // InstantSearchPrerenderer cannot commit any search query to the base page.
477 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query)); 468 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
478 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), 469 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
479 ASCIIToUTF16("joy"))); 470 ASCIIToUTF16("joy")));
480 } 471 }
481 472
482 #if !defined(OS_ANDROID) 473 #if !defined(OS_ANDROID)
483 class TestUsePrerenderPage : public InstantSearchPrerendererTest { 474 class TestUsePrerenderPage : public InstantSearchPrerendererTest {
484 protected:
485 void SetUp() override {
486 // Disable query extraction flag in field trials.
487 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
488 "EmbeddedSearch", "Group1 strk:20 query_extraction:0"));
489 InstantUnitTestBase::SetUpWithoutQueryExtraction();
490 }
491 }; 475 };
492 476
493 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) { 477 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) {
494 PrerenderSearchQuery(ASCIIToUTF16("foo")); 478 PrerenderSearchQuery(ASCIIToUTF16("foo"));
495 479
496 // Open a search results page. Query extraction flag is disabled in field 480 // Open a search results page. Query extraction flag is disabled in field
497 // trials. Search results page URL does not contain search terms replacement 481 // trials. Search results page URL does not contain search terms replacement
498 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL 482 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL
499 // and uses the prerendered page contents. 483 // and uses the prerendered page contents.
500 GURL url("https://www.google.com/alt#quux=foo"); 484 GURL url("https://www.google.com/alt#quux=foo");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 std::tuple<base::string16, EmbeddedSearchRequestParams> params; 521 std::tuple<base::string16, EmbeddedSearchRequestParams> params;
538 ChromeViewMsg_SearchBoxSubmit::Read(message, &params); 522 ChromeViewMsg_SearchBoxSubmit::Read(message, &params);
539 EXPECT_EQ("foo", base::UTF16ToASCII(std::get<0>(params))); 523 EXPECT_EQ("foo", base::UTF16ToASCII(std::get<0>(params)));
540 EXPECT_EQ("f", base::UTF16ToASCII(std::get<1>(params).original_query)); 524 EXPECT_EQ("f", base::UTF16ToASCII(std::get<1>(params).original_query));
541 EXPECT_EQ("utf-8", base::UTF16ToASCII(std::get<1>(params).input_encoding)); 525 EXPECT_EQ("utf-8", base::UTF16ToASCII(std::get<1>(params).input_encoding));
542 EXPECT_EQ("", base::UTF16ToASCII(std::get<1>(params).rlz_parameter_value)); 526 EXPECT_EQ("", base::UTF16ToASCII(std::get<1>(params).rlz_parameter_value));
543 EXPECT_EQ("chrome...0", 527 EXPECT_EQ("chrome...0",
544 base::UTF16ToASCII(std::get<1>(params).assisted_query_stats)); 528 base::UTF16ToASCII(std::get<1>(params).assisted_query_stats));
545 } 529 }
546 #endif 530 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698