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/ui/webui/options2/language_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/language_options_handler2.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
13 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" |
14 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" | |
15 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 14 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
16 #include "chrome/browser/ui/webui/options2/chromeos/cros_language_options_handle
r2.h" | 15 #include "chrome/browser/ui/webui/options2/chromeos/cros_language_options_handle
r2.h" |
17 | 16 |
18 using chromeos::input_method::InputMethodDescriptor; | 17 using chromeos::input_method::InputMethodDescriptor; |
19 using chromeos::input_method::InputMethodDescriptors; | 18 using chromeos::input_method::InputMethodDescriptors; |
20 using chromeos::input_method::InputMethodManager; | 19 using chromeos::input_method::InputMethodManager; |
21 using chromeos::input_method::InputMethodWhitelist; | |
22 using chromeos::input_method::MockInputMethodManager; | 20 using chromeos::input_method::MockInputMethodManager; |
23 | 21 |
24 namespace { | 22 namespace { |
25 | 23 |
26 class LanguageOptionsHandlerTest : public testing::Test { | 24 class LanguageOptionsHandlerTest : public testing::Test { |
27 public: | 25 public: |
28 LanguageOptionsHandlerTest() { | 26 LanguageOptionsHandlerTest() { |
29 InputMethodManager::InitializeForTesting(new MockInputMethodManager); | 27 InputMethodManager::InitializeForTesting(new MockInputMethodManager); |
30 } | 28 } |
31 virtual ~LanguageOptionsHandlerTest() { | 29 virtual ~LanguageOptionsHandlerTest() { |
32 InputMethodManager::Shutdown(); | 30 InputMethodManager::Shutdown(); |
33 } | 31 } |
34 | 32 |
35 protected: | 33 protected: |
36 InputMethodDescriptors CreateInputMethodDescriptors() { | 34 InputMethodDescriptors CreateInputMethodDescriptors() { |
37 InputMethodDescriptors descriptors; | 35 InputMethodDescriptors descriptors; |
38 descriptors.push_back(GetDesc("xkb:us::eng", "us", "en-US")); | 36 descriptors.push_back(GetDesc("xkb:us::eng", "us", "en-US")); |
39 descriptors.push_back(GetDesc("xkb:fr::fra", "fr", "fr")); | 37 descriptors.push_back(GetDesc("xkb:fr::fra", "fr", "fr")); |
40 descriptors.push_back(GetDesc("xkb:be::fra", "be", "fr")); | 38 descriptors.push_back(GetDesc("xkb:be::fra", "be", "fr")); |
41 descriptors.push_back(GetDesc("mozc", "us", "ja")); | 39 descriptors.push_back(GetDesc("mozc", "us", "ja")); |
42 return descriptors; | 40 return descriptors; |
43 } | 41 } |
44 | 42 |
45 private: | 43 private: |
46 InputMethodDescriptor GetDesc(const std::string& id, | 44 InputMethodDescriptor GetDesc(const std::string& id, |
47 const std::string& raw_layout, | 45 const std::string& raw_layout, |
48 const std::string& language_code) { | 46 const std::string& language_code) { |
49 return InputMethodDescriptor(whitelist_, | 47 return InputMethodDescriptor(id, |
50 id, | |
51 "", // name | 48 "", // name |
52 raw_layout, | 49 raw_layout, |
53 language_code); | 50 language_code); |
54 } | 51 } |
55 | |
56 const InputMethodWhitelist whitelist_; | |
57 }; | 52 }; |
58 | 53 |
59 } // namespace | 54 } // namespace |
60 #else | 55 #else |
61 typedef testing::Test LanguageOptionsHandlerTest; | 56 typedef testing::Test LanguageOptionsHandlerTest; |
62 #endif | 57 #endif |
63 | 58 |
64 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
65 TEST_F(LanguageOptionsHandlerTest, GetInputMethodList) { | 60 TEST_F(LanguageOptionsHandlerTest, GetInputMethodList) { |
66 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); | 61 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // fail when we add support for the language. | 216 // fail when we add support for the language. |
222 // EXPECT_FALSE(dictionary->HasKey("no")); | 217 // EXPECT_FALSE(dictionary->HasKey("no")); |
223 } | 218 } |
224 #endif // !defined(OS_MACOSX) | 219 #endif // !defined(OS_MACOSX) |
225 | 220 |
226 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { | 221 TEST_F(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) { |
227 scoped_ptr<DictionaryValue> dictionary( | 222 scoped_ptr<DictionaryValue> dictionary( |
228 options2::LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); | 223 options2::LanguageOptionsHandler::GetSpellCheckLanguageCodeSet()); |
229 EXPECT_TRUE(dictionary->HasKey("en-US")); | 224 EXPECT_TRUE(dictionary->HasKey("en-US")); |
230 } | 225 } |
OLD | NEW |