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

Side by Side Diff: ui/base/ime/remote_input_method_win_unittest.cc

Issue 81023002: Remove dead code unnecessarily added by r231563 and 236449 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years 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
« no previous file with comments | « ui/base/ime/remote_input_method_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/ime/remote_input_method_win.h" 5 #include "ui/base/ime/remote_input_method_win.h"
6 6
7 #include <InputScope.h> 7 #include <InputScope.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool cancel_composition_called_; 185 bool cancel_composition_called_;
186 bool text_input_client_updated_called_; 186 bool text_input_client_updated_called_;
187 std::vector<int32> input_scopes_; 187 std::vector<int32> input_scopes_;
188 std::vector<gfx::Rect> composition_character_bounds_; 188 std::vector<gfx::Rect> composition_character_bounds_;
189 DISALLOW_COPY_AND_ASSIGN(MockRemoteInputMethodDelegateWin); 189 DISALLOW_COPY_AND_ASSIGN(MockRemoteInputMethodDelegateWin);
190 }; 190 };
191 191
192 class MockInputMethodObserver : public InputMethodObserver { 192 class MockInputMethodObserver : public InputMethodObserver {
193 public: 193 public:
194 MockInputMethodObserver() 194 MockInputMethodObserver()
195 : on_text_input_type_changed_(0), 195 : on_text_input_state_changed_(0),
196 on_caret_bounds_changed_(0),
197 on_text_input_state_changed_(0),
198 on_input_method_destroyed_changed_(0) { 196 on_input_method_destroyed_changed_(0) {
199 } 197 }
200 virtual ~MockInputMethodObserver() { 198 virtual ~MockInputMethodObserver() {
201 } 199 }
202 void Reset() { 200 void Reset() {
203 on_text_input_type_changed_ = 0;
204 on_caret_bounds_changed_ = 0;
205 on_text_input_state_changed_ = 0; 201 on_text_input_state_changed_ = 0;
206 on_input_method_destroyed_changed_ = 0; 202 on_input_method_destroyed_changed_ = 0;
207 } 203 }
208 size_t on_text_input_type_changed() const {
209 return on_text_input_type_changed_;
210 }
211 size_t on_caret_bounds_changed() const {
212 return on_caret_bounds_changed_;
213 }
214 size_t on_text_input_state_changed() const { 204 size_t on_text_input_state_changed() const {
215 return on_text_input_state_changed_; 205 return on_text_input_state_changed_;
216 } 206 }
217 size_t on_input_method_destroyed_changed() const { 207 size_t on_input_method_destroyed_changed() const {
218 return on_input_method_destroyed_changed_; 208 return on_input_method_destroyed_changed_;
219 } 209 }
220 210
221 private: 211 private:
222 // Overriden from InputMethodObserver. 212 // Overriden from InputMethodObserver.
223 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE { 213 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE {
224 ++on_text_input_type_changed_;
225 } 214 }
226 virtual void OnFocus() OVERRIDE { 215 virtual void OnFocus() OVERRIDE {
227 } 216 }
228 virtual void OnBlur() OVERRIDE { 217 virtual void OnBlur() OVERRIDE {
229 } 218 }
230 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE { 219 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE {
231 ++on_caret_bounds_changed_;
232 } 220 }
233 virtual void OnTextInputStateChanged(const TextInputClient* client) OVERRIDE { 221 virtual void OnTextInputStateChanged(const TextInputClient* client) OVERRIDE {
234 ++on_text_input_state_changed_; 222 ++on_text_input_state_changed_;
235 } 223 }
236 virtual void OnInputMethodDestroyed(const InputMethod* client) OVERRIDE { 224 virtual void OnInputMethodDestroyed(const InputMethod* client) OVERRIDE {
237 ++on_input_method_destroyed_changed_; 225 ++on_input_method_destroyed_changed_;
238 } 226 }
239 227
240 size_t on_text_input_type_changed_;
241 size_t on_caret_bounds_changed_;
242 size_t on_text_input_state_changed_; 228 size_t on_text_input_state_changed_;
243 size_t on_input_method_destroyed_changed_; 229 size_t on_input_method_destroyed_changed_;
244 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver); 230 DISALLOW_COPY_AND_ASSIGN(MockInputMethodObserver);
245 }; 231 };
246 232
247 typedef ScopedObserver<InputMethod, InputMethodObserver> 233 typedef ScopedObserver<InputMethod, InputMethodObserver>
248 InputMethodScopedObserver; 234 InputMethodScopedObserver;
249 235
250 TEST(RemoteInputMethodWinTest, RemoteInputMethodPrivateWin) { 236 TEST(RemoteInputMethodWinTest, RemoteInputMethodPrivateWin) {
251 InputMethod* other_ptr = static_cast<InputMethod*>(NULL) + 1; 237 InputMethod* other_ptr = static_cast<InputMethod*>(NULL) + 1;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 ASSERT_EQ(&text_input_client_the_other, input_method->GetTextInputClient()); 746 ASSERT_EQ(&text_input_client_the_other, input_method->GetTextInputClient());
761 EXPECT_EQ(1u, input_method_observer.on_text_input_state_changed()); 747 EXPECT_EQ(1u, input_method_observer.on_text_input_state_changed());
762 input_method_observer.Reset(); 748 input_method_observer.Reset();
763 749
764 input_method->DetachTextInputClient(&text_input_client_the_other); 750 input_method->DetachTextInputClient(&text_input_client_the_other);
765 ASSERT_TRUE(input_method->GetTextInputClient() == NULL); 751 ASSERT_TRUE(input_method->GetTextInputClient() == NULL);
766 EXPECT_EQ(1u, input_method_observer.on_text_input_state_changed()); 752 EXPECT_EQ(1u, input_method_observer.on_text_input_state_changed());
767 input_method_observer.Reset(); 753 input_method_observer.Reset();
768 } 754 }
769 755
770 TEST(RemoteInputMethodWinTest, OnCaretBoundsChanged_Observer) {
771 DummyTextInputClient text_input_client;
772 DummyTextInputClient text_input_client_the_other;
773
774 MockInputMethodObserver input_method_observer;
775 MockInputMethodDelegate delegate_;
776 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
777 InputMethodScopedObserver scoped_observer(&input_method_observer);
778 scoped_observer.Add(input_method.get());
779
780 {
781 SCOPED_TRACE("OnCaretBoundsChanged callback must not be fired when no text "
782 "input client is focused");
783 ASSERT_EQ(NULL, input_method->GetTextInputClient());
784
785 input_method_observer.Reset();
786 input_method->OnCaretBoundsChanged(&text_input_client);
787 EXPECT_EQ(0u, input_method_observer.on_caret_bounds_changed());
788 input_method->OnCaretBoundsChanged(NULL);
789 EXPECT_EQ(0u, input_method_observer.on_caret_bounds_changed());
790 }
791
792 {
793 SCOPED_TRACE("OnCaretBoundsChanged callback must be fired when and only "
794 "the event is notified from the focused text input client");
795
796 input_method->SetFocusedTextInputClient(&text_input_client);
797 ASSERT_EQ(&text_input_client, input_method->GetTextInputClient());
798
799 // Must fire the event
800 input_method_observer.Reset();
801 input_method->OnCaretBoundsChanged(&text_input_client);
802 EXPECT_EQ(1u, input_method_observer.on_caret_bounds_changed());
803
804 // Must not fire the event
805 input_method_observer.Reset();
806 input_method->OnCaretBoundsChanged(NULL);
807 EXPECT_EQ(0u, input_method_observer.on_caret_bounds_changed());
808
809 // Must not fire the event
810 input_method_observer.Reset();
811 input_method->OnCaretBoundsChanged(&text_input_client_the_other);
812 EXPECT_EQ(0u, input_method_observer.on_caret_bounds_changed());
813 }
814 }
815
816 TEST(RemoteInputMethodWinTest, OnInputMethodDestroyed_Observer) { 756 TEST(RemoteInputMethodWinTest, OnInputMethodDestroyed_Observer) {
817 DummyTextInputClient text_input_client; 757 DummyTextInputClient text_input_client;
818 DummyTextInputClient text_input_client_the_other; 758 DummyTextInputClient text_input_client_the_other;
819 759
820 MockInputMethodObserver input_method_observer; 760 MockInputMethodObserver input_method_observer;
821 InputMethodScopedObserver scoped_observer(&input_method_observer); 761 InputMethodScopedObserver scoped_observer(&input_method_observer);
822 762
823 MockInputMethodDelegate delegate_; 763 MockInputMethodDelegate delegate_;
824 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); 764 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_));
825 input_method->AddObserver(&input_method_observer); 765 input_method->AddObserver(&input_method_observer);
826 766
827 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed()); 767 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed());
828 input_method.reset(); 768 input_method.reset();
829 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed()); 769 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed());
830 } 770 }
831 771
832 } // namespace 772 } // namespace
833 } // namespace ui 773 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/remote_input_method_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698