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

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

Issue 11377049: Moving prepopulated search engines to a JSON file. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Unit tests for python and C++. Added build step. Created 8 years, 1 month 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
Index: chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc b/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
index 324af6e2bed86e996ea3cbe88129f521a7735aa0..ec1c3879a976e38e97d8019711ba87b07535e255 100644
--- a/chrome/browser/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/chrome/browser/search_engines/template_url_prepopulate_data_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 "base/command_line.h"
#include "base/file_util.h"
#include "base/memory/scoped_vector.h"
#include "base/scoped_temp_dir.h"
@@ -10,6 +11,7 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service.h"
#include "chrome/test/base/testing_profile.h"
@@ -177,6 +179,44 @@ TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrefs) {
EXPECT_EQ(2u, t_urls.size());
}
+// Verifies that built-in search providers are processed correctly.
+TEST(TemplateURLPrepopulateDataTest, ProvidersFromPrepopulated) {
+ // Use Norway to test some unicode characters.
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kCountry, "NO");
+ TestingProfile profile;
+ ScopedVector<TemplateURL> t_urls;
+ size_t default_index;
+ TemplateURLPrepopulateData::GetPrepopulatedEngines(&profile, &t_urls.get(),
+ &default_index);
+ ASSERT_EQ(0u, default_index);
+ ASSERT_EQ(5u, t_urls.size());
+ EXPECT_EQ(ASCIIToUTF16("Google"), t_urls[0]->short_name());
+ EXPECT_EQ(ASCIIToUTF16("google.com"), t_urls[0]->keyword());
+ EXPECT_EQ("www.google.com", t_urls[0]->url_ref().GetHost());
+ EXPECT_EQ("http://www.google.com/favicon.ico",
+ t_urls[0]->favicon_url().spec());
+ EXPECT_EQ(1u, t_urls[0]->input_encodings().size());
+ EXPECT_EQ("UTF-8", t_urls[0]->input_encodings()[0]);
+ EXPECT_EQ(1, t_urls[0]->prepopulate_id());
+ EXPECT_EQ("{google:baseSuggestURL}search?{google:searchFieldtrialParameter}"
+ "client=chrome&q={searchTerms}&"
+ "sugkey={google:suggestAPIKeyParameter}",
+ t_urls[0]->suggestions_url());
+ EXPECT_EQ("{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}"
+ "{google:instantEnabledParameter}ie={inputEncoding}",
+ t_urls[0]->instant_url());
+ EXPECT_EQ("{google:baseURL}#q={searchTerms}",
+ t_urls[0]->alternate_urls()[0]);
+ EXPECT_EQ("{google:baseURL}search#q={searchTerms}",
+ t_urls[0]->alternate_urls()[1]);
+ EXPECT_EQ("{google:baseURL}webhp#q={searchTerms}",
+ t_urls[0]->alternate_urls()[2]);
+
+ // Testing unicode characters work correctly.
+ EXPECT_EQ(WideToUTF16(L"ABC S\x00f8k"), t_urls[2]->short_name());
+}
+
TEST(TemplateURLPrepopulateDataTest, GetEngineTypeBasic) {
EXPECT_EQ(SEARCH_ENGINE_OTHER,
TemplateURLPrepopulateData::GetEngineType("http://example.com/"));

Powered by Google App Engine
This is Rietveld 408576698