Extend the suppression for issue 379943
[chromium-blink-merge.git] / components / search_engines / default_search_pref_test_util.cc
blobf09add350e453ab208a1025dd0d07d43a732422b
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 std::vector<std::string> encodings_items;
45 base::SplitString(encodings, ';', &encodings_items);
46 scoped_ptr<base::ListValue> encodings_list(new base::ListValue);
47 for (std::vector<std::string>::const_iterator it = encodings_items.begin();
48 it != encodings_items.end();
49 ++it) {
50 encodings_list->AppendString(*it);
52 value->Set(DefaultSearchManager::kInputEncodings, encodings_list.release());
54 scoped_ptr<base::ListValue> alternate_url_list(new base::ListValue());
55 if (!alternate_url.empty())
56 alternate_url_list->Append(new base::StringValue(alternate_url));
57 value->Set(DefaultSearchManager::kAlternateURLs,
58 alternate_url_list.release());
59 return value.Pass();