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

Side by Side Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 228013002: Use whether a query is from the app list to determine the RLZ parameter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@rlz-access-ids
Patch Set: Created 6 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 GURL result(url.url_ref().ReplaceSearchTerms( 674 GURL result(url.url_ref().ReplaceSearchTerms(
675 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("x")))); 675 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("x"))));
676 ASSERT_TRUE(result.is_valid()); 676 ASSERT_TRUE(result.is_valid());
677 std::string expected_url = "http://bar/?"; 677 std::string expected_url = "http://bar/?";
678 if (!rlz_string.empty()) 678 if (!rlz_string.empty())
679 expected_url += "rlz=" + base::UTF16ToUTF8(rlz_string) + "&"; 679 expected_url += "rlz=" + base::UTF16ToUTF8(rlz_string) + "&";
680 expected_url += "x"; 680 expected_url += "x";
681 EXPECT_EQ(expected_url, result.spec()); 681 EXPECT_EQ(expected_url, result.spec());
682 } 682 }
683 683
684 #if !defined(OS_ANDROID) && !defined(OS_IOS)
685 TEST_F(TemplateURLTest, RLZFromAppList) {
686 base::string16 rlz_string;
687 #if defined(ENABLE_RLZ)
688 std::string brand;
689 if (google_util::GetBrand(&brand) && !brand.empty() &&
690 !google_util::IsOrganic(brand)) {
691 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz_string);
692 }
693 #endif
694
695 TemplateURLData data;
696 data.SetURL("http://bar/?{google:RLZ}{searchTerms}");
697 TemplateURL url(NULL, data);
698 EXPECT_TRUE(url.url_ref().IsValid());
699 ASSERT_TRUE(url.url_ref().SupportsReplacement());
700 TemplateURLRef::SearchTermsArgs args(ASCIIToUTF16("x"));
701 args.from_app_list = true;
702 GURL result(url.url_ref().ReplaceSearchTerms(args));
703 ASSERT_TRUE(result.is_valid());
704 std::string expected_url = "http://bar/?";
705 if (!rlz_string.empty())
706 expected_url += "rlz=" + base::UTF16ToUTF8(rlz_string) + "&";
707 expected_url += "x";
708 EXPECT_EQ(expected_url, result.spec());
709 }
710 #endif
711
684 TEST_F(TemplateURLTest, HostAndSearchTermKey) { 712 TEST_F(TemplateURLTest, HostAndSearchTermKey) {
685 struct TestData { 713 struct TestData {
686 const std::string url; 714 const std::string url;
687 const std::string host; 715 const std::string host;
688 const std::string path; 716 const std::string path;
689 const std::string search_term_key; 717 const std::string search_term_key;
690 } test_data[] = { 718 } test_data[] = {
691 { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"}, 719 { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"},
692 720
693 // No query key should result in empty values. 721 // No query key should result in empty values.
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 url.url_ref_.showing_search_terms_ = true; 1314 url.url_ref_.showing_search_terms_ = true;
1287 search_terms_args.bookmark_bar_pinned = false; 1315 search_terms_args.bookmark_bar_pinned = false;
1288 result = url.url_ref().ReplaceSearchTerms(search_terms_args); 1316 result = url.url_ref().ReplaceSearchTerms(search_terms_args);
1289 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result); 1317 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result);
1290 1318
1291 url.url_ref_.showing_search_terms_ = true; 1319 url.url_ref_.showing_search_terms_ = true;
1292 search_terms_args.bookmark_bar_pinned = true; 1320 search_terms_args.bookmark_bar_pinned = true;
1293 result = url.url_ref().ReplaceSearchTerms(search_terms_args); 1321 result = url.url_ref().ReplaceSearchTerms(search_terms_args);
1294 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result); 1322 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result);
1295 } 1323 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | chrome/browser/ui/app_list/search/omnibox_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698