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

Side by Side Diff: ash/ime/input_method_menu_manager_unittest.cc

Issue 165783002: Reland of: Split out InputMethodMenuManager from InputMethodManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comment; spelling 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/ime/input_method_menu_manager.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace ash {
12 namespace ime {
13
14 TEST(InputMethodMenuManagerTest, TestGetSingleton) {
15 EXPECT_TRUE(InputMethodMenuManager::GetInstance());
16 }
17
18 class MockObserver : public InputMethodMenuManager::Observer {
19 public:
20 MockObserver() : input_method_menu_item_changed_count_(0) {}
21 virtual ~MockObserver() {}
22
23 // Called when the list of menu items is changed.
24 virtual void InputMethodMenuItemChanged(
25 InputMethodMenuManager* manager) OVERRIDE {
26 input_method_menu_item_changed_count_++;
27 }
28 int input_method_menu_item_changed_count_;
29 };
30
31 class InputMethodMenuManagerStatefulTest : public testing::Test{
32 public:
33 InputMethodMenuManagerStatefulTest()
34 : observer_(new MockObserver()) {}
35 virtual ~InputMethodMenuManagerStatefulTest() {}
36 virtual void SetUp() OVERRIDE {
37 menu_manager_ = InputMethodMenuManager::GetInstance();
38 menu_manager_->AddObserver(observer_.get());
39 }
40
41 virtual void TearDown() OVERRIDE {
42 menu_manager_->RemoveObserver(observer_.get());
43 }
44
45 InputMethodMenuManager* menu_manager_;
46 scoped_ptr<MockObserver> observer_;
47 };
48
49 TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) {
50 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0);
51 menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList());
52 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 1);
53 }
54
55 TEST_F(InputMethodMenuManagerStatefulTest, AddAndCheckExists) {
56 InputMethodMenuItemList list;
57 list.push_back(InputMethodMenuItem("key1", "label1", false, false));
58 list.push_back(InputMethodMenuItem("key2", "label2", false, false));
59 menu_manager_->SetCurrentInputMethodMenuItemList(list);
60 EXPECT_EQ(menu_manager_->GetCurrentInputMethodMenuItemList().size(), 2U);
61 EXPECT_EQ(
62 menu_manager_->GetCurrentInputMethodMenuItemList().at(0).ToString(),
63 "key=key1, label=label1, "
64 "is_selection_item=0, is_selection_item_checked=0");
65 EXPECT_EQ(
66 menu_manager_->GetCurrentInputMethodMenuItemList().at(1).ToString(),
67 "key=key2, label=label2, "
68 "is_selection_item=0, is_selection_item_checked=0");
69
70 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1"));
71 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2"));
72 EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist"));
73 }
74
75 } // namespace ime
76 } // namespace ash
OLDNEW
« 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