Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 TEST_F(TemplateURLTest, RLZFromAppList) { | |
| 685 base::string16 rlz_string; | |
| 686 #if defined(ENABLE_RLZ) | |
| 687 std::string brand; | |
| 688 if (google_util::GetBrand(&brand) && !brand.empty() && | |
| 689 !google_util::IsOrganic(brand)) { | |
| 690 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz_string); | |
| 691 } | |
| 692 #elif defined(OS_ANDROID) | |
|
Peter Kasting
2014/04/08 20:33:14
Is this test even useful on Android?
Sam McNally
2014/04/09 01:48:56
Done.
| |
| 693 SearchTermsDataAndroid::rlz_parameter_value_.Get() = | |
| 694 ASCIIToUTF16("android_test"); | |
| 695 rlz_string = SearchTermsDataAndroid::rlz_parameter_value_.Get(); | |
| 696 #endif | |
| 697 | |
| 698 TemplateURLData data; | |
| 699 data.SetURL("http://bar/?{google:RLZ}{searchTerms}"); | |
| 700 TemplateURL url(NULL, data); | |
| 701 EXPECT_TRUE(url.url_ref().IsValid()); | |
| 702 ASSERT_TRUE(url.url_ref().SupportsReplacement()); | |
| 703 TemplateURLRef::SearchTermsArgs args(ASCIIToUTF16("x")); | |
| 704 args.from_app_list = true; | |
| 705 GURL result(url.url_ref().ReplaceSearchTerms(args)); | |
| 706 ASSERT_TRUE(result.is_valid()); | |
| 707 std::string expected_url = "http://bar/?"; | |
| 708 if (!rlz_string.empty()) | |
| 709 expected_url += "rlz=" + base::UTF16ToUTF8(rlz_string) + "&"; | |
| 710 expected_url += "x"; | |
| 711 EXPECT_EQ(expected_url, result.spec()); | |
| 712 } | |
| 713 | |
| 684 TEST_F(TemplateURLTest, HostAndSearchTermKey) { | 714 TEST_F(TemplateURLTest, HostAndSearchTermKey) { |
| 685 struct TestData { | 715 struct TestData { |
| 686 const std::string url; | 716 const std::string url; |
| 687 const std::string host; | 717 const std::string host; |
| 688 const std::string path; | 718 const std::string path; |
| 689 const std::string search_term_key; | 719 const std::string search_term_key; |
| 690 } test_data[] = { | 720 } test_data[] = { |
| 691 { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"}, | 721 { "http://blah/?foo=bar&q={searchTerms}&b=x", "blah", "/", "q"}, |
| 692 | 722 |
| 693 // No query key should result in empty values. | 723 // No query key should result in empty values. |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1286 url.url_ref_.showing_search_terms_ = true; | 1316 url.url_ref_.showing_search_terms_ = true; |
| 1287 search_terms_args.bookmark_bar_pinned = false; | 1317 search_terms_args.bookmark_bar_pinned = false; |
| 1288 result = url.url_ref().ReplaceSearchTerms(search_terms_args); | 1318 result = url.url_ref().ReplaceSearchTerms(search_terms_args); |
| 1289 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result); | 1319 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result); |
| 1290 | 1320 |
| 1291 url.url_ref_.showing_search_terms_ = true; | 1321 url.url_ref_.showing_search_terms_ = true; |
| 1292 search_terms_args.bookmark_bar_pinned = true; | 1322 search_terms_args.bookmark_bar_pinned = true; |
| 1293 result = url.url_ref().ReplaceSearchTerms(search_terms_args); | 1323 result = url.url_ref().ReplaceSearchTerms(search_terms_args); |
| 1294 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result); | 1324 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result); |
| 1295 } | 1325 } |
| OLD | NEW |