| Index: chrome/browser/ui/search/search_unittest.cc
|
| diff --git a/chrome/browser/ui/search/search_unittest.cc b/chrome/browser/ui/search/search_unittest.cc
|
| index c91203eed212a4c8aeeddfb11de4f9909c43633e..7646bb75afbc2f0480a9faa39c096deb17abf4c0 100644
|
| --- a/chrome/browser/ui/search/search_unittest.cc
|
| +++ b/chrome/browser/ui/search/search_unittest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/search_engines/template_url.h"
|
| #include "chrome/browser/ui/search/search.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -65,5 +66,54 @@ TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) {
|
| EXPECT_EQ(ZERO, flags.size());
|
| }
|
|
|
| +TEST(SearchTest, ShouldAssignURLToInstantRendererImpl) {
|
| + TemplateURLData data;
|
| + data.SetURL("http://foo.com/url?bar={searchTerms}");
|
| + data.instant_url = "http://foo.com/instant";
|
| + data.alternate_urls.push_back("http://foo.com/alt#quux={searchTerms}");
|
| + data.search_terms_replacement_key = "strk";
|
| + TemplateURL url(NULL, data);
|
| +
|
| + struct {
|
| + const char* const url;
|
| + bool extended_api_enabled;
|
| + bool expected_result;
|
| + } kTestCases[] = {
|
| + {"invalid URL", false, false},
|
| + {"unknown://scheme/path", false, false},
|
| + {"chrome-search://foo/bar", false, true},
|
| + {kLocalOmniboxPopupURL, false, false},
|
| + {kLocalOmniboxPopupURL, true, true},
|
| + {"http://foo.com/instant", false, true},
|
| + {"http://foo.com/instant?foo=bar", false, true},
|
| + {"https://foo.com/instant", false, true},
|
| + {"https://foo.com/instant#foo=bar", false, true},
|
| + {"HtTpS://fOo.CoM/instant", false, true},
|
| + {"http://foo.com:80/instant", false, true},
|
| + {"ftp://foo.com/instant", false, false},
|
| + {"http://sub.foo.com/instant", false, false},
|
| + {"http://foo.com:26/instant", false, false},
|
| + {"http://foo.com/instant/bar", false, false},
|
| + {"http://foo.com/Instant", false, false},
|
| + {"https://foo.com/instant?strk", true, true},
|
| + {"https://foo.com/instant#strk", true, true},
|
| + {"https://foo.com/instant?strk=0", true, true},
|
| + {"http://foo.com/instant", true, false},
|
| + {"https://foo.com/instant", true, false},
|
| + {"http://foo.com/instant?strk=1", true, false},
|
| + {"https://foo.com/url?strk", true, true},
|
| + {"https://foo.com/alt?strk", true, true},
|
| + };
|
| +
|
| + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
|
| + EXPECT_EQ(kTestCases[i].expected_result,
|
| + ShouldAssignURLToInstantRendererImpl(
|
| + GURL(kTestCases[i].url),
|
| + kTestCases[i].extended_api_enabled,
|
| + &url)) << kTestCases[i].url << " "
|
| + << kTestCases[i].extended_api_enabled;
|
| + }
|
| +}
|
| +
|
| } // namespace search
|
| } // namespace chrome
|
|
|