Chromium Code Reviews| Index: chrome/browser/search/search_unittest.cc |
| diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc |
| index e6035e20e675cc22114cad0cefb8a8b82e130278..7a22b1c69ac0bb113846e202638f4ff9c8c48d4f 100644 |
| --- a/chrome/browser/search/search_unittest.cc |
| +++ b/chrome/browser/search/search_unittest.cc |
| @@ -201,6 +201,18 @@ class SearchTest : public BrowserWithTestWindowTest { |
| template_url_service->Add(template_url); |
| template_url_service->SetDefaultSearchProvider(template_url); |
| } |
| + |
| + void SetGoogleAsSearchProvider() { |
| + TemplateURLService* template_url_service = |
| + TemplateURLServiceFactory::GetForProfile(profile()); |
| + TemplateURLData data; |
| + data.SetURL("http://www.google.com/"); |
| + data.instant_url = "http://www.google.com/"; |
| + TemplateURL* template_url = new TemplateURL(profile(), data); |
| + // Takes ownership of |template_url|. |
| + template_url_service->Add(template_url); |
| + template_url_service->SetDefaultSearchProvider(template_url); |
| + } |
| }; |
| struct SearchTestCase { |
| @@ -243,8 +255,8 @@ TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) { |
| EnableInstantExtendedAPIForTesting(); |
| const SearchTestCase kTestCases[] = { |
| - {chrome::kChromeSearchLocalOmniboxPopupURL, true, ""}, |
| {chrome::kChromeSearchLocalNtpUrl, true, ""}, |
| + {chrome::kChromeSearchLocalGoogleNtpUrl, true, ""}, |
| {"https://foo.com/instant?strk", true, ""}, |
| {"https://foo.com/instant#strk", true, ""}, |
| {"https://foo.com/instant?strk=0", true, ""}, |
| @@ -277,23 +289,23 @@ TEST_F(SearchTest, CoerceCommandLineURLToTemplateURL) { |
| } |
| const SearchTestCase kInstantNTPTestCases[] = { |
| - {"https://foo.com/instant?strk", true, "Valid Instant URL"}, |
| - {"https://foo.com/instant#strk", true, "Valid Instant URL"}, |
| - {"https://foo.com/url?strk", true, "Valid search URL"}, |
| - {"https://foo.com/url#strk", true, "Valid search URL"}, |
| - {"https://foo.com/alt?strk", true, "Valid alternative URL"}, |
| - {"https://foo.com/alt#strk", true, "Valid alternative URL"}, |
| - {"https://foo.com/url?strk&bar=", true, "No query terms"}, |
| - {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, |
| - {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, |
| - {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
| - {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
| - {"https://foo.com/instant", false, "No search terms replacement"}, |
| - {"chrome://blank/", false, "Chrome scheme"}, |
| - {"chrome-search//foo", false, "Chrome-search scheme"}, |
| - {chrome::kChromeSearchLocalOmniboxPopupURL, false, "Local omnibox popup"}, |
| - {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
| - {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
| + {"https://foo.com/instant?strk", true, "Valid Instant URL"}, |
| + {"https://foo.com/instant#strk", true, "Valid Instant URL"}, |
| + {"https://foo.com/url?strk", true, "Valid search URL"}, |
| + {"https://foo.com/url#strk", true, "Valid search URL"}, |
| + {"https://foo.com/alt?strk", true, "Valid alternative URL"}, |
| + {"https://foo.com/alt#strk", true, "Valid alternative URL"}, |
| + {"https://foo.com/url?strk&bar=", true, "No query terms"}, |
| + {"https://foo.com/url?strk&q=abc", true, "No query terms key"}, |
| + {"https://foo.com/url?strk#bar=abc", true, "Query terms key in ref"}, |
| + {"https://foo.com/url?strk&bar=abc", false, "Has query terms"}, |
| + {"http://foo.com/instant?strk=1", false, "Insecure URL"}, |
| + {"https://foo.com/instant", false, "No search term replacement"}, |
| + {"chrome://blank/", false, "Chrome scheme"}, |
| + {"chrome-search//foo", false, "Chrome-search scheme"}, |
| + {chrome::kChromeSearchLocalNtpUrl, true, "Local new tab page"}, |
| + {chrome::kChromeSearchLocalGoogleNtpUrl, true, "Local new tab page"}, |
| + {"https://bar.com/instant?strk=1", false, "Random non-search page"}, |
| }; |
| TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
| @@ -302,6 +314,10 @@ TEST_F(SearchTest, InstantNTPExtendedEnabled) { |
| for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
| const SearchTestCase& test = kInstantNTPTestCases[i]; |
| NavigateAndCommitActiveTab(GURL(test.url)); |
| + |
| + if (test.url == chrome::kChromeSearchLocalGoogleNtpUrl) |
| + SetGoogleAsSearchProvider(); |
|
sreeram
2013/04/19 17:05:00
This persists to the next iteration of the loop, r
jeremycho
2013/04/19 19:55:07
Fixed.
On 2013/04/19 17:05:00, sreeram wrote:
|
| + |
| const content::WebContents* contents = |
| browser()->tab_strip_model()->GetWebContentsAt(0); |
| EXPECT_EQ(test.expected_result, IsInstantNTP(contents)) |
| @@ -326,6 +342,9 @@ TEST_F(SearchTest, InstantNTPCustomNavigationEntry) { |
| for (size_t i = 0; i < arraysize(kInstantNTPTestCases); ++i) { |
| const SearchTestCase& test = kInstantNTPTestCases[i]; |
| NavigateAndCommitActiveTab(GURL(test.url)); |
| + if (test.url == chrome::kChromeSearchLocalGoogleNtpUrl) |
| + SetGoogleAsSearchProvider(); |
|
sreeram
2013/04/19 17:05:00
-ditto-
jeremycho
2013/04/19 19:55:07
Fixed.
On 2013/04/19 17:05:00, sreeram wrote:
|
| + |
| content::WebContents* contents = |
| browser()->tab_strip_model()->GetWebContentsAt(0); |
| content::NavigationController& controller = contents->GetController(); |