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

Unified Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 11448005: Add Android-specific parameters to search_engines/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 8 years 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/search_engines/template_url.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/template_url_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 948740b145a1d996e24b32f96be72020a76e3196..725cd20612799be61d0be25559b915c39be74909 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -15,6 +15,10 @@
#include "chrome/browser/google/google_util.h"
#endif
+#if defined(OS_ANDROID)
+#include "chrome/browser/search_engines/search_terms_data_android.h"
+#endif
+
// TestSearchTermsData --------------------------------------------------------
// Simple implementation of SearchTermsData.
@@ -475,6 +479,10 @@ TEST_F(TemplateURLTest, RLZ) {
!google_util::IsOrganic(brand)) {
RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string);
}
+#elif defined(OS_ANDROID)
+ SearchTermsDataAndroid::rlz_parameter_value_.Get() =
+ ASCIIToUTF16("android_test");
+ rlz_string = SearchTermsDataAndroid::rlz_parameter_value_.Get();
#endif
TemplateURLData data;
@@ -640,6 +648,34 @@ TEST_F(TemplateURLTest, ParseURLNestedParameter) {
EXPECT_TRUE(valid);
}
+#if defined(OS_ANDROID)
+TEST_F(TemplateURLTest, SearchClient) {
+ const std::string base_url_str("http://google.com/?");
+ const std::string terms_str("{searchTerms}&{google:searchClient}");
+ const std::string full_url_str = base_url_str + terms_str;
+ const string16 terms(ASCIIToUTF16(terms_str));
+ UIThreadSearchTermsData::SetGoogleBaseURL(base_url_str);
+
+ TemplateURLData data;
+ data.SetURL(full_url_str);
+ TemplateURL url(NULL, data);
+ EXPECT_TRUE(url.url_ref().IsValid());
+ ASSERT_TRUE(url.url_ref().SupportsReplacement());
+ TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foobar"));
+
+ // Check that the URL is correct when a client is not present.
+ GURL result(url.url_ref().ReplaceSearchTerms(search_terms_args));
+ ASSERT_TRUE(result.is_valid());
+ EXPECT_EQ("http://google.com/?foobar&", result.spec());
+
+ // Check that the URL is correct when a client is present.
+ SearchTermsDataAndroid::search_client_.Get() = "android_test";
+ GURL result_2(url.url_ref().ReplaceSearchTerms(search_terms_args));
+ ASSERT_TRUE(result_2.is_valid());
+ EXPECT_EQ("http://google.com/?foobar&client=android_test&", result_2.spec());
+}
+#endif
+
TEST_F(TemplateURLTest, GetURLNoInstantURL) {
TemplateURLData data;
data.SetURL("http://google.com/?q={searchTerms}");
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698