OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/ime/input_method_menu_manager.h" | 5 #include "ash/ime/input_method_menu_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace ash { | 11 namespace ash { |
12 namespace ime { | 12 namespace ime { |
13 | 13 |
14 TEST(InputMethodMenuManagerTest, TestGetSingleton) { | 14 TEST(InputMethodMenuManagerTest, TestGetSingleton) { |
15 EXPECT_TRUE(InputMethodMenuManager::GetInstance()); | 15 EXPECT_TRUE(InputMethodMenuManager::GetInstance()); |
16 } | 16 } |
17 | 17 |
18 class MockObserver : public InputMethodMenuManager::Observer { | 18 class MockObserver : public InputMethodMenuManager::Observer { |
19 public: | 19 public: |
20 MockObserver() : input_method_menu_item_changed_count_(0) {} | 20 MockObserver() : input_method_menu_item_changed_count_(0) {} |
21 virtual ~MockObserver() {} | 21 virtual ~MockObserver() {} |
22 | 22 |
23 // Called when the list of menu items is changed. | 23 // Called when the list of menu items is changed. |
24 virtual void InputMethodMenuItemChanged( | 24 virtual void InputMethodMenuItemChanged( |
25 InputMethodMenuManager* manager) OVERRIDE { | 25 InputMethodMenuManager* manager) override { |
26 input_method_menu_item_changed_count_++; | 26 input_method_menu_item_changed_count_++; |
27 } | 27 } |
28 int input_method_menu_item_changed_count_; | 28 int input_method_menu_item_changed_count_; |
29 }; | 29 }; |
30 | 30 |
31 class InputMethodMenuManagerStatefulTest : public testing::Test{ | 31 class InputMethodMenuManagerStatefulTest : public testing::Test{ |
32 public: | 32 public: |
33 InputMethodMenuManagerStatefulTest() | 33 InputMethodMenuManagerStatefulTest() |
34 : observer_(new MockObserver()) {} | 34 : observer_(new MockObserver()) {} |
35 virtual ~InputMethodMenuManagerStatefulTest() {} | 35 virtual ~InputMethodMenuManagerStatefulTest() {} |
36 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() override { |
37 menu_manager_ = InputMethodMenuManager::GetInstance(); | 37 menu_manager_ = InputMethodMenuManager::GetInstance(); |
38 menu_manager_->AddObserver(observer_.get()); | 38 menu_manager_->AddObserver(observer_.get()); |
39 } | 39 } |
40 | 40 |
41 virtual void TearDown() OVERRIDE { | 41 virtual void TearDown() override { |
42 menu_manager_->RemoveObserver(observer_.get()); | 42 menu_manager_->RemoveObserver(observer_.get()); |
43 } | 43 } |
44 | 44 |
45 InputMethodMenuManager* menu_manager_; | 45 InputMethodMenuManager* menu_manager_; |
46 scoped_ptr<MockObserver> observer_; | 46 scoped_ptr<MockObserver> observer_; |
47 }; | 47 }; |
48 | 48 |
49 TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) { | 49 TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) { |
50 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0); | 50 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0); |
51 menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList()); | 51 menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList()); |
(...skipping 15 matching lines...) Expand all Loading... |
67 "key=key2, label=label2, " | 67 "key=key2, label=label2, " |
68 "is_selection_item=0, is_selection_item_checked=0"); | 68 "is_selection_item=0, is_selection_item_checked=0"); |
69 | 69 |
70 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1")); | 70 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1")); |
71 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2")); | 71 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2")); |
72 EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist")); | 72 EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist")); |
73 } | 73 } |
74 | 74 |
75 } // namespace ime | 75 } // namespace ime |
76 } // namespace ash | 76 } // namespace ash |
OLD | NEW |