add flags for future skia api change
[chromium-blink-merge.git] / components / search_engines / default_search_pref_test_util.cc
blob22acd425b39a86b388911d82daaff49053f89cc1
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/search_engines/default_search_pref_test_util.h"
7 #include "base/strings/string_split.h"
8 #include "components/search_engines/default_search_manager.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 // static
12 scoped_ptr<base::DictionaryValue>
13 DefaultSearchPrefTestUtil::CreateDefaultSearchPreferenceValue(
14 bool enabled,
15 const std::string& name,
16 const std::string& keyword,
17 const std::string& search_url,
18 const std::string& suggest_url,
19 const std::string& icon_url,
20 const std::string& encodings,
21 const std::string& alternate_url,
22 const std::string& search_terms_replacement_key) {
23 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue);
24 if (!enabled) {
25 value->SetBoolean(DefaultSearchManager::kDisabledByPolicy, true);
26 return value.Pass();
29 EXPECT_FALSE(keyword.empty());
30 EXPECT_FALSE(search_url.empty());
31 value->Set(DefaultSearchManager::kShortName,
32 new base::StringValue(name));
33 value->Set(DefaultSearchManager::kKeyword,
34 new base::StringValue(keyword));
35 value->Set(DefaultSearchManager::kURL,
36 new base::StringValue(search_url));
37 value->Set(DefaultSearchManager::kSuggestionsURL,
38 new base::StringValue(suggest_url));
39 value->Set(DefaultSearchManager::kFaviconURL,
40 new base::StringValue(icon_url));
41 value->Set(DefaultSearchManager::kSearchTermsReplacementKey,
42 new base::StringValue(search_terms_replacement_key));
44 scoped_ptr<base::ListValue> encodings_list(new base::ListValue);
45 for (const std::string& term : base::SplitString(
46 encodings, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
47 encodings_list->AppendString(term);
48 value->Set(DefaultSearchManager::kInputEncodings, encodings_list.release());
50 scoped_ptr<base::ListValue> alternate_url_list(new base::ListValue());
51 if (!alternate_url.empty())
52 alternate_url_list->Append(new base::StringValue(alternate_url));
53 value->Set(DefaultSearchManager::kAlternateURLs,
54 alternate_url_list.release());
55 return value.Pass();