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

Side by Side Diff: ui/base/ime/mock_ime_input_context_handler.h

Issue 1780523006: Add tests for input.ime.* APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 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 #ifndef UI_BASE_IME_CHROMEOS_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ 5 #ifndef UI_BASE_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_
6 #define UI_BASE_IME_CHROMEOS_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ 6 #define UI_BASE_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "ui/base/ime/composition_text.h" 10 #include "ui/base/ime/composition_text.h"
11 #include "ui/base/ime/ime_input_context_handler_interface.h" 11 #include "ui/base/ime/ime_input_context_handler_interface.h"
12 #include "ui/base/ime/ui_base_ime_export.h" 12 #include "ui/base/ime/ui_base_ime_export.h"
13 13
14 namespace chromeos { 14 namespace ui {
15 15
16 class UI_BASE_IME_EXPORT MockIMEInputContextHandler 16 class UI_BASE_IME_EXPORT MockIMEInputContextHandler
17 : public ui::IMEInputContextHandlerInterface { 17 : public IMEInputContextHandlerInterface {
18 public: 18 public:
19 struct UpdateCompositionTextArg { 19 struct UpdateCompositionTextArg {
20 ui::CompositionText composition_text; 20 CompositionText composition_text;
21 uint32_t cursor_pos; 21 uint32_t cursor_pos;
22 bool is_visible; 22 bool is_visible;
23 }; 23 };
24 24
25 struct DeleteSurroundingTextArg { 25 struct DeleteSurroundingTextArg {
26 int32_t offset; 26 int32_t offset;
27 uint32_t length; 27 uint32_t length;
28 }; 28 };
29 29
30 MockIMEInputContextHandler(); 30 MockIMEInputContextHandler();
31 virtual ~MockIMEInputContextHandler(); 31 virtual ~MockIMEInputContextHandler();
32 32
33 void CommitText(const std::string& text) override; 33 void CommitText(const std::string& text) override;
34 void UpdateCompositionText(const ui::CompositionText& text, 34 void UpdateCompositionText(const CompositionText& text,
35 uint32_t cursor_pos, 35 uint32_t cursor_pos,
36 bool visible) override; 36 bool visible) override;
37 void DeleteSurroundingText(int32_t offset, uint32_t length) override; 37 void DeleteSurroundingText(int32_t offset, uint32_t length) override;
38 38
39 int commit_text_call_count() const { return commit_text_call_count_; } 39 int commit_text_call_count() const { return commit_text_call_count_; }
40 40
41 int update_preedit_text_call_count() const { 41 int update_preedit_text_call_count() const {
42 return update_preedit_text_call_count_; 42 return update_preedit_text_call_count_;
43 } 43 }
44 44
45 int delete_surrounding_text_call_count() const { 45 int delete_surrounding_text_call_count() const {
46 return delete_surrounding_text_call_count_; 46 return delete_surrounding_text_call_count_;
47 } 47 }
48 48
49 const std::string& last_commit_text() const { 49 const std::string& last_commit_text() const { return last_commit_text_; };
50 return last_commit_text_;
51 };
52 50
53 const UpdateCompositionTextArg& last_update_composition_arg() const { 51 const UpdateCompositionTextArg& last_update_composition_arg() const {
54 return last_update_composition_arg_; 52 return last_update_composition_arg_;
55 } 53 }
56 54
57 const DeleteSurroundingTextArg& last_delete_surrounding_text_arg() const { 55 const DeleteSurroundingTextArg& last_delete_surrounding_text_arg() const {
58 return last_delete_surrounding_text_arg_; 56 return last_delete_surrounding_text_arg_;
59 } 57 }
60 58
61 // Resets all call count. 59 // Resets all call count.
62 void Reset(); 60 void Reset();
63 61
64 private: 62 private:
65 int commit_text_call_count_; 63 int commit_text_call_count_;
66 int update_preedit_text_call_count_; 64 int update_preedit_text_call_count_;
67 int delete_surrounding_text_call_count_; 65 int delete_surrounding_text_call_count_;
68 std::string last_commit_text_; 66 std::string last_commit_text_;
69 UpdateCompositionTextArg last_update_composition_arg_; 67 UpdateCompositionTextArg last_update_composition_arg_;
70 DeleteSurroundingTextArg last_delete_surrounding_text_arg_; 68 DeleteSurroundingTextArg last_delete_surrounding_text_arg_;
71 }; 69 };
72 70
73 } // namespace chromeos 71 } // namespace ui
74 72
75 #endif // UI_BASE_IME_CHROMEOS_MOCK_IME_INPUT_CONTEXT_HANDLER_H_ 73 #endif // UI_BASE_IME_MOCK_IME_INPUT_CONTEXT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698