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

Unified Diff: ash/ime/input_method_menu_manager_unittest.cc

Issue 150203015: Split out InputMethodMenuManager from InputMethodManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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: ash/ime/input_method_menu_manager_unittest.cc
diff --git a/ash/ime/input_method_menu_manager_unittest.cc b/ash/ime/input_method_menu_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..92bba26bc83081730d7b01b32d13a71b32748d72
--- /dev/null
+++ b/ash/ime/input_method_menu_manager_unittest.cc
@@ -0,0 +1,89 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/ime/input_method_menu_manager.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ash {
+namespace ime {
+
+TEST(InputMethodMenuManagerTest, TestUninitializedGet) {
+ EXPECT_DEATH(InputMethodMenuManager::Get(),
+ "g_input_method_menu_manager not initialized");
+}
+
+TEST(InputMethodMenuManagerTest, TestUninitializedShutdown) {
+ EXPECT_DEATH(InputMethodMenuManager::Shutdown(),
+ "g_input_method_menu_manager not initialized");
+}
+
+TEST(InputMethodMenuManagerTest, TestNormalOperation) {
+ InputMethodMenuManager::Initialize();
+ EXPECT_TRUE(NULL != InputMethodMenuManager::Get());
+ InputMethodMenuManager::Shutdown();
+}
+
+class MockObserver : public InputMethodMenuManager::Observer {
+ public:
+ MockObserver() : input_method_menu_item_changed_count_(0) {}
+ virtual ~MockObserver() {}
+
+ // Called when the list of menu items is changed.
+ virtual void InputMethodMenuItemChanged(
+ InputMethodMenuManager* manager) OVERRIDE {
+ input_method_menu_item_changed_count_++;
+ }
+ int input_method_menu_item_changed_count_;
+};
+
+class InputMethodMenuManagerStatefulTest : public testing::Test{
+ public:
+ InputMethodMenuManagerStatefulTest()
+ : observer_(new MockObserver()) {}
+ virtual ~InputMethodMenuManagerStatefulTest() {}
+ virtual void SetUp() OVERRIDE {
+ InputMethodMenuManager::Initialize();
+ menu_manager_ = InputMethodMenuManager::Get();
+ menu_manager_->AddObserver(observer_.get());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ InputMethodMenuManager::Shutdown();
+ }
+
+ InputMethodMenuManager* menu_manager_;
+ scoped_ptr<MockObserver> observer_;
+};
+
+TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) {
+ EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0);
+ menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList());
+ EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 1);
+}
+
+TEST_F(InputMethodMenuManagerStatefulTest, AddAndCheckExists) {
+ InputMethodMenuItemList list;
+ list.push_back(InputMethodMenuItem("key1", "label1", false, false));
+ list.push_back(InputMethodMenuItem("key2", "label2", false, false));
+ menu_manager_->SetCurrentInputMethodMenuItemList(list);
+ EXPECT_EQ(menu_manager_->GetCurrentInputMethodMenuItemList().size(), 2U);
+ EXPECT_EQ(
+ menu_manager_->GetCurrentInputMethodMenuItemList().at(0).ToString(),
+ "key=key1, label=label1, "
+ "is_selection_item=0, is_selection_item_checked=0");
+ EXPECT_EQ(
+ menu_manager_->GetCurrentInputMethodMenuItemList().at(1).ToString(),
+ "key=key2, label=label2, "
+ "is_selection_item=0, is_selection_item_checked=0");
+
+ EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1"));
+ EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2"));
+ EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist"));
+}
+
+} // namespace ime
+} // namespace ash
« no previous file with comments | « ash/ime/input_method_menu_manager.cc ('k') | chrome/browser/chromeos/extensions/input_method_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698