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

Side by Side Diff: chrome/browser/search/search_unittest.cc

Issue 2898313003: Ensure the NTP ServiceWorker has the proper site URL (Closed)
Patch Set: Rebase + addressed comments Created 3 years, 6 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
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/common/search/search_urls.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 525
526 TEST_F(SearchTest, IsNTPURL) { 526 TEST_F(SearchTest, IsNTPURL) {
527 GURL invalid_url; 527 GURL invalid_url;
528 GURL ntp_url(chrome::kChromeUINewTabURL); 528 GURL ntp_url(chrome::kChromeUINewTabURL);
529 GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl); 529 GURL local_ntp_url(chrome::kChromeSearchLocalNtpUrl);
530 530
531 EXPECT_FALSE(IsNTPURL(invalid_url, profile())); 531 EXPECT_FALSE(IsNTPURL(invalid_url, profile()));
532 // No margin. 532 // No margin.
533 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); 533 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true);
534 GURL remote_ntp_url(GetInstantURL(profile(), false)); 534 GURL remote_ntp_url(GetInstantURL(profile(), false));
535 GURL remote_ntp_service_worker_url("https://foo.com/newtab-serviceworker.js");
535 GURL search_url_with_search_terms("https://foo.com/url?strk&bar=abc"); 536 GURL search_url_with_search_terms("https://foo.com/url?strk&bar=abc");
536 GURL search_url_without_search_terms("https://foo.com/url?strk&bar"); 537 GURL search_url_without_search_terms("https://foo.com/url?strk&bar");
537 538
538 EXPECT_FALSE(IsNTPURL(ntp_url, profile())); 539 EXPECT_FALSE(IsNTPURL(ntp_url, profile()));
539 EXPECT_TRUE(IsNTPURL(local_ntp_url, profile())); 540 EXPECT_TRUE(IsNTPURL(local_ntp_url, profile()));
540 EXPECT_TRUE(IsNTPURL(remote_ntp_url, profile())); 541 EXPECT_TRUE(IsNTPURL(remote_ntp_url, profile()));
542 EXPECT_TRUE(IsNTPURL(remote_ntp_service_worker_url, profile()));
541 EXPECT_FALSE(IsNTPURL(search_url_with_search_terms, profile())); 543 EXPECT_FALSE(IsNTPURL(search_url_with_search_terms, profile()));
542 EXPECT_FALSE(IsNTPURL(search_url_without_search_terms, profile())); 544 EXPECT_FALSE(IsNTPURL(search_url_without_search_terms, profile()));
543 545
544 EXPECT_FALSE(IsNTPURL(ntp_url, NULL)); 546 EXPECT_FALSE(IsNTPURL(ntp_url, NULL));
545 EXPECT_FALSE(IsNTPURL(local_ntp_url, NULL)); 547 EXPECT_FALSE(IsNTPURL(local_ntp_url, NULL));
546 EXPECT_FALSE(IsNTPURL(remote_ntp_url, NULL)); 548 EXPECT_FALSE(IsNTPURL(remote_ntp_url, NULL));
549 EXPECT_FALSE(IsNTPURL(remote_ntp_service_worker_url, NULL));
547 EXPECT_FALSE(IsNTPURL(search_url_with_search_terms, NULL)); 550 EXPECT_FALSE(IsNTPURL(search_url_with_search_terms, NULL));
548 EXPECT_FALSE(IsNTPURL(search_url_without_search_terms, NULL)); 551 EXPECT_FALSE(IsNTPURL(search_url_without_search_terms, NULL));
549 } 552 }
550 553
551 TEST_F(SearchTest, GetSearchURLs) { 554 TEST_F(SearchTest, GetSearchURLs) {
552 std::vector<GURL> search_urls = GetSearchURLs(profile()); 555 std::vector<GURL> search_urls = GetSearchURLs(profile());
553 EXPECT_EQ(2U, search_urls.size()); 556 EXPECT_EQ(2U, search_urls.size());
554 EXPECT_EQ("http://foo.com/alt#quux=", search_urls[0].spec()); 557 EXPECT_EQ("http://foo.com/alt#quux=", search_urls[0].spec());
555 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec()); 558 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec());
556 } 559 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo")); 644 TemplateURLRef::SearchTermsArgs search_terms_args(base::ASCIIToUTF16("foo"));
642 GURL result(template_url_->url_ref().ReplaceSearchTerms( 645 GURL result(template_url_->url_ref().ReplaceSearchTerms(
643 search_terms_args, UIThreadSearchTermsData(profile()))); 646 search_terms_args, UIThreadSearchTermsData(profile())));
644 ASSERT_TRUE(result.is_valid()); 647 ASSERT_TRUE(result.is_valid());
645 // Query extraction is disabled. Make sure 648 // Query extraction is disabled. Make sure
646 // {google:instantExtendedEnabledParameter} is not set in the search URL. 649 // {google:instantExtendedEnabledParameter} is not set in the search URL.
647 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); 650 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec());
648 } 651 }
649 652
650 } // namespace search 653 } // namespace search
OLDNEW
« no previous file with comments | « chrome/browser/search/search.cc ('k') | chrome/common/search/search_urls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698