OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/ime/arc_ime_service.h" |
| 6 |
| 7 #include <memory> |
5 #include <utility> | 8 #include <utility> |
6 | 9 |
7 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
10 #include "components/arc/ime/arc_ime_service.h" | |
11 #include "components/arc/test/fake_arc_bridge_service.h" | 13 #include "components/arc/test/fake_arc_bridge_service.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/base/ime/composition_text.h" | 15 #include "ui/base/ime/composition_text.h" |
14 #include "ui/base/ime/dummy_input_method.h" | 16 #include "ui/base/ime/dummy_input_method.h" |
15 | 17 |
16 namespace arc { | 18 namespace arc { |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 class FakeArcImeBridge : public ArcImeBridge { | 22 class FakeArcImeBridge : public ArcImeBridge { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 int count_cancel_composition_; | 66 int count_cancel_composition_; |
65 }; | 67 }; |
66 | 68 |
67 } // namespace | 69 } // namespace |
68 | 70 |
69 class ArcImeServiceTest : public testing::Test { | 71 class ArcImeServiceTest : public testing::Test { |
70 public: | 72 public: |
71 ArcImeServiceTest() {} | 73 ArcImeServiceTest() {} |
72 | 74 |
73 protected: | 75 protected: |
74 scoped_ptr<FakeArcBridgeService> fake_arc_bridge_service_; | 76 std::unique_ptr<FakeArcBridgeService> fake_arc_bridge_service_; |
75 scoped_ptr<FakeInputMethod> fake_input_method_; | 77 std::unique_ptr<FakeInputMethod> fake_input_method_; |
76 scoped_ptr<ArcImeService> instance_; | 78 std::unique_ptr<ArcImeService> instance_; |
77 | 79 |
78 private: | 80 private: |
79 void SetUp() override { | 81 void SetUp() override { |
80 fake_arc_bridge_service_.reset(new FakeArcBridgeService); | 82 fake_arc_bridge_service_.reset(new FakeArcBridgeService); |
81 instance_.reset(new ArcImeService(fake_arc_bridge_service_.get())); | 83 instance_.reset(new ArcImeService(fake_arc_bridge_service_.get())); |
82 instance_->SetImeBridgeForTesting(make_scoped_ptr(new FakeArcImeBridge)); | 84 instance_->SetImeBridgeForTesting(base::WrapUnique(new FakeArcImeBridge)); |
83 | 85 |
84 fake_input_method_.reset(new FakeInputMethod); | 86 fake_input_method_.reset(new FakeInputMethod); |
85 instance_->SetInputMethodForTesting(fake_input_method_.get()); | 87 instance_->SetInputMethodForTesting(fake_input_method_.get()); |
86 } | 88 } |
87 | 89 |
88 void TearDown() override { | 90 void TearDown() override { |
89 instance_.reset(); | 91 instance_.reset(); |
90 fake_arc_bridge_service_.reset(); | 92 fake_arc_bridge_service_.reset(); |
91 } | 93 } |
92 }; | 94 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 141 } |
140 | 142 |
141 TEST_F(ArcImeServiceTest, CancelComposition) { | 143 TEST_F(ArcImeServiceTest, CancelComposition) { |
142 // The bridge should forward the cancel event to the input method. | 144 // The bridge should forward the cancel event to the input method. |
143 fake_input_method_->SetFocusedTextInputClient(instance_.get()); | 145 fake_input_method_->SetFocusedTextInputClient(instance_.get()); |
144 instance_->OnCancelComposition(); | 146 instance_->OnCancelComposition(); |
145 EXPECT_EQ(1, fake_input_method_->count_cancel_composition()); | 147 EXPECT_EQ(1, fake_input_method_->count_cancel_composition()); |
146 } | 148 } |
147 | 149 |
148 } // namespace arc | 150 } // namespace arc |
OLD | NEW |