Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Unified Diff: chrome/browser/chromeos/input_method/input_method_manager_impl_unittest.cc

Issue 139803010: Support comma separated hardware keyboard layout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix wrong condition. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..491dfea16d18ac7ff1c9b7d0d632332c6c424f7b 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
@@ -62,6 +62,7 @@ class InputMethodManagerImplTest : public testing::Test {
delegate_ = new FakeInputMethodDelegate();
manager_.reset(new InputMethodManagerImpl(
scoped_ptr<InputMethodDelegate>(delegate_)));
+ manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache();
candidate_window_controller_ = new MockCandidateWindowController;
manager_->SetCandidateWindowControllerForTesting(
candidate_window_controller_);
@@ -233,11 +234,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 +287,84 @@ 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) {
// The physical layout is French.
- delegate_->set_hardware_keyboard_layout("xkb:fr::fra");
- manager_->EnableLoginLayouts("en-US", "");
+ manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting(
+ "xkb:fr::fra");
+ manager_->EnableLoginLayouts(
+ "en-US",
+ manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds());
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()->SetHardwareKeyboardLayoutForTesting(
+ "xkb:jp::jpn");
+ manager_->EnableLoginLayouts(
+ "ja",
+ manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds());
// "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()->SetHardwareKeyboardLayoutForTesting(
+ "xkb:ru::rus");
+ manager_->EnableLoginLayouts(
+ "ru",
+ manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds());
// "xkb:us::eng" only.
EXPECT_EQ(1U, manager_->GetNumActiveInputMethods());
EXPECT_EQ("xkb:us::eng", manager_->GetActiveInputMethodIds().front());
}
+TEST_F(InputMethodManagerImplTest, TestEnableMultipleHardwareKeyboardLayout) {
+ // The physical layouts are French and Hungarian.
+ manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting(
+ "xkb:fr::fra,xkb:hu::hun");
+ manager_->EnableLoginLayouts(
+ "en-US",
+ manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds());
+ // 5 + French + Hungarian
+ EXPECT_EQ(7U, manager_->GetNumActiveInputMethods());
+}
+
+TEST_F(InputMethodManagerImplTest,
+ TestEnableMultipleHardwareKeyboardLayout_NoLoginKeyboard) {
+ // The physical layouts are English (US) and Russian.
+ manager_->GetInputMethodUtil()->SetHardwareKeyboardLayoutForTesting(
+ "xkb:us::eng,xkb:ru::rus");
+ manager_->EnableLoginLayouts(
+ "ru",
+ manager_->GetInputMethodUtil()->GetHardwareLoginInputMethodIds());
+ // 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 +718,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 +759,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 +834,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 +873,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_);

Powered by Google App Engine
This is Rietveld 408576698