| 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 "ui/chromeos/ime/input_method_menu_manager.h" | 5 #include "ui/chromeos/ime/input_method_menu_manager.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 namespace ui { | 12 namespace ui { |
| 12 namespace ime { | 13 namespace ime { |
| 13 | 14 |
| 14 TEST(InputMethodMenuManagerTest, TestGetSingleton) { | 15 TEST(InputMethodMenuManagerTest, TestGetSingleton) { |
| 15 EXPECT_TRUE(InputMethodMenuManager::GetInstance()); | 16 EXPECT_TRUE(InputMethodMenuManager::GetInstance()); |
| 16 } | 17 } |
| 17 | 18 |
| 18 class MockObserver : public InputMethodMenuManager::Observer { | 19 class MockObserver : public InputMethodMenuManager::Observer { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 : observer_(new MockObserver()) {} | 34 : observer_(new MockObserver()) {} |
| 34 ~InputMethodMenuManagerStatefulTest() override {} | 35 ~InputMethodMenuManagerStatefulTest() override {} |
| 35 void SetUp() override { | 36 void SetUp() override { |
| 36 menu_manager_ = InputMethodMenuManager::GetInstance(); | 37 menu_manager_ = InputMethodMenuManager::GetInstance(); |
| 37 menu_manager_->AddObserver(observer_.get()); | 38 menu_manager_->AddObserver(observer_.get()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void TearDown() override { menu_manager_->RemoveObserver(observer_.get()); } | 41 void TearDown() override { menu_manager_->RemoveObserver(observer_.get()); } |
| 41 | 42 |
| 42 InputMethodMenuManager* menu_manager_; | 43 InputMethodMenuManager* menu_manager_; |
| 43 scoped_ptr<MockObserver> observer_; | 44 std::unique_ptr<MockObserver> observer_; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) { | 47 TEST_F(InputMethodMenuManagerStatefulTest, AddAndObserve) { |
| 47 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0); | 48 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 0); |
| 48 menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList()); | 49 menu_manager_->SetCurrentInputMethodMenuItemList(InputMethodMenuItemList()); |
| 49 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 1); | 50 EXPECT_EQ(observer_->input_method_menu_item_changed_count_, 1); |
| 50 } | 51 } |
| 51 | 52 |
| 52 TEST_F(InputMethodMenuManagerStatefulTest, AddAndCheckExists) { | 53 TEST_F(InputMethodMenuManagerStatefulTest, AddAndCheckExists) { |
| 53 InputMethodMenuItemList list; | 54 InputMethodMenuItemList list; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 64 "key=key2, label=label2, " | 65 "key=key2, label=label2, " |
| 65 "is_selection_item=0, is_selection_item_checked=0"); | 66 "is_selection_item=0, is_selection_item_checked=0"); |
| 66 | 67 |
| 67 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1")); | 68 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key1")); |
| 68 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2")); | 69 EXPECT_TRUE(menu_manager_->HasInputMethodMenuItemForKey("key2")); |
| 69 EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist")); | 70 EXPECT_FALSE(menu_manager_->HasInputMethodMenuItemForKey("key-not-exist")); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace ime | 73 } // namespace ime |
| 73 } // namespace ui | 74 } // namespace ui |
| OLD | NEW |