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 e657f1c7ec98d80471441fbe89a81c44ac2e718f..b6a144394cf839ead5956151809f0a900add1360 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 |
@@ -6,6 +6,8 @@ |
#include <algorithm> |
+#include "ash/ime/input_method_menu_item.h" |
+#include "ash/ime/input_method_menu_manager.h" |
#include "base/basictypes.h" |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
@@ -71,6 +73,8 @@ class InputMethodManagerImplTest : public testing::Test { |
IMEBridge::Initialize(); |
IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
+ menu_manager_ = ash::ime::InputMethodMenuManager::Get(); |
+ |
ime_list_.clear(); |
ComponentExtensionIME ext1; |
@@ -121,6 +125,7 @@ class InputMethodManagerImplTest : public testing::Test { |
candidate_window_controller_ = NULL; |
xkeyboard_ = NULL; |
manager_.reset(); |
+ |
IMEBridge::Get()->SetCurrentEngineHandler(NULL); |
IMEBridge::Shutdown(); |
} |
@@ -153,16 +158,18 @@ class InputMethodManagerImplTest : public testing::Test { |
base::MessageLoop message_loop_; |
MockComponentExtIMEManagerDelegate* mock_delegate_; |
std::vector<ComponentExtensionIME> ime_list_; |
+ ash::ime::InputMethodMenuManager* menu_manager_; |
private: |
DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); |
}; |
-class TestObserver : public InputMethodManager::Observer { |
+class TestObserver : public InputMethodManager::Observer, |
+ public ash::ime::InputMethodMenuManager::Observer{ |
public: |
TestObserver() |
: input_method_changed_count_(0), |
- input_method_property_changed_count_(0), |
+ input_method_menu_item_changed_count_(0), |
last_show_message_(false) { |
} |
virtual ~TestObserver() {} |
@@ -172,13 +179,13 @@ class TestObserver : public InputMethodManager::Observer { |
++input_method_changed_count_; |
last_show_message_ = show_message; |
} |
- virtual void InputMethodPropertyChanged( |
- InputMethodManager* manager) OVERRIDE { |
- ++input_method_property_changed_count_; |
+ virtual void InputMethodMenuItemChanged( |
+ ash::ime::InputMethodMenuManager* manager) OVERRIDE { |
+ ++input_method_menu_item_changed_count_; |
} |
int input_method_changed_count_; |
- int input_method_property_changed_count_; |
+ int input_method_menu_item_changed_count_; |
bool last_show_message_; |
private: |
@@ -236,14 +243,15 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { |
TestObserver observer; |
InitComponentExtension(); |
manager_->AddObserver(&observer); |
+ menu_manager_->AddObserver(&observer); |
EXPECT_EQ(0, observer.input_method_changed_count_); |
manager_->EnableLoginLayouts("en-US", "xkb:us::eng"); |
EXPECT_EQ(1, observer.input_method_changed_count_); |
- EXPECT_EQ(1, observer.input_method_property_changed_count_); |
+ EXPECT_EQ(1, observer.input_method_menu_item_changed_count_); |
manager_->ChangeInputMethod("xkb:us:dvorak:eng"); |
EXPECT_FALSE(observer.last_show_message_); |
EXPECT_EQ(2, observer.input_method_changed_count_); |
- EXPECT_EQ(2, observer.input_method_property_changed_count_); |
+ EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
manager_->ChangeInputMethod("xkb:us:dvorak:eng"); |
EXPECT_FALSE(observer.last_show_message_); |
@@ -254,7 +262,7 @@ TEST_F(InputMethodManagerImplTest, TestObserver) { |
// If the same input method ID is passed, PropertyChanged() is not |
// notified. |
- EXPECT_EQ(2, observer.input_method_property_changed_count_); |
+ EXPECT_EQ(2, observer.input_method_menu_item_changed_count_); |
manager_->RemoveObserver(&observer); |
} |
@@ -593,23 +601,24 @@ TEST_F(InputMethodManagerImplTest, TestXkbSetting) { |
EXPECT_EQ("us(colemak)", xkeyboard_->last_layout_); |
} |
-TEST_F(InputMethodManagerImplTest, TestActivateInputMethodProperty) { |
+TEST_F(InputMethodManagerImplTest, TestActivateInputMethodMenuItem) { |
const std::string kKey = "key"; |
- InputMethodPropertyList property_list; |
- property_list.push_back(InputMethodProperty(kKey, "label", false, false)); |
- manager_->SetCurrentInputMethodProperties(property_list); |
+ ash::ime::InputMethodMenuItemList menu_list; |
+ menu_list.push_back(ash::ime::InputMethodMenuItem( |
+ kKey, "label", false, false)); |
+ menu_manager_->SetCurrentInputMethodMenuItemList(menu_list); |
- manager_->ActivateInputMethodProperty(kKey); |
+ manager_->ActivateInputMethodMenuItem(kKey); |
EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
// Key2 is not registered, so activated property should not be changed. |
- manager_->ActivateInputMethodProperty("key2"); |
+ manager_->ActivateInputMethodMenuItem("key2"); |
EXPECT_EQ(kKey, mock_engine_handler_->last_activated_property()); |
} |
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
InitComponentExtension(); |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
std::vector<std::string> ids; |
@@ -617,26 +626,25 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodProperties) { |
ids.push_back(kNaclMozcUsId); |
EXPECT_TRUE(manager_->EnableInputMethods(ids)); |
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
manager_->ChangeInputMethod(kNaclMozcUsId); |
- InputMethodPropertyList current_property_list; |
- current_property_list.push_back(InputMethodProperty("key", |
- "label", |
- false, |
- false)); |
- manager_->SetCurrentInputMethodProperties(current_property_list); |
+ ash::ime::InputMethodMenuItemList current_property_list; |
+ current_property_list.push_back(ash::ime::InputMethodMenuItem( |
+ "key", "label", false, false)); |
+ menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
- ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); |
- EXPECT_EQ("key", manager_->GetCurrentInputMethodProperties().at(0).key); |
+ ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
+ EXPECT_EQ("key", |
+ menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
manager_->ChangeInputMethod("xkb:us::eng"); |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
} |
TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
InitComponentExtension(); |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
manager_->SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
std::vector<std::string> ids; |
@@ -644,32 +652,31 @@ TEST_F(InputMethodManagerImplTest, TestGetCurrentInputMethodPropertiesTwoImes) { |
ids.push_back(kExt2Engine1Id); // T-Chinese |
EXPECT_TRUE(manager_->EnableInputMethods(ids)); |
EXPECT_EQ(2U, manager_->GetNumActiveInputMethods()); |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
- InputMethodPropertyList current_property_list; |
- current_property_list.push_back(InputMethodProperty("key-mozc", |
- "label", |
- false, |
- false)); |
- manager_->SetCurrentInputMethodProperties(current_property_list); |
+ ash::ime::InputMethodMenuItemList current_property_list; |
+ current_property_list.push_back(ash::ime::InputMethodMenuItem("key-mozc", |
+ "label", |
+ false, |
+ false)); |
+ menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
- ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); |
- EXPECT_EQ("key-mozc", manager_->GetCurrentInputMethodProperties().at(0).key); |
+ ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
+ EXPECT_EQ("key-mozc", |
+ menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
manager_->ChangeInputMethod(kExt2Engine1Id); |
// Since the IME is changed, the property for mozc Japanese should be hidden. |
- EXPECT_TRUE(manager_->GetCurrentInputMethodProperties().empty()); |
+ EXPECT_TRUE(menu_manager_->GetCurrentInputMethodMenuItemList().empty()); |
// Asynchronous property update signal from mozc-chewing. |
current_property_list.clear(); |
- current_property_list.push_back(InputMethodProperty("key-chewing", |
- "label", |
- false, |
- false)); |
- manager_->SetCurrentInputMethodProperties(current_property_list); |
- ASSERT_EQ(1U, manager_->GetCurrentInputMethodProperties().size()); |
+ current_property_list.push_back(ash::ime::InputMethodMenuItem( |
+ "key-chewing", "label", false, false)); |
+ menu_manager_->SetCurrentInputMethodMenuItemList(current_property_list); |
+ ASSERT_EQ(1U, menu_manager_->GetCurrentInputMethodMenuItemList().size()); |
EXPECT_EQ("key-chewing", |
- manager_->GetCurrentInputMethodProperties().at(0).key); |
+ menu_manager_->GetCurrentInputMethodMenuItemList().at(0).key); |
} |
TEST_F(InputMethodManagerImplTest, TestNextInputMethod) { |