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 "chrome/browser/spellchecker/spellcheck_service.h" | 5 #include "chrome/browser/spellchecker/spellcheck_service.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/stl_util.h" |
11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/supports_user_data.h" | 14 #include "base/supports_user_data.h" |
14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/prefs/pref_registry_simple.h" | 17 #include "components/prefs/pref_registry_simple.h" |
17 #include "components/prefs/testing_pref_service.h" | 18 #include "components/prefs/testing_pref_service.h" |
18 #include "components/spellcheck/browser/pref_names.h" | 19 #include "components/spellcheck/browser/pref_names.h" |
19 #include "components/user_prefs/user_prefs.h" | 20 #include "components/user_prefs/user_prefs.h" |
20 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 15 matching lines...) Expand all Loading... |
36 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 37 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
37 | 38 |
38 std::vector<std::string> used_for_spellcheck = | 39 std::vector<std::string> used_for_spellcheck = |
39 base::SplitString(unsplit_expected_languages_used_for_spellcheck, ",", | 40 base::SplitString(unsplit_expected_languages_used_for_spellcheck, ",", |
40 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 41 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
41 | 42 |
42 SpellcheckService::Dictionary dictionary; | 43 SpellcheckService::Dictionary dictionary; |
43 for (const auto& language : languages) { | 44 for (const auto& language : languages) { |
44 dictionary.language = language; | 45 dictionary.language = language; |
45 dictionary.used_for_spellcheck = | 46 dictionary.used_for_spellcheck = |
46 std::find(used_for_spellcheck.begin(), used_for_spellcheck.end(), | 47 base::ContainsValue(used_for_spellcheck, language); |
47 language) != used_for_spellcheck.end(); | |
48 expected_dictionaries.push_back(dictionary); | 48 expected_dictionaries.push_back(dictionary); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 ~TestCase() {} | 52 ~TestCase() {} |
53 | 53 |
54 std::string accept_languages; | 54 std::string accept_languages; |
55 std::vector<std::string> spellcheck_dictionaries; | 55 std::vector<std::string> spellcheck_dictionaries; |
56 std::vector<SpellcheckService::Dictionary> expected_dictionaries; | 56 std::vector<SpellcheckService::Dictionary> expected_dictionaries; |
57 }; | 57 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 base::ListValue spellcheck_dictionaries; | 128 base::ListValue spellcheck_dictionaries; |
129 spellcheck_dictionaries.AppendStrings(GetParam().spellcheck_dictionaries); | 129 spellcheck_dictionaries.AppendStrings(GetParam().spellcheck_dictionaries); |
130 prefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, | 130 prefs()->Set(spellcheck::prefs::kSpellCheckDictionaries, |
131 spellcheck_dictionaries); | 131 spellcheck_dictionaries); |
132 | 132 |
133 std::vector<SpellcheckService::Dictionary> dictionaries; | 133 std::vector<SpellcheckService::Dictionary> dictionaries; |
134 SpellcheckService::GetDictionaries(context(), &dictionaries); | 134 SpellcheckService::GetDictionaries(context(), &dictionaries); |
135 | 135 |
136 EXPECT_EQ(GetParam().expected_dictionaries, dictionaries); | 136 EXPECT_EQ(GetParam().expected_dictionaries, dictionaries); |
137 } | 137 } |
OLD | NEW |