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/options/language_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/language_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
| 9 #include "base/message_loop/message_loop.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 11 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
11 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" | 12 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h" |
12 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" | 13 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler
.h" |
13 #include "chromeos/ime/input_method_descriptor.h" | 14 #include "chromeos/ime/input_method_descriptor.h" |
| 15 #include "chromeos/system/statistics_provider.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
15 | 17 |
16 using chromeos::input_method::InputMethodDescriptor; | 18 using chromeos::input_method::InputMethodDescriptor; |
17 using chromeos::input_method::InputMethodDescriptors; | 19 using chromeos::input_method::InputMethodDescriptors; |
18 using chromeos::input_method::MockInputMethodManager; | 20 using chromeos::input_method::MockInputMethodManager; |
19 | 21 |
20 namespace { | 22 namespace { |
21 | 23 |
22 class CrosLanguageOptionsHandlerTest : public testing::Test { | 24 class CrosLanguageOptionsHandlerTest : public testing::Test { |
23 public: | 25 public: |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 ASSERT_TRUE(entry->GetString("id", &input_method_id)); | 102 ASSERT_TRUE(entry->GetString("id", &input_method_id)); |
101 ASSERT_TRUE(entry->GetString("displayName", &display_name)); | 103 ASSERT_TRUE(entry->GetString("displayName", &display_name)); |
102 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); | 104 ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set)); |
103 EXPECT_EQ("xkb:is::ice", input_method_id); | 105 EXPECT_EQ("xkb:is::ice", input_method_id); |
104 // Commented out. See above. | 106 // Commented out. See above. |
105 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); | 107 // EXPECT_EQ("Japanese input method (for US keyboard)", display_name); |
106 ASSERT_TRUE(language_code_set->HasKey("is")); | 108 ASSERT_TRUE(language_code_set->HasKey("is")); |
107 } | 109 } |
108 | 110 |
109 TEST_F(CrosLanguageOptionsHandlerTest, GetUILanguageList) { | 111 TEST_F(CrosLanguageOptionsHandlerTest, GetUILanguageList) { |
| 112 // Load statistics engine |
| 113 base::MessageLoop tmp_loop(base::MessageLoop::TYPE_DEFAULT); |
| 114 chromeos::system::StatisticsProvider::GetInstance() |
| 115 ->StartLoadingMachineStatistics(tmp_loop.message_loop_proxy(), false); |
| 116 tmp_loop.RunUntilIdle(); |
| 117 |
110 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); | 118 InputMethodDescriptors descriptors = CreateInputMethodDescriptors(); |
111 scoped_ptr<base::ListValue> list( | 119 scoped_ptr<base::ListValue> list( |
112 chromeos::options::CrosLanguageOptionsHandler::GetUILanguageList( | 120 chromeos::options::CrosLanguageOptionsHandler::GetUILanguageList( |
113 descriptors)); | 121 descriptors)); |
114 | 122 |
115 for (size_t i = 0; i < list->GetSize(); ++i) { | 123 for (size_t i = 0; i < list->GetSize(); ++i) { |
116 base::DictionaryValue* dict; | 124 base::DictionaryValue* dict; |
117 ASSERT_TRUE(list->GetDictionary(i, &dict)); | 125 ASSERT_TRUE(list->GetDictionary(i, &dict)); |
118 std::string code; | 126 std::string code; |
119 ASSERT_TRUE(dict->GetString("code", &code)); | 127 ASSERT_TRUE(dict->GetString("code", &code)); |
120 EXPECT_NE("is", code) | 128 EXPECT_NE("is", code) |
121 << "Icelandic is an example language which has input method " | 129 << "Icelandic is an example language which has input method " |
122 << "but can't use it as UI language."; | 130 << "but can't use it as UI language."; |
123 } | 131 } |
124 } | 132 } |
OLD | NEW |