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

Side by Side Diff: chrome/browser/chromeos/input_method/ibus_controller_impl_unittest.cc

Issue 23460003: Merge IBusContorllerBase into IBusControllerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "chrome/browser/chromeos/input_method/ibus_controller_impl.h" 6 #include "chrome/browser/chromeos/input_method/ibus_controller_impl.h"
7 #include "chromeos/ime/input_method_property.h" 7 #include "chromeos/ime/input_method_property.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
11 namespace input_method { 11 namespace input_method {
12 12
13 namespace { 13 namespace {
14 14
15 bool FindAndUpdateProperty(const InputMethodProperty& new_prop, 15 bool FindAndUpdateProperty(const InputMethodProperty& new_prop,
16 InputMethodPropertyList* prop_list) { 16 InputMethodPropertyList* prop_list) {
17 return IBusControllerImpl::FindAndUpdatePropertyForTesting(new_prop, 17 return IBusControllerImpl::FindAndUpdatePropertyForTesting(new_prop,
18 prop_list); 18 prop_list);
19 } 19 }
20 20
21 // A mock class for testing AddObserver() and RemoveObserver() methods
22 // in IBusControllerImpl.
23 class TestIBusController : public IBusControllerImpl {
24 public:
25 TestIBusController() {
26 }
27 virtual ~TestIBusController() {
Seigo Nonaka 2013/08/27 11:31:12 nit: please add one line break above.
Hiro Komatsu 2013/08/28 01:41:28 Done.
28 }
29
30 bool HasObservers() const {
31 return observers_.might_have_observers();
32 }
33
34 private:
35 DISALLOW_COPY_AND_ASSIGN(TestIBusController);
36 };
37
38 class TestObserver : public IBusController::Observer {
39 public:
40 // IBusController::Observer overrides:
41 virtual void PropertyChanged() OVERRIDE {}
42 };
21 } // namespace 43 } // namespace
22 44
23 TEST(IBusControllerImplTest, TestFindAndUpdateProperty) { 45 TEST(IBusControllerImplTest, TestFindAndUpdateProperty) {
24 InputMethodPropertyList properties; 46 InputMethodPropertyList properties;
25 EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties)); 47 EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties));
26 48
27 properties.push_back( 49 properties.push_back(
28 InputMethodProperty("key1", "label1", false, false)); 50 InputMethodProperty("key1", "label1", false, false));
29 EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties)); 51 EXPECT_FALSE(FindAndUpdateProperty(InputMethodProperty(), &properties));
30 EXPECT_FALSE(FindAndUpdateProperty( 52 EXPECT_FALSE(FindAndUpdateProperty(
(...skipping 11 matching lines...) Expand all
42 EXPECT_FALSE(FindAndUpdateProperty( 64 EXPECT_FALSE(FindAndUpdateProperty(
43 InputMethodProperty("keyX", "labelX", false, false), &properties)); 65 InputMethodProperty("keyX", "labelX", false, false), &properties));
44 EXPECT_EQ(InputMethodProperty("key2", "label2", false, false), 66 EXPECT_EQ(InputMethodProperty("key2", "label2", false, false),
45 properties[1]); 67 properties[1]);
46 EXPECT_TRUE(FindAndUpdateProperty( 68 EXPECT_TRUE(FindAndUpdateProperty(
47 InputMethodProperty("key2", "labelZ", false, false), &properties)); 69 InputMethodProperty("key2", "labelZ", false, false), &properties));
48 EXPECT_EQ(InputMethodProperty("key2", "labelZ", false, false), 70 EXPECT_EQ(InputMethodProperty("key2", "labelZ", false, false),
49 properties[1]); 71 properties[1]);
50 } 72 }
51 73
74 TEST(IBusControllerImplTest, TestAddRemoveObserver) {
75 IBusBridge::Initialize();
76 {
77 TestIBusController controller;
78 TestObserver observer1;
79 TestObserver observer2;
80 TestObserver observer3;
81 EXPECT_FALSE(controller.HasObservers());
82 controller.AddObserver(&observer1);
83 EXPECT_TRUE(controller.HasObservers());
84 controller.AddObserver(&observer2);
85 EXPECT_TRUE(controller.HasObservers());
86 controller.RemoveObserver(&observer3); // nop
87 EXPECT_TRUE(controller.HasObservers());
88 controller.RemoveObserver(&observer1);
89 EXPECT_TRUE(controller.HasObservers());
90 controller.RemoveObserver(&observer1); // nop
91 EXPECT_TRUE(controller.HasObservers());
92 controller.RemoveObserver(&observer2);
93 EXPECT_FALSE(controller.HasObservers());
94 }
95 IBusBridge::Shutdown();
96 }
97
98 TEST(IBusControllerImplTest, TestGetCurrentProperties) {
99 IBusBridge::Initialize();
100 {
101 IBusControllerImpl controller;
102 EXPECT_EQ(0U, controller.GetCurrentProperties().size());
103 }
104 IBusBridge::Shutdown();
105 }
106
52 } // namespace input_method 107 } // namespace input_method
53 } // namespace chromeos 108 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller_impl.cc ('k') | chrome/chrome_browser_chromeos.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698