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 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // Sends a request to the RenderWidget corresponding to |rwh| to commit the | 72 // Sends a request to the RenderWidget corresponding to |rwh| to commit the |
73 // given |text|. | 73 // given |text|. |
74 void SendImeCommitTextToWidget( | 74 void SendImeCommitTextToWidget( |
75 RenderWidgetHost* rwh, | 75 RenderWidgetHost* rwh, |
76 const base::string16& text, | 76 const base::string16& text, |
77 const std::vector<ui::CompositionUnderline>& underlines, | 77 const std::vector<ui::CompositionUnderline>& underlines, |
78 const gfx::Range& replacement_range, | 78 const gfx::Range& replacement_range, |
79 int relative_cursor_pos); | 79 int relative_cursor_pos); |
80 | 80 |
| 81 // Sends a request to RenderWidget corresponding to |rwh| to set the given |
| 82 // composition text and update the corresponding IME params. |
| 83 void SendImeSetCompositionTextToWidget( |
| 84 RenderWidgetHost* rwh, |
| 85 const base::string16& text, |
| 86 const std::vector<ui::CompositionUnderline>& underlines, |
| 87 const gfx::Range& replacement_range, |
| 88 int selection_start, |
| 89 int selection_end); |
| 90 |
81 // This class provides the necessary API for accessing the state of and also | 91 // This class provides the necessary API for accessing the state of and also |
82 // observing the TextInputManager for WebContents. | 92 // observing the TextInputManager for WebContents. |
83 class TextInputManagerTester { | 93 class TextInputManagerTester { |
84 public: | 94 public: |
85 TextInputManagerTester(WebContents* web_contents); | 95 TextInputManagerTester(WebContents* web_contents); |
86 virtual ~TextInputManagerTester(); | 96 virtual ~TextInputManagerTester(); |
87 | 97 |
88 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState | 98 // Sets a callback which is invoked when a RWHV calls UpdateTextInputState |
89 // on the TextInputManager which is being observed. | 99 // on the TextInputManager which is being observed. |
90 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback); | 100 void SetUpdateTextInputStateCalledCallback(const base::Closure& callback); |
(...skipping 15 matching lines...) Expand all Loading... |
106 bool GetTextInputType(ui::TextInputType* type); | 116 bool GetTextInputType(ui::TextInputType* type); |
107 | 117 |
108 // Returns true if there is a focused <input> and populates |value| with | 118 // Returns true if there is a focused <input> and populates |value| with |
109 // |TextInputState.value| of the TextInputManager. | 119 // |TextInputState.value| of the TextInputManager. |
110 bool GetTextInputValue(std::string* value); | 120 bool GetTextInputValue(std::string* value); |
111 | 121 |
112 // Returns true if there is a focused <input> and populates |length| with the | 122 // Returns true if there is a focused <input> and populates |length| with the |
113 // length of the selected text range in the focused view. | 123 // length of the selected text range in the focused view. |
114 bool GetCurrentTextSelectionLength(size_t* length); | 124 bool GetCurrentTextSelectionLength(size_t* length); |
115 | 125 |
| 126 // This method sets |output| to the last value of composition range length |
| 127 // reported by a renderer corresponding to WebContents. If no such update have |
| 128 // been received, the method will leave |output| untouched and returns false. |
| 129 // Returning true means an update has been received and the value of |output| |
| 130 // has been updated accordingly. |
| 131 bool GetLastCompositionRangeLength(uint32_t* output); |
| 132 |
116 // Returns the RenderWidgetHostView with a focused <input> element or nullptr | 133 // Returns the RenderWidgetHostView with a focused <input> element or nullptr |
117 // if none exists. | 134 // if none exists. |
118 const RenderWidgetHostView* GetActiveView(); | 135 const RenderWidgetHostView* GetActiveView(); |
119 | 136 |
120 // Returns the RenderWidgetHostView which has most recently updated any of its | 137 // Returns the RenderWidgetHostView which has most recently updated any of its |
121 // state (e.g., TextInputState or otherwise). | 138 // state (e.g., TextInputState or otherwise). |
122 RenderWidgetHostView* GetUpdatedView(); | 139 RenderWidgetHostView* GetUpdatedView(); |
123 | 140 |
124 // Returns true if a call to TextInputManager::UpdateTextInputState has led | 141 // Returns true if a call to TextInputManager::UpdateTextInputState has led |
125 // to a change in TextInputState (since the time the observer has been | 142 // to a change in TextInputState (since the time the observer has been |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 const gfx::Range& range); | 257 const gfx::Range& range); |
241 | 258 |
242 // Returns the total count of NSWindows instances which belong to the currently | 259 // Returns the total count of NSWindows instances which belong to the currently |
243 // running NSApplication. | 260 // running NSApplication. |
244 size_t GetOpenNSWindowsCount(); | 261 size_t GetOpenNSWindowsCount(); |
245 #endif | 262 #endif |
246 | 263 |
247 } // namespace content | 264 } // namespace content |
248 | 265 |
249 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ | 266 #endif // CONTENT_PUBLIC_TEST_TEXT_INPUT_TEST_UTILS_H_ |
OLD | NEW |