Index: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc |
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc |
index 87c8b63fdda11c858e923a3108e5b40fd9f4758c..20405cd731d059867d4bf562cc2924a6f19d098e 100644 |
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc |
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc |
@@ -233,11 +233,14 @@ TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { |
TEST_F(InputMethodManagerImplTest, TestObserver) { |
// For http://crbug.com/19655#c11 - (3). browser_state_monitor_unittest.cc is |
// also for the scenario. |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:us::eng"); |
+ |
TestObserver observer; |
InitComponentExtension(); |
manager_->AddObserver(&observer); |
EXPECT_EQ(0, observer.input_method_changed_count_); |
- manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(1, observer.input_method_changed_count_); |
EXPECT_EQ(1, observer.input_method_property_changed_count_); |
manager_->ChangeInputMethod("xkb:us:dvorak:eng"); |
@@ -283,46 +286,89 @@ TEST_F(InputMethodManagerImplTest, TestGetSupportedInputMethods) { |
TEST_F(InputMethodManagerImplTest, TestEnableLayouts) { |
// Currently 5 keyboard layouts are supported for en-US, and 1 for ja. See |
// ibus_input_method.txt. |
+ std::vector<std::string> keyboard_layouts; |
+ |
InitComponentExtension(); |
- manager_->EnableLoginLayouts("en-US", ""); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
for (size_t i = 0; i < manager_->GetActiveInputMethodIds().size(); ++i) |
LOG(ERROR) << manager_->GetActiveInputMethodIds().at(i); |
// For http://crbug.com/19655#c11 - (5) |
// The hardware keyboard layout "xkb:us::eng" is always active, hence 2U. |
- manager_->EnableLoginLayouts("ja", ""); // Japanese |
+ manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
} |
TEST_F(InputMethodManagerImplTest, TestEnableLayoutsAndCurrentInputMethod) { |
// For http://crbug.com/329061 |
- manager_->EnableLoginLayouts("en-US", "xkb:se::swe"); |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:se::swe"); |
+ |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
const std::string im_id = manager_->GetCurrentInputMethod().id(); |
EXPECT_EQ("xkb:se::swe", im_id); |
} |
TEST_F(InputMethodManagerImplTest, TestEnableLayoutsNonUsHardwareKeyboard) { |
+ std::vector<std::string> keyboard_layouts; |
+ |
// The physical layout is French. |
- delegate_->set_hardware_keyboard_layout("xkb:fr::fra"); |
- manager_->EnableLoginLayouts("en-US", ""); |
+ keyboard_layouts.push_back("xkb:fr::fra"); |
+ delegate_->set_hardware_keyboard_layout(keyboard_layouts); |
+ keyboard_layouts.clear(); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(6U, manager_->GetNumActiveInputMethods()); // 5 + French |
// The physical layout is Japanese. |
- delegate_->set_hardware_keyboard_layout("xkb:jp::jpn"); |
- manager_->EnableLoginLayouts("ja", ""); |
+ manager_->GetInputMethodUtil()->InvalidateHardwareInputMethodIdsCache(); |
+ keyboard_layouts.push_back("xkb:jp::jpn"); |
+ delegate_->set_hardware_keyboard_layout(keyboard_layouts); |
Alexander Alekseev
2014/02/12 14:45:35
Why set_hardware_keyboard_layout() doesn't invalid
Seigo Nonaka
2014/02/12 16:49:51
To invalidate internal cache, need to include chro
Alexander Alekseev
2014/02/12 17:55:52
I mean you can replace two calls:
GetInputMethod
Seigo Nonaka
2014/02/13 04:36:05
Done.
|
+ keyboard_layouts.clear(); |
+ manager_->EnableLoginLayouts("ja", keyboard_layouts); |
// "xkb:us::eng" is not needed, hence 1. |
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
// The physical layout is Russian. |
- delegate_->set_hardware_keyboard_layout("xkb:ru::rus"); |
- manager_->EnableLoginLayouts("ru", ""); |
+ manager_->GetInputMethodUtil()->InvalidateHardwareInputMethodIdsCache(); |
+ keyboard_layouts.push_back("xkb:ru::rus"); |
+ delegate_->set_hardware_keyboard_layout(keyboard_layouts); |
+ keyboard_layouts.clear(); |
+ manager_->EnableLoginLayouts("ru", keyboard_layouts); |
// "xkb:us::eng" only. |
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
EXPECT_EQ("xkb:us::eng", manager_->GetActiveInputMethodIds().front()); |
} |
+TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) { |
+ std::vector<std::string> keyboard_layouts; |
+ |
+ // The physical layouts are French and Hungarian. |
+ keyboard_layouts.push_back("xkb:fr::fra"); |
+ keyboard_layouts.push_back("xkb:hu::hun"); |
+ delegate_->set_hardware_keyboard_layout(keyboard_layouts); |
+ keyboard_layouts.clear(); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
+ // 5 + French + Hungarian |
+ EXPECT_EQ(7U, manager_->GetNumActiveInputMethods()); |
+} |
+ |
+TEST_F(InputMethodManagerImplTest, |
+ TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) { |
+ std::vector<std::string> keyboard_layouts; |
+ |
+ // The physical layouts are French and Hungarian. |
Alexander Alekseev
2014/02/12 14:45:35
English (US) and Russian.
Seigo Nonaka
2014/02/12 16:49:51
Done.
|
+ keyboard_layouts.push_back("xkb:us::eng"); |
+ keyboard_layouts.push_back("xkb:ru::rus"); |
+ delegate_->set_hardware_keyboard_layout(keyboard_layouts); |
+ keyboard_layouts.clear(); |
+ manager_->EnableLoginLayouts("ru", keyboard_layouts); |
+ // xkb:us:eng |
+ EXPECT_EQ(1U, manager_->GetNumActiveInputMethods()); |
+} |
+ |
TEST_F(InputMethodManagerImplTest, TestActiveInputMethods) { |
- manager_->EnableLoginLayouts("ja", ""); // Japanese |
+ std::vector<std::string> keyboard_layouts; |
+ manager_->EnableLoginLayouts("ja", keyboard_layouts); // Japanese |
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
scoped_ptr<InputMethodDescriptors> methods( |
manager_->GetActiveInputMethods()); |
@@ -676,8 +722,10 @@ TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |
TestObserver observer; |
manager_->AddObserver(&observer); |
InitComponentExtension(); |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:us::eng"); |
// For http://crbug.com/19655#c11 - (1) |
- manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
EXPECT_EQ("us", xkeyboard_->last_layout_); |
@@ -715,7 +763,9 @@ TEST_F(InputMethodManagerImplTest, TestPreviousInputMethod) { |
ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
- manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:us::eng"); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
EXPECT_EQ("us", xkeyboard_->last_layout_); |
@@ -788,7 +838,9 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithUsLayouts) { |
TestObserver observer; |
manager_->AddObserver(&observer); |
InitComponentExtension(); |
- manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:us::eng"); |
+ manager_->EnableLoginLayouts("en-US", keyboard_layouts); |
EXPECT_EQ(5U, manager_->GetNumActiveInputMethods()); |
EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
EXPECT_EQ("us", xkeyboard_->last_layout_); |
@@ -825,7 +877,9 @@ TEST_F(InputMethodManagerImplTest, TestSwitchInputMethodWithJpLayout) { |
ui::Accelerator keyup_accelerator(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
keyup_accelerator.set_type(ui::ET_KEY_RELEASED); |
- manager_->EnableLoginLayouts("ja", "xkb:us::eng"); |
+ std::vector<std::string> keyboard_layouts; |
+ keyboard_layouts.push_back("xkb:us::eng"); |
+ manager_->EnableLoginLayouts("ja", keyboard_layouts); |
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
EXPECT_EQ("xkb:us::eng", manager_->GetCurrentInputMethod().id()); |
EXPECT_EQ("us", xkeyboard_->last_layout_); |