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

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

Issue 9699054: rlz: Hook up on mac, switch to chrome's network stack on win. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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 | Annotate | Revision Log
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/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/rlz/rlz.h" 9 #include "chrome/browser/rlz/rlz.h"
10 #include "chrome/browser/search_engines/search_terms_data.h" 10 #include "chrome/browser/search_engines/search_terms_data.h"
11 #include "chrome/browser/search_engines/template_url.h" 11 #include "chrome/browser/search_engines/template_url.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 #if defined(ENABLE_RLZ)
15 #include "chrome/browser/google/google_util.h"
16 #endif
17
14 // TestSearchTermsData -------------------------------------------------------- 18 // TestSearchTermsData --------------------------------------------------------
15 19
16 // Simple implementation of SearchTermsData. 20 // Simple implementation of SearchTermsData.
17 class TestSearchTermsData : public SearchTermsData { 21 class TestSearchTermsData : public SearchTermsData {
18 public: 22 public:
19 explicit TestSearchTermsData(const std::string& google_base_url); 23 explicit TestSearchTermsData(const std::string& google_base_url);
20 24
21 virtual std::string GoogleBaseURLValue() const OVERRIDE; 25 virtual std::string GoogleBaseURLValue() const OVERRIDE;
22 26
23 private: 27 private:
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 ASSERT_TRUE(ref.SupportsReplacement()); 406 ASSERT_TRUE(ref.SupportsReplacement());
403 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { 407 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
404 GURL result(ref.ReplaceSearchTerms(turl, ASCIIToUTF16("foobar"), 408 GURL result(ref.ReplaceSearchTerms(turl, ASCIIToUTF16("foobar"),
405 test_data[i].accepted_suggestion, 409 test_data[i].accepted_suggestion,
406 test_data[i].original_query_for_suggestion)); 410 test_data[i].original_query_for_suggestion));
407 ASSERT_TRUE(result.is_valid()); 411 ASSERT_TRUE(result.is_valid());
408 EXPECT_EQ(test_data[i].expected_result, result.spec()); 412 EXPECT_EQ(test_data[i].expected_result, result.spec());
409 } 413 }
410 } 414 }
411 415
412 #if defined(OS_WIN) 416 #if defined(OS_WIN) || defined(OS_MACOSX)
413 TEST_F(TemplateURLTest, RLZ) { 417 TEST_F(TemplateURLTest, RLZ) {
414 string16 rlz_string; 418 string16 rlz_string;
415 #if defined(GOOGLE_CHROME_BUILD) 419 #if defined(ENABLE_RLZ)
416 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); 420 std::string brand;
421 if (google_util::GetBrand(&brand) && !brand.empty() &&
422 !google_util::IsOrganic(brand)) {
423 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string);
424 }
417 #endif 425 #endif
418 426
419 TemplateURL t_url; 427 TemplateURL t_url;
420 TemplateURLRef ref("http://bar/?{google:RLZ}{searchTerms}", 1, 2); 428 TemplateURLRef ref("http://bar/?{google:RLZ}{searchTerms}", 1, 2);
421 ASSERT_TRUE(ref.IsValid()); 429 ASSERT_TRUE(ref.IsValid());
422 ASSERT_TRUE(ref.SupportsReplacement()); 430 ASSERT_TRUE(ref.SupportsReplacement());
423 GURL result(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("x"), 431 GURL result(ref.ReplaceSearchTerms(t_url, ASCIIToUTF16("x"),
424 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); 432 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()));
425 ASSERT_TRUE(result.is_valid()); 433 ASSERT_TRUE(result.is_valid());
426 std::string expected_url = "http://bar/?"; 434 std::string expected_url = "http://bar/?";
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 TEST_F(TemplateURLTest, ParseURLNestedParameter) { 578 TEST_F(TemplateURLTest, ParseURLNestedParameter) {
571 TemplateURLRef url_ref("{%s", 0, 0); 579 TemplateURLRef url_ref("{%s", 0, 0);
572 TemplateURLRef::Replacements replacements; 580 TemplateURLRef::Replacements replacements;
573 bool valid = false; 581 bool valid = false;
574 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); 582 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid));
575 ASSERT_EQ(1U, replacements.size()); 583 ASSERT_EQ(1U, replacements.size());
576 EXPECT_EQ(1U, replacements[0].index); 584 EXPECT_EQ(1U, replacements[0].index);
577 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); 585 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type);
578 EXPECT_TRUE(valid); 586 EXPECT_TRUE(valid);
579 } 587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698