| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "base/metrics/histogram_base.h" | 7 #include "base/metrics/histogram_base.h" |
| 8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 EXPECT_EQ(test.same_site_instance, | 421 EXPECT_EQ(test.same_site_instance, |
| 422 start_rvh == contents->GetRenderViewHost()) | 422 start_rvh == contents->GetRenderViewHost()) |
| 423 << test.description; | 423 << test.description; |
| 424 EXPECT_EQ(test.same_site_instance, | 424 EXPECT_EQ(test.same_site_instance, |
| 425 start_rph == contents->GetRenderProcessHost()) | 425 start_rph == contents->GetRenderProcessHost()) |
| 426 << test.description; | 426 << test.description; |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 const SearchTestCase kInstantNTPTestCases[] = { | 430 const SearchTestCase kInstantNTPTestCases[] = { |
| 431 {"https://foo.com/instant?strk", true, "Valid Instant URL"}, | 431 {"https://foo.com/instant?strk", false, "Valid Instant URL"}, |
| 432 {"https://foo.com/instant#strk", true, "Valid Instant URL"}, | 432 {"https://foo.com/instant#strk", false, "Valid Instant URL"}, |
| 433 {"https://foo.com/url?strk", true, "Valid search URL"}, | 433 {"https://foo.com/url?strk", false, "Valid search URL"}, |
| 434 {"https://foo.com/url#strk", true, "Valid search URL"}, | 434 {"https://foo.com/url#strk", false, "Valid search URL"}, |
| 435 {"https://foo.com/alt?strk", true, "Valid alternative URL"}, | 435 {"https://foo.com/alt?strk", false, "Valid alternative URL"}, |
| 436 {"https://foo.com/alt#strk", true, "Valid alternative URL"}, | 436 {"https://foo.com/alt#strk", false, "Valid alternative URL"}, |
| 437 {"https://foo.com/url?strk&bar=", true, "No query terms"}, | 437 {"https://foo.com/url?strk&bar=", false, "No query terms"}, |
| 438 {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, | 438 {"https://foo.com/url?strk&q=abc", false, "No query terms key"}, |
| 439 {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, | 439 {"https://foo.com/url?strk#bar=abc", false, "Query terms key in ref"}, |
| 440 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, | 440 {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
| 441 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, | 441 {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
| 442 {"https://foo.com/instant", false, "No search term replacement"}, | 442 {"https://foo.com/instant", false, "No search term replacement"}, |
| 443 {"chrome://blank/", false, "Chrome scheme"}, | 443 {"chrome://blank/", false, "Chrome scheme"}, |
| 444 {"chrome-search://foo", false, "Chrome-search scheme"}, | 444 {"chrome-search://foo", false, "Chrome-search scheme"}, |
| 445 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
| 445 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, | 446 {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
| 446 {"https://bar.com/instant?strk=1", false, "Random non-search page"}, | 447 {"https://foo.com/newtab?strk", true, "New tab URL"}, |
| 448 {"http://foo.com/newtab?strk", false, "Insecure New tab URL"}, |
| 447 }; | 449 }; |
| 448 | 450 |
| 449 TEST_F(SearchTest, InstantNTPExtendedEnabled) { | 451 TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
| 450 EnableQueryExtractionForTesting(); | 452 EnableQueryExtractionForTesting(); |
| 451 // TODO(samarth): update test cases to use cacheable NTP URLs and remove this. | |
| 452 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 453 "InstantExtended", "Group1 use_cacheable_ntp:0")); | |
| 454 AddTab(browser(), GURL("chrome://blank")); | 453 AddTab(browser(), GURL("chrome://blank")); |
| 455 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { | 454 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
| 456 const SearchTestCase& test = kInstantNTPTestCases[i]; | 455 const SearchTestCase& test = kInstantNTPTestCases[i]; |
| 457 NavigateAndCommitActiveTab(GURL(test.url)); | 456 NavigateAndCommitActiveTab(GURL(test.url)); |
| 458 const content::WebContents* contents = | 457 const content::WebContents* contents = |
| 459 browser()->tab_strip_model()->GetWebContentsAt(0); | 458 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 460 EXPECT_EQ(test.expected_result, IsInstantNTP(contents)) | 459 EXPECT_EQ(test.expected_result, IsInstantNTP(contents)) |
| 461 << test.url << " " << test.comment; | 460 << test.url << " " << test.comment; |
| 462 } | 461 } |
| 463 } | 462 } |
| 464 | 463 |
| 465 TEST_F(SearchTest, InstantNTPCustomNavigationEntry) { | 464 TEST_F(SearchTest, InstantNTPCustomNavigationEntry) { |
| 466 EnableQueryExtractionForTesting(); | 465 EnableQueryExtractionForTesting(); |
| 467 // TODO(samarth): update test cases to use cacheable NTP URLs and remove this. | |
| 468 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 469 "InstantExtended", "Group1 use_cacheable_ntp:0")); | |
| 470 AddTab(browser(), GURL("chrome://blank")); | 466 AddTab(browser(), GURL("chrome://blank")); |
| 471 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { | 467 for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
| 472 const SearchTestCase& test = kInstantNTPTestCases[i]; | 468 const SearchTestCase& test = kInstantNTPTestCases[i]; |
| 473 NavigateAndCommitActiveTab(GURL(test.url)); | 469 NavigateAndCommitActiveTab(GURL(test.url)); |
| 474 content::WebContents* contents = | 470 content::WebContents* contents = |
| 475 browser()->tab_strip_model()->GetWebContentsAt(0); | 471 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 476 content::NavigationController& controller = contents->GetController(); | 472 content::NavigationController& controller = contents->GetController(); |
| 477 controller.SetTransientEntry( | 473 controller.SetTransientEntry( |
| 478 controller.CreateNavigationEntry(GURL("chrome://blank"), | 474 controller.CreateNavigationEntry(GURL("chrome://blank"), |
| 479 content::Referrer(), | 475 content::Referrer(), |
| 480 content::PAGE_TRANSITION_LINK, | 476 content::PAGE_TRANSITION_LINK, |
| 481 false, | 477 false, |
| 482 std::string(), | 478 std::string(), |
| 483 contents->GetBrowserContext())); | 479 contents->GetBrowserContext())); |
| 484 // The active entry is chrome://blank and not an NTP. | 480 // The active entry is chrome://blank and not an NTP. |
| 485 EXPECT_FALSE(IsInstantNTP(contents)); | 481 EXPECT_FALSE(IsInstantNTP(contents)); |
| 486 EXPECT_EQ(test.expected_result, | 482 EXPECT_EQ(test.expected_result, |
| 487 NavEntryIsInstantNTP(contents, | 483 NavEntryIsInstantNTP(contents, |
| 488 controller.GetLastCommittedEntry())) | 484 controller.GetLastCommittedEntry())) |
| 489 << test.url << " " << test.comment; | 485 << test.url << " " << test.comment; |
| 490 } | 486 } |
| 491 } | 487 } |
| 492 | 488 |
| 493 TEST_F(SearchTest, InstantCacheableNTPNavigationEntry) { | 489 TEST_F(SearchTest, InstantCacheableNTPNavigationEntry) { |
| 494 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 495 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 496 | |
| 497 AddTab(browser(), GURL("chrome://blank")); | 490 AddTab(browser(), GURL("chrome://blank")); |
| 498 content::WebContents* contents = | 491 content::WebContents* contents = |
| 499 browser()->tab_strip_model()->GetWebContentsAt(0); | 492 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 500 content::NavigationController& controller = contents->GetController(); | 493 content::NavigationController& controller = contents->GetController(); |
| 501 // Local NTP. | 494 // Local NTP. |
| 502 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 495 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 503 EXPECT_TRUE(NavEntryIsInstantNTP(contents, | 496 EXPECT_TRUE(NavEntryIsInstantNTP(contents, |
| 504 controller.GetLastCommittedEntry())); | 497 controller.GetLastCommittedEntry())); |
| 505 // Instant page is not cacheable NTP. | 498 // Instant page is not cacheable NTP. |
| 506 NavigateAndCommitActiveTab(GetInstantURL(profile(), kDisableStartMargin, | 499 NavigateAndCommitActiveTab(GetInstantURL(profile(), kDisableStartMargin, |
| 507 false)); | 500 false)); |
| 508 EXPECT_FALSE(NavEntryIsInstantNTP(contents, | 501 EXPECT_FALSE(NavEntryIsInstantNTP(contents, |
| 509 controller.GetLastCommittedEntry())); | 502 controller.GetLastCommittedEntry())); |
| 510 // Test Cacheable NTP | 503 // Test Cacheable NTP |
| 511 NavigateAndCommitActiveTab(chrome::GetNewTabPageURL(profile())); | 504 NavigateAndCommitActiveTab(chrome::GetNewTabPageURL(profile())); |
| 512 EXPECT_TRUE(NavEntryIsInstantNTP(contents, | 505 EXPECT_TRUE(NavEntryIsInstantNTP(contents, |
| 513 controller.GetLastCommittedEntry())); | 506 controller.GetLastCommittedEntry())); |
| 514 } | 507 } |
| 515 | 508 |
| 516 TEST_F(SearchTest, InstantCacheableNTPNavigationEntryNewProfile) { | 509 TEST_F(SearchTest, InstantCacheableNTPNavigationEntryNewProfile) { |
| 517 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 518 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 519 SetSearchProvider(false, false); | 510 SetSearchProvider(false, false); |
| 520 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); | 511 AddTab(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 521 content::WebContents* contents = | 512 content::WebContents* contents = |
| 522 browser()->tab_strip_model()->GetWebContentsAt(0); | 513 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 523 content::NavigationController& controller = contents->GetController(); | 514 content::NavigationController& controller = contents->GetController(); |
| 524 // Test virtual url chrome://newtab for first NTP of a new profile | 515 // Test virtual url chrome://newtab for first NTP of a new profile |
| 525 EXPECT_TRUE(NavEntryIsInstantNTP(contents, | 516 EXPECT_TRUE(NavEntryIsInstantNTP(contents, |
| 526 controller.GetLastCommittedEntry())); | 517 controller.GetLastCommittedEntry())); |
| 527 // The new_tab_url gets set after the first NTP is visible. | 518 // The new_tab_url gets set after the first NTP is visible. |
| 528 SetSearchProvider(true, false); | 519 SetSearchProvider(true, false); |
| 529 EXPECT_TRUE(NavEntryIsInstantNTP(contents, | 520 EXPECT_TRUE(NavEntryIsInstantNTP(contents, |
| 530 controller.GetLastCommittedEntry())); | 521 controller.GetLastCommittedEntry())); |
| 531 } | 522 } |
| 532 | 523 |
| 533 TEST_F(SearchTest, UseLocalNTPInIncognito) { | 524 TEST_F(SearchTest, UseLocalNTPInIncognito) { |
| 534 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 535 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 536 EXPECT_EQ(GURL(), chrome::GetNewTabPageURL( | 525 EXPECT_EQ(GURL(), chrome::GetNewTabPageURL( |
| 537 profile()->GetOffTheRecordProfile())); | 526 profile()->GetOffTheRecordProfile())); |
| 538 } | 527 } |
| 539 | 528 |
| 540 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) { | 529 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsInsecure) { |
| 541 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 542 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 543 // Set an insecure new tab page URL and verify that it's ignored. | 530 // Set an insecure new tab page URL and verify that it's ignored. |
| 544 SetSearchProvider(true, true); | 531 SetSearchProvider(true, true); |
| 545 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 532 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
| 546 chrome::GetNewTabPageURL(profile())); | 533 chrome::GetNewTabPageURL(profile())); |
| 547 } | 534 } |
| 548 | 535 |
| 549 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { | 536 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) { |
| 550 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 551 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 552 // Set an insecure new tab page URL and verify that it's ignored. | 537 // Set an insecure new tab page URL and verify that it's ignored. |
| 553 SetSearchProvider(false, true); | 538 SetSearchProvider(false, true); |
| 554 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 539 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
| 555 chrome::GetNewTabPageURL(profile())); | 540 chrome::GetNewTabPageURL(profile())); |
| 556 } | 541 } |
| 557 | 542 |
| 558 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) { | 543 TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) { |
| 559 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 560 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 561 | |
| 562 // Block access to foo.com in the URL filter. | 544 // Block access to foo.com in the URL filter. |
| 563 ManagedUserService* managed_user_service = | 545 ManagedUserService* managed_user_service = |
| 564 ManagedUserServiceFactory::GetForProfile(profile()); | 546 ManagedUserServiceFactory::GetForProfile(profile()); |
| 565 ManagedModeURLFilter* url_filter = | 547 ManagedModeURLFilter* url_filter = |
| 566 managed_user_service->GetURLFilterForUIThread(); | 548 managed_user_service->GetURLFilterForUIThread(); |
| 567 std::map<std::string, bool> hosts; | 549 std::map<std::string, bool> hosts; |
| 568 hosts["foo.com"] = false; | 550 hosts["foo.com"] = false; |
| 569 url_filter->SetManualHosts(&hosts); | 551 url_filter->SetManualHosts(&hosts); |
| 570 | 552 |
| 571 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 553 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 640 |
| 659 // If we specify extra search query params, they should be inserted into the | 641 // If we specify extra search query params, they should be inserted into the |
| 660 // query portion of the instant URL. | 642 // query portion of the instant URL. |
| 661 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 643 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 662 switches::kExtraSearchQueryParams, "a=b"); | 644 switches::kExtraSearchQueryParams, "a=b"); |
| 663 instant_url = GetInstantURL(profile(), kDisableStartMargin, false); | 645 instant_url = GetInstantURL(profile(), kDisableStartMargin, false); |
| 664 ASSERT_TRUE(instant_url.is_valid()); | 646 ASSERT_TRUE(instant_url.is_valid()); |
| 665 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); | 647 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); |
| 666 } | 648 } |
| 667 | 649 |
| 668 TEST_F(SearchTest, ShouldShowInstantNTP_Default) { | |
| 669 EXPECT_FALSE(ShouldShowInstantNTP()); | |
| 670 } | |
| 671 | |
| 672 TEST_F(SearchTest, ShouldShowInstantNTP_DisabledViaFinch) { | |
| 673 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 674 "EmbeddedSearch", "Group1 show_ntp:0")); | |
| 675 EXPECT_FALSE(ShouldShowInstantNTP()); | |
| 676 } | |
| 677 | |
| 678 TEST_F(SearchTest, ShouldShowInstantNTP_DisabledByUseCacheableNTPFinchFlag) { | |
| 679 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 680 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 681 EXPECT_FALSE(ShouldShowInstantNTP()); | |
| 682 } | |
| 683 | |
| 684 TEST_F(SearchTest, ShouldUseCacheableNTP_Default) { | |
| 685 EXPECT_TRUE(ShouldUseCacheableNTP()); | |
| 686 } | |
| 687 | |
| 688 TEST_F(SearchTest, ShouldUseCacheableNTP_EnabledViaFinch) { | |
| 689 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 690 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | |
| 691 EXPECT_TRUE(ShouldUseCacheableNTP()); | |
| 692 } | |
| 693 | |
| 694 TEST_F(SearchTest, ShouldPrefetchSearchResults_Default) { | |
| 695 EXPECT_FALSE(ShouldPrefetchSearchResults()); | |
| 696 } | |
| 697 | |
| 698 TEST_F(SearchTest, ShouldPrefetchSearchResults_InstantExtendedAPIEnabled) { | 650 TEST_F(SearchTest, ShouldPrefetchSearchResults_InstantExtendedAPIEnabled) { |
| 699 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 651 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 700 "EmbeddedSearch", | 652 "EmbeddedSearch", |
| 701 "Group1 espv:2 use_cacheable_ntp:1 prefetch_results:1")); | 653 "Group1 espv:2 prefetch_results:1")); |
| 702 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 654 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 703 #if defined(OS_IOS) || defined(OS_ANDROID) | 655 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 704 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); | 656 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); |
| 705 #else | 657 #else |
| 706 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | 658 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); |
| 707 #endif | 659 #endif |
| 708 } | 660 } |
| 709 | 661 |
| 710 TEST_F(SearchTest, ShouldPrefetchSearchResults_DisabledViaFinch) { | 662 TEST_F(SearchTest, ShouldPrefetchSearchResults_DisabledViaFinch) { |
| 711 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 663 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 712 "EmbeddedSearch", | 664 "EmbeddedSearch", |
| 713 "Group1 use_cacheable_ntp:1 espv:89 prefetch_results:0")); | 665 "Group1 espv:89 prefetch_results:0")); |
| 714 EXPECT_FALSE(ShouldPrefetchSearchResults()); | 666 EXPECT_FALSE(ShouldPrefetchSearchResults()); |
| 715 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 667 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 716 } | 668 } |
| 717 | 669 |
| 718 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFinch) { | 670 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFinch) { |
| 719 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 671 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 720 "EmbeddedSearch", | 672 "EmbeddedSearch", |
| 721 "Group1 espv:80 use_cacheable_ntp:1 prefetch_results:1")); | 673 "Group1 espv:80 prefetch_results:1")); |
| 722 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 674 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 723 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 675 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 724 } | 676 } |
| 725 | 677 |
| 726 TEST_F(SearchTest, IsNTPURL) { | 678 TEST_F(SearchTest, IsNTPURL) { |
| 727 GURL invalid_url; | 679 GURL invalid_url; |
| 728 GURL ntp_url(chrome::kChromeUINewTabURL); | 680 GURL ntp_url(chrome::kChromeUINewTabURL); |
| 729 GURL local_ntp_url(GetLocalInstantURL(profile())); | 681 GURL local_ntp_url(GetLocalInstantURL(profile())); |
| 730 | 682 |
| 731 EXPECT_FALSE(chrome::IsNTPURL(invalid_url, profile())); | 683 EXPECT_FALSE(chrome::IsNTPURL(invalid_url, profile())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 756 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec()); | 708 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec()); |
| 757 } | 709 } |
| 758 | 710 |
| 759 TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) { | 711 TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) { |
| 760 // "prefetch_results" flag is disabled. | 712 // "prefetch_results" flag is disabled. |
| 761 EXPECT_EQ(GURL(), GetSearchResultPrefetchBaseURL(profile())); | 713 EXPECT_EQ(GURL(), GetSearchResultPrefetchBaseURL(profile())); |
| 762 | 714 |
| 763 // "prefetch_results" flag is enabled via field trials. | 715 // "prefetch_results" flag is enabled via field trials. |
| 764 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 716 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 765 "EmbeddedSearch", | 717 "EmbeddedSearch", |
| 766 "Group1 espv:80 use_cacheable_ntp:1 prefetch_results:1")); | 718 "Group1 espv:80 prefetch_results:1")); |
| 767 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 719 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 768 | 720 |
| 769 EXPECT_EQ(GURL("https://foo.com/instant?ion=1&foo=foo#foo=foo&strk"), | 721 EXPECT_EQ(GURL("https://foo.com/instant?ion=1&foo=foo#foo=foo&strk"), |
| 770 GetSearchResultPrefetchBaseURL(profile())); | 722 GetSearchResultPrefetchBaseURL(profile())); |
| 771 } | 723 } |
| 772 | 724 |
| 773 typedef SearchTest IsQueryExtractionEnabledTest; | 725 typedef SearchTest IsQueryExtractionEnabledTest; |
| 774 | 726 |
| 775 TEST_F(IsQueryExtractionEnabledTest, NotSet) { | 727 TEST_F(IsQueryExtractionEnabledTest, NotSet) { |
| 776 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 728 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); | 888 "EmbeddedSearch", "Group1 espv:2 origin_chip:1")); |
| 937 EXPECT_TRUE(ShouldDisplayOriginChip()); | 889 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 938 } | 890 } |
| 939 | 891 |
| 940 TEST_F(OriginChipTest, CommandLineOriginChip) { | 892 TEST_F(OriginChipTest, CommandLineOriginChip) { |
| 941 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); | 893 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableOriginChip); |
| 942 EXPECT_TRUE(ShouldDisplayOriginChip()); | 894 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 943 } | 895 } |
| 944 | 896 |
| 945 } // namespace chrome | 897 } // namespace chrome |
| OLD | NEW |