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

Unified Diff: chrome/browser/ui/search/search_unittest.cc

Issue 12250033: Consolidate search terms extraction and Instant process determination. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style nit Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698