1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "inputmethod_controller_capi.h"
16 #include <gtest/gtest.h>
17 
18 using namespace testing::ext;
19 class InputMethodControllerCapiTest : public testing::Test { };
20 
21 /**
22  * @tc.name: TestCursorInfo_001
23  * @tc.desc: create and destroy TestCursorInfo success
24  * @tc.type: FUNC
25  */
26 HWTEST_F(InputMethodControllerCapiTest, TestCursorInfo_001, TestSize.Level0)
27 {
28     double expLeft = 1.1;
29     double expTop = 2.2;
30     double expWidth = 3.3;
31     double expHeight = 4.4;
32     auto cursorInfo = OH_CursorInfo_Create(expLeft, expTop, expWidth, expHeight);
33     ASSERT_NE(nullptr, cursorInfo);
34 
35     double actLeft = 0;
36     double actTop = 0;
37     double actWidth = 0;
38     double actHeight = 0;
39     EXPECT_EQ(IME_ERR_OK, OH_CursorInfo_GetRect(cursorInfo, &actLeft, &actTop, &actWidth, &actHeight));
40     EXPECT_EQ(expLeft, actLeft);
41     EXPECT_EQ(expTop, actTop);
42     EXPECT_EQ(expWidth, actWidth);
43     EXPECT_EQ(expHeight, actHeight);
44 
45     // test set rect
46     expLeft = 1;
47     expTop = 2;
48     expWidth = 3;
49     expHeight = 4;
50     EXPECT_EQ(IME_ERR_OK, OH_CursorInfo_SetRect(cursorInfo, expLeft, expTop, expWidth, expHeight));
51     EXPECT_EQ(IME_ERR_OK, OH_CursorInfo_GetRect(cursorInfo, &actLeft, &actTop, &actWidth, &actHeight));
52     EXPECT_EQ(expLeft, actLeft);
53     EXPECT_EQ(expTop, actTop);
54     EXPECT_EQ(expWidth, actWidth);
55     EXPECT_EQ(expHeight, actHeight);
56 
57     OH_CursorInfo_Destroy(cursorInfo);
58 }
59 
TestCursorInfoOfTextConfig(InputMethod_TextConfig * config)60 static void TestCursorInfoOfTextConfig(InputMethod_TextConfig *config)
61 {
62     InputMethod_CursorInfo *cursorInfo = nullptr;
63     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetCursorInfo(config, &cursorInfo));
64     // test set and get cursorInfo rect
65     double expLeft = 1.1;
66     double expTop = 2.2;
67     double expWidth = 3.3;
68     double expHeight = 4.4;
69     EXPECT_EQ(IME_ERR_OK, OH_CursorInfo_SetRect(cursorInfo, expLeft, expTop, expWidth, expHeight));
70     double actLeft = 0.0;
71     double actTop = 0.0;
72     double actWidth = 0.0;
73     double actHeight = 0.0;
74     EXPECT_EQ(IME_ERR_OK, OH_CursorInfo_GetRect(cursorInfo, &actLeft, &actTop, &actWidth, &actHeight));
75     EXPECT_EQ(expLeft, actLeft);
76     EXPECT_EQ(expTop, actTop);
77     EXPECT_EQ(expWidth, actWidth);
78     EXPECT_EQ(expHeight, actHeight);
79 }
80 
81 /**
82  * @tc.name: TestTextConfig_001
83  * @tc.desc: create and destroy TestTextConfig success
84  * @tc.type: FUNC
85  */
86 HWTEST_F(InputMethodControllerCapiTest, TestTextConfig_001, TestSize.Level0)
87 {
88     auto config = OH_TextConfig_Create();
89     ASSERT_NE(nullptr, config);
90 
91     // test set and get inputType
92     InputMethod_TextInputType expInputType = IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL;
93     InputMethod_TextInputType actInputType = IME_TEXT_INPUT_TYPE_NONE;
94     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetInputType(config, expInputType));
95     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetInputType(config, &actInputType));
96     EXPECT_EQ(expInputType, actInputType);
97 
98     // test set and get enterKeyType
99     InputMethod_EnterKeyType expEnterKeyType = IME_ENTER_KEY_SEARCH;
100     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetEnterKeyType(config, expEnterKeyType));
101     InputMethod_EnterKeyType actEnterKeyType = IME_ENTER_KEY_UNSPECIFIED;
102     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetEnterKeyType(config, &actEnterKeyType));
103     EXPECT_EQ(expEnterKeyType, actEnterKeyType);
104 
105     // test set and get isPreviewTextSupported
106     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetPreviewTextSupport(config, true));
107     bool isPreviewTextSupported = false;
108     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_IsPreviewTextSupported(config, &isPreviewTextSupported));
109     EXPECT_TRUE(isPreviewTextSupported);
110 
111     // test set and get selection
112     int32_t expStart = 1;
113     int32_t expEnd = 2;
114     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetSelection(config, expStart, expEnd));
115     int32_t actStart = 0;
116     int32_t actEnd = 0;
117     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetSelection(config, &actStart, &actEnd));
118     EXPECT_EQ(expStart, actStart);
119     EXPECT_EQ(expEnd, actEnd);
120 
121     // test set and get windowId
122     int32_t expWindowId = 1;
123     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_SetWindowId(config, expWindowId));
124     int32_t actWindowId = 0;
125     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetWindowId(config, &actWindowId));
126     EXPECT_EQ(expWindowId, actWindowId);
127 
128     TestCursorInfoOfTextConfig(config);
129 
130     InputMethod_TextAvoidInfo *textAvoidInfo = nullptr;
131     EXPECT_EQ(IME_ERR_OK, OH_TextConfig_GetTextAvoidInfo(config, &textAvoidInfo));
132 
133     // test set and get text avoid info member
134     double expPositionY = 10.0;
135     double expHeight = 20.0;
136     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_SetPositionY(textAvoidInfo, expPositionY));
137     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_SetHeight(textAvoidInfo, expHeight));
138     double actPositionY = 0.0;
139     double actHeight = 0.0;
140     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetPositionY(textAvoidInfo, &actPositionY));
141     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetHeight(textAvoidInfo, &actHeight));
142     EXPECT_EQ(expPositionY, actPositionY);
143     EXPECT_EQ(expHeight, actHeight);
144 
145     OH_TextConfig_Destroy(config);
146 }
GetTextConfigFunc(InputMethod_TextEditorProxy * proxy,InputMethod_TextConfig * config)147 void GetTextConfigFunc(InputMethod_TextEditorProxy *proxy, InputMethod_TextConfig *config) { }
InsertTextFunc(InputMethod_TextEditorProxy * proxy,const char16_t * text,size_t length)148 void InsertTextFunc(InputMethod_TextEditorProxy *proxy, const char16_t *text, size_t length) { }
DeleteForwardFunc(InputMethod_TextEditorProxy * proxy,int32_t length)149 void DeleteForwardFunc(InputMethod_TextEditorProxy *proxy, int32_t length) { }
DeleteBackwardFunc(InputMethod_TextEditorProxy * proxy,int32_t length)150 void DeleteBackwardFunc(InputMethod_TextEditorProxy *proxy, int32_t length) { }
SendKeyboardStatusFunc(InputMethod_TextEditorProxy * proxy,InputMethod_KeyboardStatus status)151 void SendKeyboardStatusFunc(InputMethod_TextEditorProxy *proxy, InputMethod_KeyboardStatus status) { }
SendEnterKeyFunc(InputMethod_TextEditorProxy * proxy,InputMethod_EnterKeyType type)152 void SendEnterKeyFunc(InputMethod_TextEditorProxy *proxy, InputMethod_EnterKeyType type) { }
MoveCursorFunc(InputMethod_TextEditorProxy * proxy,InputMethod_Direction direction)153 void MoveCursorFunc(InputMethod_TextEditorProxy *proxy, InputMethod_Direction direction) { }
HandleSetSelectionFunc(InputMethod_TextEditorProxy * proxy,int32_t start,int32_t end)154 void HandleSetSelectionFunc(InputMethod_TextEditorProxy *proxy, int32_t start, int32_t end) { }
HandleExtendActionFunc(InputMethod_TextEditorProxy * proxy,InputMethod_ExtendAction action)155 void HandleExtendActionFunc(InputMethod_TextEditorProxy *proxy, InputMethod_ExtendAction action) { }
GetleftTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,int32_t number,char16_t text[],size_t * length)156 void GetleftTextOfCursorFunc(InputMethod_TextEditorProxy *proxy, int32_t number, char16_t text[], size_t *length) { }
GetRightTextOfCursorFunc(InputMethod_TextEditorProxy * proxy,int32_t number,char16_t text[],size_t * length)157 void GetRightTextOfCursorFunc(InputMethod_TextEditorProxy *proxy, int32_t number, char16_t text[], size_t *length) { }
GetTextIndexAtCursorFunc(InputMethod_TextEditorProxy * proxy)158 int32_t GetTextIndexAtCursorFunc(InputMethod_TextEditorProxy *proxy)
159 {
160     return 0;
161 }
ReceivePrivateCommandFunc(InputMethod_TextEditorProxy * proxy,InputMethod_PrivateCommand * privateCommand[],size_t size)162 int32_t ReceivePrivateCommandFunc(
163     InputMethod_TextEditorProxy *proxy, InputMethod_PrivateCommand *privateCommand[], size_t size)
164 {
165     return 0;
166 }
SetPreviewTextFunc(InputMethod_TextEditorProxy * proxy,const char16_t * text,size_t length,int32_t start,int32_t end)167 int32_t SetPreviewTextFunc(
168     InputMethod_TextEditorProxy *proxy, const char16_t *text, size_t length, int32_t start, int32_t end)
169 {
170     return 0;
171 }
FinishTextPreviewFunc(InputMethod_TextEditorProxy * proxy)172 void FinishTextPreviewFunc(InputMethod_TextEditorProxy *proxy) { }
ConstructTextEditorProxy(InputMethod_TextEditorProxy * textEditorProxy)173 static void ConstructTextEditorProxy(InputMethod_TextEditorProxy *textEditorProxy)
174 {
175     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetTextConfigFunc(textEditorProxy, GetTextConfigFunc));
176     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetInsertTextFunc(textEditorProxy, InsertTextFunc));
177     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetDeleteForwardFunc(textEditorProxy, DeleteForwardFunc));
178     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetDeleteBackwardFunc(textEditorProxy, DeleteBackwardFunc));
179     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSendKeyboardStatusFunc(textEditorProxy, SendKeyboardStatusFunc));
180     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSendEnterKeyFunc(textEditorProxy, SendEnterKeyFunc));
181     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetMoveCursorFunc(textEditorProxy, MoveCursorFunc));
182     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetHandleSetSelectionFunc(textEditorProxy, HandleSetSelectionFunc));
183     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetHandleExtendActionFunc(textEditorProxy, HandleExtendActionFunc));
184     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(textEditorProxy, GetleftTextOfCursorFunc));
185     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetRightTextOfCursorFunc(textEditorProxy, GetRightTextOfCursorFunc));
186     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(textEditorProxy, GetTextIndexAtCursorFunc));
187     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetReceivePrivateCommandFunc(textEditorProxy, ReceivePrivateCommandFunc));
188     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSetPreviewTextFunc(textEditorProxy, SetPreviewTextFunc));
189     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetFinishTextPreviewFunc(textEditorProxy, FinishTextPreviewFunc));
190 }
191 
TestGetTextEditorProxyMember(InputMethod_TextEditorProxy * textEditorProxy)192 static void TestGetTextEditorProxyMember(InputMethod_TextEditorProxy *textEditorProxy)
193 {
194     OH_TextEditorProxy_GetTextConfigFunc getTextCOnfigFunc = nullptr;
195     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetGetTextConfigFunc(textEditorProxy, &getTextCOnfigFunc));
196     EXPECT_EQ(GetTextConfigFunc, getTextCOnfigFunc);
197 
198     OH_TextEditorProxy_InsertTextFunc insertTextFunc = nullptr;
199     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetInsertTextFunc(textEditorProxy, &insertTextFunc));
200     EXPECT_EQ(InsertTextFunc, insertTextFunc);
201 
202     OH_TextEditorProxy_DeleteForwardFunc deleteForwardFunc = nullptr;
203     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetDeleteForwardFunc(textEditorProxy, &deleteForwardFunc));
204     EXPECT_EQ(DeleteForwardFunc, deleteForwardFunc);
205 
206     OH_TextEditorProxy_DeleteBackwardFunc deleteBackwardFunc = nullptr;
207     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetDeleteBackwardFunc(textEditorProxy, &deleteBackwardFunc));
208     EXPECT_EQ(DeleteBackwardFunc, deleteBackwardFunc);
209 
210     OH_TextEditorProxy_SendKeyboardStatusFunc sendKeyboardStatusFunc = nullptr;
211     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetSendKeyboardStatusFunc(textEditorProxy, &sendKeyboardStatusFunc));
212     EXPECT_EQ(SendKeyboardStatusFunc, sendKeyboardStatusFunc);
213 
214     OH_TextEditorProxy_SendEnterKeyFunc sendEnterKeyFunc = nullptr;
215     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetSendEnterKeyFunc(textEditorProxy, &sendEnterKeyFunc));
216     EXPECT_EQ(SendEnterKeyFunc, sendEnterKeyFunc);
217 
218     OH_TextEditorProxy_MoveCursorFunc moveCursorFunc = nullptr;
219     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetMoveCursorFunc(textEditorProxy, &moveCursorFunc));
220     EXPECT_EQ(MoveCursorFunc, moveCursorFunc);
221 
222     OH_TextEditorProxy_HandleSetSelectionFunc handleSetSelectionFunc = nullptr;
223     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetHandleSetSelectionFunc(textEditorProxy, &handleSetSelectionFunc));
224     EXPECT_EQ(HandleSetSelectionFunc, handleSetSelectionFunc);
225 
226     OH_TextEditorProxy_HandleExtendActionFunc handleExtendActionFunc = nullptr;
227     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetHandleExtendActionFunc(textEditorProxy, &handleExtendActionFunc));
228     EXPECT_EQ(HandleExtendActionFunc, handleExtendActionFunc);
229 
230     OH_TextEditorProxy_GetLeftTextOfCursorFunc getLeftTextOfCursorFunc = nullptr;
231     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(textEditorProxy, &getLeftTextOfCursorFunc));
232     EXPECT_EQ(GetleftTextOfCursorFunc, getLeftTextOfCursorFunc);
233 
234     OH_TextEditorProxy_GetRightTextOfCursorFunc getRightTextOfCursorFunc = nullptr;
235     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetGetRightTextOfCursorFunc(textEditorProxy, &getRightTextOfCursorFunc));
236     EXPECT_EQ(GetRightTextOfCursorFunc, getRightTextOfCursorFunc);
237 
238     OH_TextEditorProxy_GetTextIndexAtCursorFunc getTextIndexAtCursorFunc = nullptr;
239     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(textEditorProxy, &getTextIndexAtCursorFunc));
240     EXPECT_EQ(GetTextIndexAtCursorFunc, getTextIndexAtCursorFunc);
241 
242     OH_TextEditorProxy_ReceivePrivateCommandFunc receivePrivateCommandFunc = nullptr;
243     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetReceivePrivateCommandFunc(textEditorProxy, &receivePrivateCommandFunc));
244     EXPECT_EQ(ReceivePrivateCommandFunc, receivePrivateCommandFunc);
245 
246     OH_TextEditorProxy_SetPreviewTextFunc setPreviewTextFunc = nullptr;
247     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetSetPreviewTextFunc(textEditorProxy, &setPreviewTextFunc));
248     EXPECT_EQ(SetPreviewTextFunc, setPreviewTextFunc);
249 
250     OH_TextEditorProxy_FinishTextPreviewFunc finishTextPreviewFunc = nullptr;
251     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_GetFinishTextPreviewFunc(textEditorProxy, &finishTextPreviewFunc));
252     EXPECT_EQ(FinishTextPreviewFunc, finishTextPreviewFunc);
253 }
254 
255 /**
256  * @tc.name: TextEditorProxy_001
257  * @tc.desc: create and destroy TextEditorProxy success
258  * @tc.type: FUNC
259  */
260 HWTEST_F(InputMethodControllerCapiTest, TextEditorProxy_001, TestSize.Level0)
261 {
262     auto textEditorProxy = OH_TextEditorProxy_Create();
263     ASSERT_NE(nullptr, textEditorProxy);
264     ConstructTextEditorProxy(textEditorProxy);
265     TestGetTextEditorProxyMember(textEditorProxy);
266     OH_TextEditorProxy_Destroy(textEditorProxy);
267 }
268 
269 /**
270  * @tc.name: AttachOptions_001
271  * @tc.desc: create and destroy AttachOptions success
272  * @tc.type: FUNC
273  */
274 HWTEST_F(InputMethodControllerCapiTest, AttachOptions_001, TestSize.Level0)
275 {
276     auto options = OH_AttachOptions_Create(true);
277     ASSERT_NE(nullptr, options);
278 
279     bool showKeyboard = false;
280     EXPECT_EQ(IME_ERR_OK, OH_AttachOptions_IsShowKeyboard(options, &showKeyboard));
281     EXPECT_TRUE(showKeyboard);
282     OH_AttachOptions_Destroy(options);
283 }
284 
285 /**
286  * @tc.name: TextAvoidInfo_001
287  * @tc.desc: create and destroy TextAvoidInfo success
288  * @tc.type: FUNC
289  */
290 HWTEST_F(InputMethodControllerCapiTest, TextAvoidInfo_001, TestSize.Level0)
291 {
292     double expPositionY = 1.1;
293     double expHeight = 1.2;
294     auto avoidInfo = OH_TextAvoidInfo_Create(expPositionY, expHeight);
295     ASSERT_NE(nullptr, avoidInfo);
296 
297     double actPositionY = 0.0;
298     double actHeight = 0.0;
299     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetPositionY(avoidInfo, &actPositionY));
300     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetHeight(avoidInfo, &actHeight));
301     EXPECT_EQ(expPositionY, actPositionY);
302     EXPECT_EQ(expHeight, actHeight);
303 
304     // test set positionY and height
305     expPositionY = 2.1;
306     expHeight = 2.2;
307     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_SetPositionY(avoidInfo, expPositionY));
308     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_SetHeight(avoidInfo, expHeight));
309     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetPositionY(avoidInfo, &actPositionY));
310     EXPECT_EQ(IME_ERR_OK, OH_TextAvoidInfo_GetHeight(avoidInfo, &actHeight));
311     EXPECT_EQ(expPositionY, actPositionY);
312     EXPECT_EQ(expHeight, actHeight);
313 
314     OH_TextAvoidInfo_Destroy(avoidInfo);
315 }
316 
317 /**
318  * @tc.name: PrivateCommand_001
319  * @tc.desc: create and destroy PrivateCommand success
320  * @tc.type: FUNC
321  */
322 HWTEST_F(InputMethodControllerCapiTest, PrivateCommand_001, TestSize.Level0)
323 {
324     std::string key = "key";
325     auto privateCommand = OH_PrivateCommand_Create(const_cast<char *>(key.c_str()), key.length());
326     ASSERT_NE(nullptr, privateCommand);
327 
328     // test set bool value
329     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_SetBoolValue(privateCommand, true));
330     bool actBoolValue = false;
331     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetBoolValue(privateCommand, &actBoolValue));
332     EXPECT_TRUE(actBoolValue);
333 
334     // test set int value
335     int32_t expIntValue = 1;
336     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_SetIntValue(privateCommand, expIntValue));
337     int32_t actIntValue = 0;
338     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetIntValue(privateCommand, &actIntValue));
339     EXPECT_EQ(expIntValue, actIntValue);
340 
341     // test set string value
342     std::string expStrValue = "string";
343     EXPECT_EQ(IME_ERR_OK,
344         OH_PrivateCommand_SetStrValue(privateCommand, const_cast<char *>(expStrValue.c_str()), expStrValue.length()));
345     const char *actStrValue = nullptr;
346     size_t actStrValueLength = 0;
347     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetStrValue(privateCommand, &actStrValue, &actStrValueLength));
348     EXPECT_EQ(expStrValue, std::string(actStrValue, actStrValueLength));
349 
350     // test get value type
351     InputMethod_CommandValueType valueType = IME_COMMAND_VALUE_TYPE_NONE;
352     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetValueType(privateCommand, &valueType));
353     EXPECT_EQ(IME_COMMAND_VALUE_TYPE_STRING, valueType);
354 
355     // test get and set key
356     const char *actStrKey = nullptr;
357     size_t actStrKeyLength = 0;
358     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetKey(privateCommand, &actStrKey, &actStrKeyLength));
359     EXPECT_EQ(key, std::string(actStrKey, actStrKeyLength));
360     std::string newKey = "newKey";
361     EXPECT_EQ(
362         IME_ERR_OK, OH_PrivateCommand_SetKey(privateCommand, const_cast<char *>(newKey.c_str()), newKey.length()));
363     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_GetKey(privateCommand, &actStrKey, &actStrKeyLength));
364     EXPECT_EQ(newKey, std::string(actStrKey, actStrKeyLength));
365     OH_PrivateCommand_Destroy(privateCommand);
366 }
367 /**
368  * @tc.name: OH_CursorInfo_SetRect_001
369  * @tc.desc: input parameters is nullptr
370  * @tc.type: FUNC
371  */
372 HWTEST_F(InputMethodControllerCapiTest, OH_CursorInfo_SetRect_001, TestSize.Level0)
373 {
374     double left = 0;
375     double top = 0;
376     double width = 0;
377     double height = 0;
378     auto ret = OH_CursorInfo_SetRect(nullptr, left, top, width, height);
379     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
380 }
381 
382 /**
383  * @tc.name: OH_CursorInfo_GetRect_001
384  * @tc.desc: input parameters is nullptr
385  * @tc.type: FUNC
386  */
387 HWTEST_F(InputMethodControllerCapiTest, OH_CursorInfo_GetRect_001, TestSize.Level0)
388 {
389     double left = 0;
390     double top = 0;
391     double width = 0;
392     double height = 0;
393     auto ret = OH_CursorInfo_GetRect(nullptr, nullptr, nullptr, nullptr, nullptr);
394     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
395 
396     auto info = OH_CursorInfo_Create(left, top, width, height);
397     ret = OH_CursorInfo_GetRect(info, nullptr, nullptr, nullptr, nullptr);
398     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
399     ret = OH_CursorInfo_GetRect(info, &left, nullptr, nullptr, nullptr);
400     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
401     ret = OH_CursorInfo_GetRect(info, &left, &top, nullptr, nullptr);
402     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
403     ret = OH_CursorInfo_GetRect(info, &left, &top, &width, nullptr);
404     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
405     OH_CursorInfo_Destroy(info);
406 }
407 
408 /**
409  * @tc.name: OH_TextConfig_SetInputType_001
410  * @tc.desc: input parameters is nullptr
411  * @tc.type: FUNC
412  */
413 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_SetInputType_001, TestSize.Level0)
414 {
415     InputMethod_TextInputType inputType = IME_TEXT_INPUT_TYPE_TEXT;
416     auto ret = OH_TextConfig_SetInputType(nullptr, inputType);
417     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
418 }
419 
420 /**
421  * @tc.name: OH_TextConfig_SetEnterKeyType_001
422  * @tc.desc: input parameters is nullptr
423  * @tc.type: FUNC
424  */
425 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_SetEnterKeyType_001, TestSize.Level0)
426 {
427     InputMethod_EnterKeyType enterKeyType = IME_ENTER_KEY_UNSPECIFIED;
428     auto ret = OH_TextConfig_SetEnterKeyType(nullptr, enterKeyType);
429     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
430 }
431 
432 /**
433  * @tc.name: OH_TextConfig_SetPreviewTextSupport_001
434  * @tc.desc: input parameters is nullptr
435  * @tc.type: FUNC
436  */
437 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_SetPreviewTextSupport_001, TestSize.Level0)
438 {
439     bool supported = false;
440     auto ret = OH_TextConfig_SetPreviewTextSupport(nullptr, supported);
441     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
442 }
443 
444 /**
445  * @tc.name: OH_TextConfig_SetSelection_001
446  * @tc.desc: input parameters is nullptr
447  * @tc.type: FUNC
448  */
449 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_SetSelection_001, TestSize.Level0)
450 {
451     int32_t start = 0;
452     int32_t end = 0;
453     auto ret = OH_TextConfig_SetSelection(nullptr, start, end);
454     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
455 }
456 
457 /**
458  * @tc.name: OH_TextConfig_SetWindowId_001
459  * @tc.desc: input parameters is nullptr
460  * @tc.type: FUNC
461  */
462 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_SetWindowId_001, TestSize.Level0)
463 {
464     int32_t windowId = 0;
465     auto ret = OH_TextConfig_SetWindowId(nullptr, windowId);
466     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
467 }
468 
469 /**
470  * @tc.name: OH_TextConfig_GetInputType_001
471  * @tc.desc: input parameters is nullptr
472  * @tc.type: FUNC
473  */
474 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetInputType_001, TestSize.Level0)
475 {
476     auto ret = OH_TextConfig_GetInputType(nullptr, nullptr);
477     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
478     InputMethod_TextConfig *config = OH_TextConfig_Create();
479     ASSERT_NE(config, nullptr);
480     ret = OH_TextConfig_GetInputType(config, nullptr);
481     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
482     OH_TextConfig_Destroy(config);
483 }
484 
485 /**
486  * @tc.name: OH_TextConfig_GetEnterKeyType_001
487  * @tc.desc: input parameters is nullptr
488  * @tc.type: FUNC
489  */
490 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetEnterKeyType_001, TestSize.Level0)
491 {
492     auto ret = OH_TextConfig_GetEnterKeyType(nullptr, nullptr);
493     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
494     InputMethod_TextConfig *config = OH_TextConfig_Create();
495     ASSERT_NE(config, nullptr);
496     ret = OH_TextConfig_GetEnterKeyType(config, nullptr);
497     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
498     OH_TextConfig_Destroy(config);
499 }
500 
501 /**
502  * @tc.name: OH_TextConfig_IsPreviewTextSupported_001
503  * @tc.desc: input parameters is nullptr
504  * @tc.type: FUNC
505  */
506 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_IsPreviewTextSupported_001, TestSize.Level0)
507 {
508     auto ret = OH_TextConfig_IsPreviewTextSupported(nullptr, nullptr);
509     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
510     InputMethod_TextConfig *config = OH_TextConfig_Create();
511     ASSERT_NE(config, nullptr);
512     ret = OH_TextConfig_IsPreviewTextSupported(config, nullptr);
513     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
514     OH_TextConfig_Destroy(config);
515 }
516 
517 /**
518  * @tc.name: OH_TextConfig_GetCursorInfo_001
519  * @tc.desc: input parameters is nullptr
520  * @tc.type: FUNC
521  */
522 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetCursorInfo_001, TestSize.Level0)
523 {
524     auto ret = OH_TextConfig_GetCursorInfo(nullptr, nullptr);
525     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
526     InputMethod_TextConfig *config = OH_TextConfig_Create();
527     ASSERT_NE(config, nullptr);
528     ret = OH_TextConfig_GetCursorInfo(config, nullptr);
529     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
530     OH_TextConfig_Destroy(config);
531 }
532 
533 /**
534  * @tc.name: OH_TextConfig_GetTextAvoidInfo_001
535  * @tc.desc: input parameters is nullptr
536  * @tc.type: FUNC
537  */
538 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetTextAvoidInfo_001, TestSize.Level0)
539 {
540     auto ret = OH_TextConfig_GetTextAvoidInfo(nullptr, nullptr);
541     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
542     InputMethod_TextConfig *config = OH_TextConfig_Create();
543     ASSERT_NE(config, nullptr);
544     ret = OH_TextConfig_GetTextAvoidInfo(config, nullptr);
545     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
546     OH_TextConfig_Destroy(config);
547 }
548 
549 /**
550  * @tc.name: OH_TextConfig_GetSelection_001
551  * @tc.desc: input parameters is nullptr
552  * @tc.type: FUNC
553  */
554 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetSelection_001, TestSize.Level0)
555 {
556     auto ret = OH_TextConfig_GetSelection(nullptr, nullptr, nullptr);
557     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
558     InputMethod_TextConfig *config = OH_TextConfig_Create();
559     ASSERT_NE(config, nullptr);
560     ret = OH_TextConfig_GetSelection(config, nullptr, nullptr);
561     int32_t start = 0;
562     ret = OH_TextConfig_GetSelection(config, &start, nullptr);
563     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
564     OH_TextConfig_Destroy(config);
565 }
566 
567 /**
568  * @tc.name: OH_TextConfig_GetWindowId_001
569  * @tc.desc: input parameters is nullptr
570  * @tc.type: FUNC
571  */
572 HWTEST_F(InputMethodControllerCapiTest, OH_TextConfig_GetWindowId_001, TestSize.Level0)
573 {
574     auto ret = OH_TextConfig_GetWindowId(nullptr, nullptr);
575     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
576     InputMethod_TextConfig *config = OH_TextConfig_Create();
577     ASSERT_NE(config, nullptr);
578     ret = OH_TextConfig_GetWindowId(config, nullptr);
579     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
580     OH_TextConfig_Destroy(config);
581 }
582 
583 /**
584  * @tc.name: OH_TextEditorProxy_SetGetTextConfigFunc_001
585  * @tc.desc: input parameters is nullptr
586  * @tc.type: FUNC
587  */
588 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetGetTextConfigFunc_001, TestSize.Level0)
589 {
590     auto ret = OH_TextEditorProxy_SetGetTextConfigFunc(nullptr, nullptr);
591     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
592     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
593     ASSERT_NE(proxy, nullptr);
594     ret = OH_TextEditorProxy_SetGetTextConfigFunc(proxy, nullptr);
595     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
596     OH_TextEditorProxy_Destroy(proxy);
597 }
598 
599 /**
600  * @tc.name: OH_TextEditorProxy_SetInsertTextFunc_001
601  * @tc.desc: input parameters is nullptr
602  * @tc.type: FUNC
603  */
604 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetInsertTextFunc_001, TestSize.Level0)
605 {
606     auto ret = OH_TextEditorProxy_SetInsertTextFunc(nullptr, nullptr);
607     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
608     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
609     ASSERT_NE(proxy, nullptr);
610     ret = OH_TextEditorProxy_SetInsertTextFunc(proxy, nullptr);
611     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
612     OH_TextEditorProxy_Destroy(proxy);
613 }
614 
615 /**
616  * @tc.name: OH_TextEditorProxy_SetDeleteForwardFunc_001
617  * @tc.desc: input parameters is nullptr
618  * @tc.type: FUNC
619  */
620 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetDeleteForwardFunc_001, TestSize.Level0)
621 {
622     auto ret = OH_TextEditorProxy_SetDeleteForwardFunc(nullptr, nullptr);
623     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
624     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
625     ASSERT_NE(proxy, nullptr);
626     ret = OH_TextEditorProxy_SetDeleteForwardFunc(proxy, nullptr);
627     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
628     OH_TextEditorProxy_Destroy(proxy);
629 }
630 
631 /**
632  * @tc.name: OH_TextEditorProxy_SetDeleteBackwardFunc_001
633  * @tc.desc: input parameters is nullptr
634  * @tc.type: FUNC
635  */
636 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetDeleteBackwardFunc_001, TestSize.Level0)
637 {
638     auto ret = OH_TextEditorProxy_SetDeleteBackwardFunc(nullptr, nullptr);
639     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
640     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
641     ASSERT_NE(proxy, nullptr);
642     ret = OH_TextEditorProxy_SetDeleteBackwardFunc(proxy, nullptr);
643     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
644     OH_TextEditorProxy_Destroy(proxy);
645 }
646 
647 /**
648  * @tc.name: OH_TextEditorProxy_SetSendKeyboardStatusFunc_001
649  * @tc.desc: input parameters is nullptr
650  * @tc.type: FUNC
651  */
652 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetSendKeyboardStatusFunc_001, TestSize.Level0)
653 {
654     auto ret = OH_TextEditorProxy_SetSendKeyboardStatusFunc(nullptr, nullptr);
655     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
656     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
657     ASSERT_NE(proxy, nullptr);
658     ret = OH_TextEditorProxy_SetSendKeyboardStatusFunc(proxy, nullptr);
659     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
660     OH_TextEditorProxy_Destroy(proxy);
661 }
662 
663 /**
664  * @tc.name: OH_TextEditorProxy_SetSendEnterKeyFunc_001
665  * @tc.desc: input parameters is nullptr
666  * @tc.type: FUNC
667  */
668 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetSendEnterKeyFunc_001, TestSize.Level0)
669 {
670     auto ret = OH_TextEditorProxy_SetSendEnterKeyFunc(nullptr, nullptr);
671     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
672     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
673     ASSERT_NE(proxy, nullptr);
674     ret = OH_TextEditorProxy_SetSendEnterKeyFunc(proxy, nullptr);
675     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
676     OH_TextEditorProxy_Destroy(proxy);
677 }
678 
679 /**
680  * @tc.name: OH_TextEditorProxy_SetMoveCursorFunc_001
681  * @tc.desc: input parameters is nullptr
682  * @tc.type: FUNC
683  */
684 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetMoveCursorFunc_001, TestSize.Level0)
685 {
686     auto ret = OH_TextEditorProxy_SetMoveCursorFunc(nullptr, nullptr);
687     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
688     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
689     ASSERT_NE(proxy, nullptr);
690     ret = OH_TextEditorProxy_SetMoveCursorFunc(proxy, nullptr);
691     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
692     OH_TextEditorProxy_Destroy(proxy);
693 }
694 
695 /**
696  * @tc.name: OH_TextEditorProxy_SetHandleSetSelectionFunc_001
697  * @tc.desc: input parameters is nullptr
698  * @tc.type: FUNC
699  */
700 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetHandleSetSelectionFunc_001, TestSize.Level0)
701 {
702     auto ret = OH_TextEditorProxy_SetHandleSetSelectionFunc(nullptr, nullptr);
703     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
704     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
705     ASSERT_NE(proxy, nullptr);
706     ret = OH_TextEditorProxy_SetHandleSetSelectionFunc(proxy, nullptr);
707     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
708     OH_TextEditorProxy_Destroy(proxy);
709 }
710 
711 /**
712  * @tc.name: OH_TextEditorProxy_SetHandleExtendActionFunc_001
713  * @tc.desc: input parameters is nullptr
714  * @tc.type: FUNC
715  */
716 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetHandleExtendActionFunc_001, TestSize.Level0)
717 {
718     auto ret = OH_TextEditorProxy_SetHandleExtendActionFunc(nullptr, nullptr);
719     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
720     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
721     ASSERT_NE(proxy, nullptr);
722     ret = OH_TextEditorProxy_SetHandleExtendActionFunc(proxy, nullptr);
723     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
724     OH_TextEditorProxy_Destroy(proxy);
725 }
726 
727 /**
728  * @tc.name: OH_TextEditorProxy_SetGetLeftTextOfCursorFunc_001
729  * @tc.desc: input parameters is nullptr
730  * @tc.type: FUNC
731  */
732 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetGetLeftTextOfCursorFunc_001, TestSize.Level0)
733 {
734     auto ret = OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(nullptr, nullptr);
735     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
736     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
737     ASSERT_NE(proxy, nullptr);
738     ret = OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(proxy, nullptr);
739     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
740     OH_TextEditorProxy_Destroy(proxy);
741 }
742 
743 /**
744  * @tc.name: OH_TextEditorProxy_SetGetRightTextOfCursorFunc_001
745  * @tc.desc: input parameters is nullptr
746  * @tc.type: FUNC
747  */
748 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetGetRightTextOfCursorFunc_001, TestSize.Level0)
749 {
750     auto ret = OH_TextEditorProxy_SetGetRightTextOfCursorFunc(nullptr, nullptr);
751     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
752     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
753     ASSERT_NE(proxy, nullptr);
754     ret = OH_TextEditorProxy_SetGetRightTextOfCursorFunc(proxy, nullptr);
755     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
756     OH_TextEditorProxy_Destroy(proxy);
757 }
758 
759 /**
760  * @tc.name: OH_TextEditorProxy_SetGetTextIndexAtCursorFunc_001
761  * @tc.desc: input parameters is nullptr
762  * @tc.type: FUNC
763  */
764 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetGetTextIndexAtCursorFunc_001, TestSize.Level0)
765 {
766     auto ret = OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(nullptr, nullptr);
767     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
768     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
769     ASSERT_NE(proxy, nullptr);
770     ret = OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(proxy, nullptr);
771     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
772     OH_TextEditorProxy_Destroy(proxy);
773 }
774 
775 /**
776  * @tc.name: OH_TextEditorProxy_SetReceivePrivateCommandFunc_001
777  * @tc.desc: input parameters is nullptr
778  * @tc.type: FUNC
779  */
780 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetReceivePrivateCommandFunc_001, TestSize.Level0)
781 {
782     auto ret = OH_TextEditorProxy_SetReceivePrivateCommandFunc(nullptr, nullptr);
783     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
784     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
785     ASSERT_NE(proxy, nullptr);
786     ret = OH_TextEditorProxy_SetReceivePrivateCommandFunc(proxy, nullptr);
787     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
788     OH_TextEditorProxy_Destroy(proxy);
789 }
790 
791 /**
792  * @tc.name: OH_TextEditorProxy_SetSetPreviewTextFunc_001
793  * @tc.desc: input parameters is nullptr
794  * @tc.type: FUNC
795  */
796 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetSetPreviewTextFunc_001, TestSize.Level0)
797 {
798     auto ret = OH_TextEditorProxy_SetSetPreviewTextFunc(nullptr, nullptr);
799     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
800     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
801     ASSERT_NE(proxy, nullptr);
802     ret = OH_TextEditorProxy_SetSetPreviewTextFunc(proxy, nullptr);
803     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
804     OH_TextEditorProxy_Destroy(proxy);
805 }
806 
807 /**
808  * @tc.name: OH_TextEditorProxy_SetFinishTextPreviewFunc_001
809  * @tc.desc: input parameters is nullptr
810  * @tc.type: FUNC
811  */
812 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_SetFinishTextPreviewFunc_001, TestSize.Level0)
813 {
814     auto ret = OH_TextEditorProxy_SetFinishTextPreviewFunc(nullptr, nullptr);
815     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
816     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
817     ASSERT_NE(proxy, nullptr);
818     ret = OH_TextEditorProxy_SetFinishTextPreviewFunc(proxy, nullptr);
819     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
820     OH_TextEditorProxy_Destroy(proxy);
821 }
822 
823 /**
824  * @tc.name: OH_TextEditorProxy_GetGetTextConfigFunc_001
825  * @tc.desc: input parameters is nullptr
826  * @tc.type: FUNC
827  */
828 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetGetTextConfigFunc_001, TestSize.Level0)
829 {
830     auto ret = OH_TextEditorProxy_GetGetTextConfigFunc(nullptr, nullptr);
831     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
832     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
833     ASSERT_NE(proxy, nullptr);
834     ret = OH_TextEditorProxy_GetGetTextConfigFunc(proxy, nullptr);
835     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
836     OH_TextEditorProxy_Destroy(proxy);
837 }
838 
839 /**
840  * @tc.name: OH_TextEditorProxy_GetInsertTextFunc_001
841  * @tc.desc: input parameters is nullptr
842  * @tc.type: FUNC
843  */
844 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetInsertTextFunc_001, TestSize.Level0)
845 {
846     auto ret = OH_TextEditorProxy_GetInsertTextFunc(nullptr, nullptr);
847     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
848     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
849     ASSERT_NE(proxy, nullptr);
850     ret = OH_TextEditorProxy_GetInsertTextFunc(proxy, nullptr);
851     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
852     OH_TextEditorProxy_Destroy(proxy);
853 }
854 
855 /**
856  * @tc.name: OH_TextEditorProxy_GetDeleteForwardFunc_001
857  * @tc.desc: input parameters is nullptr
858  * @tc.type: FUNC
859  */
860 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetDeleteForwardFunc_001, TestSize.Level0)
861 {
862     auto ret = OH_TextEditorProxy_GetDeleteForwardFunc(nullptr, nullptr);
863     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
864     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
865     ASSERT_NE(proxy, nullptr);
866     ret = OH_TextEditorProxy_GetDeleteForwardFunc(proxy, nullptr);
867     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
868     OH_TextEditorProxy_Destroy(proxy);
869 }
870 
871 /**
872  * @tc.name: OH_TextEditorProxy_GetDeleteBackwardFunc_001
873  * @tc.desc: input parameters is nullptr
874  * @tc.type: FUNC
875  */
876 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetDeleteBackwardFunc_001, TestSize.Level0)
877 {
878     auto ret = OH_TextEditorProxy_GetDeleteBackwardFunc(nullptr, nullptr);
879     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
880     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
881     ASSERT_NE(proxy, nullptr);
882     ret = OH_TextEditorProxy_GetDeleteBackwardFunc(proxy, nullptr);
883     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
884     OH_TextEditorProxy_Destroy(proxy);
885 }
886 
887 /**
888  * @tc.name: OH_TextEditorProxy_GetSendKeyboardStatusFunc_001
889  * @tc.desc: input parameters is nullptr
890  * @tc.type: FUNC
891  */
892 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetSendKeyboardStatusFunc_001, TestSize.Level0)
893 {
894     auto ret = OH_TextEditorProxy_GetSendKeyboardStatusFunc(nullptr, nullptr);
895     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
896     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
897     ASSERT_NE(proxy, nullptr);
898     ret = OH_TextEditorProxy_GetSendKeyboardStatusFunc(proxy, nullptr);
899     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
900     OH_TextEditorProxy_Destroy(proxy);
901 }
902 
903 /**
904  * @tc.name: OH_TextEditorProxy_GetSendEnterKeyFunc_001
905  * @tc.desc: input parameters is nullptr
906  * @tc.type: FUNC
907  */
908 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetSendEnterKeyFunc_001, TestSize.Level0)
909 {
910     auto ret = OH_TextEditorProxy_GetSendEnterKeyFunc(nullptr, nullptr);
911     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
912     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
913     ASSERT_NE(proxy, nullptr);
914     ret = OH_TextEditorProxy_GetSendEnterKeyFunc(proxy, nullptr);
915     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
916     OH_TextEditorProxy_Destroy(proxy);
917 }
918 
919 /**
920  * @tc.name: OH_TextEditorProxy_GetMoveCursorFunc_001
921  * @tc.desc: input parameters is nullptr
922  * @tc.type: FUNC
923  */
924 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetMoveCursorFunc_001, TestSize.Level0)
925 {
926     auto ret = OH_TextEditorProxy_GetMoveCursorFunc(nullptr, nullptr);
927     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
928     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
929     ASSERT_NE(proxy, nullptr);
930     ret = OH_TextEditorProxy_GetMoveCursorFunc(proxy, nullptr);
931     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
932     OH_TextEditorProxy_Destroy(proxy);
933 }
934 
935 /**
936  * @tc.name: OH_TextEditorProxy_GetHandleSetSelectionFunc_001
937  * @tc.desc: input parameters is nullptr
938  * @tc.type: FUNC
939  */
940 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetHandleSetSelectionFunc_001, TestSize.Level0)
941 {
942     auto ret = OH_TextEditorProxy_GetHandleSetSelectionFunc(nullptr, nullptr);
943     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
944     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
945     ASSERT_NE(proxy, nullptr);
946     ret = OH_TextEditorProxy_GetHandleSetSelectionFunc(proxy, nullptr);
947     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
948     OH_TextEditorProxy_Destroy(proxy);
949 }
950 
951 /**
952  * @tc.name: OH_TextEditorProxy_GetHandleExtendActionFunc_001
953  * @tc.desc: input parameters is nullptr
954  * @tc.type: FUNC
955  */
956 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetHandleExtendActionFunc_001, TestSize.Level0)
957 {
958     auto ret = OH_TextEditorProxy_GetHandleExtendActionFunc(nullptr, nullptr);
959     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
960     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
961     ASSERT_NE(proxy, nullptr);
962     ret = OH_TextEditorProxy_GetHandleExtendActionFunc(proxy, nullptr);
963     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
964     OH_TextEditorProxy_Destroy(proxy);
965 }
966 
967 /**
968  * @tc.name: OH_TextEditorProxy_GetGetLeftTextOfCursorFunc_001
969  * @tc.desc: input parameters is nullptr
970  * @tc.type: FUNC
971  */
972 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetGetLeftTextOfCursorFunc_001, TestSize.Level0)
973 {
974     auto ret = OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(nullptr, nullptr);
975     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
976     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
977     ASSERT_NE(proxy, nullptr);
978     ret = OH_TextEditorProxy_GetGetLeftTextOfCursorFunc(proxy, nullptr);
979     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
980     OH_TextEditorProxy_Destroy(proxy);
981 }
982 
983 /**
984  * @tc.name: OH_TextEditorProxy_GetGetRightTextOfCursorFunc_001
985  * @tc.desc: input parameters is nullptr
986  * @tc.type: FUNC
987  */
988 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetGetRightTextOfCursorFunc_001, TestSize.Level0)
989 {
990     auto ret = OH_TextEditorProxy_GetGetRightTextOfCursorFunc(nullptr, nullptr);
991     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
992     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
993     ASSERT_NE(proxy, nullptr);
994     ret = OH_TextEditorProxy_GetGetRightTextOfCursorFunc(proxy, nullptr);
995     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
996     OH_TextEditorProxy_Destroy(proxy);
997 }
998 
999 /**
1000  * @tc.name: OH_TextEditorProxy_GetGetTextIndexAtCursorFunc_001
1001  * @tc.desc: input parameters is nullptr
1002  * @tc.type: FUNC
1003  */
1004 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetGetTextIndexAtCursorFunc_001, TestSize.Level0)
1005 {
1006     auto ret = OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(nullptr, nullptr);
1007     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1008     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
1009     ASSERT_NE(proxy, nullptr);
1010     ret = OH_TextEditorProxy_GetGetTextIndexAtCursorFunc(proxy, nullptr);
1011     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1012     OH_TextEditorProxy_Destroy(proxy);
1013 }
1014 
1015 /**
1016  * @tc.name: OH_TextEditorProxy_GetReceivePrivateCommandFunc_001
1017  * @tc.desc: input parameters is nullptr
1018  * @tc.type: FUNC
1019  */
1020 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetReceivePrivateCommandFunc_001, TestSize.Level0)
1021 {
1022     auto ret = OH_TextEditorProxy_GetReceivePrivateCommandFunc(nullptr, nullptr);
1023     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1024     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
1025     ASSERT_NE(proxy, nullptr);
1026     ret = OH_TextEditorProxy_GetReceivePrivateCommandFunc(proxy, nullptr);
1027     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1028     OH_TextEditorProxy_Destroy(proxy);
1029 }
1030 
1031 /**
1032  * @tc.name: OH_TextEditorProxy_GetSetPreviewTextFunc_001
1033  * @tc.desc: input parameters is nullptr
1034  * @tc.type: FUNC
1035  */
1036 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetSetPreviewTextFunc_001, TestSize.Level0)
1037 {
1038     auto ret = OH_TextEditorProxy_GetSetPreviewTextFunc(nullptr, nullptr);
1039     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1040     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
1041     ASSERT_NE(proxy, nullptr);
1042     ret = OH_TextEditorProxy_GetSetPreviewTextFunc(proxy, nullptr);
1043     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1044     OH_TextEditorProxy_Destroy(proxy);
1045 }
1046 
1047 /**
1048  * @tc.name: OH_TextEditorProxy_GetFinishTextPreviewFunc_001
1049  * @tc.desc: input parameters is nullptr
1050  * @tc.type: FUNC
1051  */
1052 HWTEST_F(InputMethodControllerCapiTest, OH_TextEditorProxy_GetFinishTextPreviewFunc_001, TestSize.Level0)
1053 {
1054     auto ret = OH_TextEditorProxy_GetFinishTextPreviewFunc(nullptr, nullptr);
1055     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1056     InputMethod_TextEditorProxy *proxy = OH_TextEditorProxy_Create();
1057     ASSERT_NE(proxy, nullptr);
1058     ret = OH_TextEditorProxy_GetFinishTextPreviewFunc(proxy, nullptr);
1059     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1060     OH_TextEditorProxy_Destroy(proxy);
1061 }
1062 
1063 /**
1064  * @tc.name: OH_AttachOptions_IsShowKeyboard_001
1065  * @tc.desc: input parameters is nullptr
1066  * @tc.type: FUNC
1067  */
1068 HWTEST_F(InputMethodControllerCapiTest, OH_AttachOptions_IsShowKeyboard_001, TestSize.Level0)
1069 {
1070     auto ret = OH_AttachOptions_IsShowKeyboard(nullptr, nullptr);
1071     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1072     InputMethod_AttachOptions *options = OH_AttachOptions_Create(true);
1073     ASSERT_NE(options, nullptr);
1074     ret = OH_AttachOptions_IsShowKeyboard(options, nullptr);
1075     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1076     OH_AttachOptions_Destroy(options);
1077 }
1078 
1079 /**
1080  * @tc.name: OH_TextAvoidInfo_SetPositionY_001
1081  * @tc.desc: input parameters is nullptr
1082  * @tc.type: FUNC
1083  */
1084 HWTEST_F(InputMethodControllerCapiTest, OH_TextAvoidInfo_SetPositionY_001, TestSize.Level0)
1085 {
1086     double positionY = 0.0;
1087     auto ret = OH_TextAvoidInfo_SetPositionY(nullptr, positionY);
1088     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1089 }
1090 
1091 /**
1092  * @tc.name: OH_TextAvoidInfo_SetHeight_001
1093  * @tc.desc: input parameters is nullptr
1094  * @tc.type: FUNC
1095  */
1096 HWTEST_F(InputMethodControllerCapiTest, OH_TextAvoidInfo_SetHeight_001, TestSize.Level0)
1097 {
1098     double positionY = 0.0;
1099     auto ret = OH_TextAvoidInfo_SetHeight(nullptr, positionY);
1100     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1101 }
1102 
1103 /**
1104  * @tc.name: OH_TextAvoidInfo_GetPositionY_001
1105  * @tc.desc: input parameters is nullptr
1106  * @tc.type: FUNC
1107  */
1108 HWTEST_F(InputMethodControllerCapiTest, OH_TextAvoidInfo_GetPositionY_001, TestSize.Level0)
1109 {
1110     double positionY = 0.0;
1111     double height = 0.0;
1112     auto ret = OH_TextAvoidInfo_GetPositionY(nullptr, nullptr);
1113     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1114     InputMethod_TextAvoidInfo *info = OH_TextAvoidInfo_Create(positionY, height);
1115     ASSERT_NE(info, nullptr);
1116     ret = OH_TextAvoidInfo_GetPositionY(info, nullptr);
1117     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1118     OH_TextAvoidInfo_Destroy(info);
1119 }
1120 
1121 /**
1122  * @tc.name: OH_TextAvoidInfo_GetHeight_001
1123  * @tc.desc: input parameters is nullptr
1124  * @tc.type: FUNC
1125  */
1126 HWTEST_F(InputMethodControllerCapiTest, OH_TextAvoidInfo_GetHeight_001, TestSize.Level0)
1127 {
1128     double positionY = 0.0;
1129     double height = 0.0;
1130     auto ret = OH_TextAvoidInfo_GetHeight(nullptr, nullptr);
1131     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1132     InputMethod_TextAvoidInfo *info = OH_TextAvoidInfo_Create(positionY, height);
1133     ASSERT_NE(info, nullptr);
1134     ret = OH_TextAvoidInfo_GetHeight(info, nullptr);
1135     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1136     OH_TextAvoidInfo_Destroy(info);
1137 }
1138 
1139 /**
1140  * @tc.name: OH_PrivateCommand_SetKey_001
1141  * @tc.desc: input parameters is nullptr
1142  * @tc.type: FUNC
1143  */
1144 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_SetKey_001, TestSize.Level0)
1145 {
1146     char key[] = "example key";
1147     size_t keyLength = strlen(key);
1148     auto ret = OH_PrivateCommand_SetKey(nullptr, nullptr, keyLength);
1149     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1150     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1151     ASSERT_NE(command, nullptr);
1152     ret = OH_PrivateCommand_SetKey(command, nullptr, keyLength);
1153     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1154     OH_PrivateCommand_Destroy(command);
1155 }
1156 
1157 /**
1158  * @tc.name: OH_PrivateCommand_SetBoolValue_001
1159  * @tc.desc: input parameters is nullptr
1160  * @tc.type: FUNC
1161  */
1162 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_SetBoolValue_001, TestSize.Level0)
1163 {
1164     bool value = false;
1165     auto ret = OH_PrivateCommand_SetBoolValue(nullptr, value);
1166     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1167 }
1168 
1169 /**
1170  * @tc.name: OH_PrivateCommand_SetIntValue_001
1171  * @tc.desc: input parameters is nullptr
1172  * @tc.type: FUNC
1173  */
1174 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_SetIntValue_001, TestSize.Level0)
1175 {
1176     int32_t value = 0;
1177     auto ret = OH_PrivateCommand_SetIntValue(nullptr, value);
1178     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1179 }
1180 
1181 /**
1182  * @tc.name: OH_PrivateCommand_SetIntValue_001
1183  * @tc.desc: input parameters is nullptr
1184  * @tc.type: FUNC
1185  */
1186 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_SetStrValue_001, TestSize.Level0)
1187 {
1188     char value[] = "example value";
1189     size_t valueLength = strlen(value);
1190     auto ret = OH_PrivateCommand_SetStrValue(nullptr, value, valueLength);
1191     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1192     char key[] = "example key";
1193     size_t keyLength = strlen(key);
1194     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1195     ASSERT_NE(command, nullptr);
1196     ret = OH_PrivateCommand_SetStrValue(command, nullptr, valueLength);
1197     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1198     OH_PrivateCommand_Destroy(command);
1199 }
1200 
1201 /**
1202  * @tc.name: OH_PrivateCommand_GetKey_001
1203  * @tc.desc: input parameters is nullptr
1204  * @tc.type: FUNC
1205  */
1206 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_GetKey_001, TestSize.Level0)
1207 {
1208     char key[] = "example key";
1209     size_t keyLength = strlen(key);
1210     auto ret = OH_PrivateCommand_GetKey(nullptr, nullptr, nullptr);
1211     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1212     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1213     ASSERT_NE(command, nullptr);
1214     ret = OH_PrivateCommand_GetKey(command, nullptr, nullptr);
1215     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1216     const char *actStrKey = nullptr;
1217     ret = OH_PrivateCommand_GetKey(command, &actStrKey, nullptr);
1218     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1219     OH_PrivateCommand_Destroy(command);
1220 }
1221 
1222 /**
1223  * @tc.name: OH_PrivateCommand_GetValueType_001
1224  * @tc.desc: input parameters is nullptr
1225  * @tc.type: FUNC
1226  */
1227 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_GetValueType_001, TestSize.Level0)
1228 {
1229     auto ret = OH_PrivateCommand_GetValueType(nullptr, nullptr);
1230     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1231     char key[] = "example key";
1232     size_t keyLength = strlen(key);
1233     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1234     ret = OH_PrivateCommand_GetValueType(command, nullptr);
1235     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1236     OH_PrivateCommand_Destroy(command);
1237 }
1238 
1239 /**
1240  * @tc.name: OH_PrivateCommand_GetBoolValue_001
1241  * @tc.desc: input parameters is nullptr
1242  * @tc.type: FUNC
1243  */
1244 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_GetBoolValue_001, TestSize.Level0)
1245 {
1246     auto ret = OH_PrivateCommand_GetBoolValue(nullptr, nullptr);
1247     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1248     char key[] = "example key";
1249     size_t keyLength = strlen(key);
1250     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1251     ret = OH_PrivateCommand_GetBoolValue(command, nullptr);
1252     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1253     ret = OH_PrivateCommand_GetBoolValue(command, nullptr);
1254     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1255     int32_t expIntValue = 1;
1256     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_SetIntValue(command, expIntValue));
1257     bool value = false;
1258     ret = OH_PrivateCommand_GetBoolValue(command, &value);
1259     EXPECT_EQ(ret, IME_ERR_QUERY_FAILED);
1260     OH_PrivateCommand_Destroy(command);
1261 }
1262 
1263 /**
1264  * @tc.name: OH_PrivateCommand_GetIntValue_001
1265  * @tc.desc: input parameters is nullptr
1266  * @tc.type: FUNC
1267  */
1268 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_GetIntValue_001, TestSize.Level0)
1269 {
1270     auto ret = OH_PrivateCommand_GetIntValue(nullptr, nullptr);
1271     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1272     char key[] = "example key";
1273     size_t keyLength = strlen(key);
1274     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1275     ret = OH_PrivateCommand_GetIntValue(command, nullptr);
1276     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1277     bool expBoolValue = false;
1278     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_SetBoolValue(command, expBoolValue));
1279     int32_t value = 0;
1280     ret = OH_PrivateCommand_GetIntValue(command, &value);
1281     EXPECT_EQ(ret, IME_ERR_QUERY_FAILED);
1282     OH_PrivateCommand_Destroy(command);
1283 }
1284 
1285 /**
1286  * @tc.name: OH_PrivateCommand_GetStrValue_001
1287  * @tc.desc: input parameters is nullptr
1288  * @tc.type: FUNC
1289  */
1290 HWTEST_F(InputMethodControllerCapiTest, OH_PrivateCommand_GetStrValue_001, TestSize.Level0)
1291 {
1292     const char *value = nullptr;
1293     size_t valueLength = 0;
1294     auto ret = OH_PrivateCommand_GetStrValue(nullptr, &value, &valueLength);
1295     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1296     char key[] = "example key";
1297     size_t keyLength = strlen(key);
1298     InputMethod_PrivateCommand *command = OH_PrivateCommand_Create(key, keyLength);
1299     ret = OH_PrivateCommand_GetStrValue(command, nullptr, &valueLength);
1300     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1301     ret = OH_PrivateCommand_GetStrValue(command, &value, nullptr);
1302     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1303     bool expBoolValue = false;
1304     EXPECT_EQ(IME_ERR_OK, OH_PrivateCommand_SetBoolValue(command, expBoolValue));
1305     ret = OH_PrivateCommand_GetStrValue(command, &value, &valueLength);
1306     EXPECT_EQ(ret, IME_ERR_QUERY_FAILED);
1307     OH_PrivateCommand_Destroy(command);
1308 }
1309 
1310 /**
1311  * @tc.name: OH_InputMethodController_Attach_001
1312  * @tc.desc: input parameters is nullptr
1313  * @tc.type: FUNC
1314  */
1315 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodController_Attach_001, TestSize.Level0)
1316 {
1317     auto ret = OH_InputMethodController_Attach(nullptr, nullptr, nullptr);
1318     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1319     auto textEditorProxy = OH_TextEditorProxy_Create();
1320     ret = OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr);
1321     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1322     ConstructTextEditorProxy(textEditorProxy);
1323     ret = OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr);
1324     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1325     InputMethod_AttachOptions *options = OH_AttachOptions_Create(true);
1326     ret = OH_InputMethodController_Attach(textEditorProxy, options, nullptr);
1327     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1328     OH_AttachOptions_Destroy(options);
1329     OH_TextEditorProxy_Destroy(textEditorProxy);
1330 }
1331 
1332 /**
1333  * @tc.name: OH_InputMethodController_Detach_001
1334  * @tc.desc: input parameters is nullptr
1335  * @tc.type: FUNC
1336  */
1337 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodController_Detach_001, TestSize.Level0)
1338 {
1339     auto ret = OH_InputMethodController_Detach(nullptr);
1340     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1341 }
1342 
1343 /**
1344  * @tc.name: OH_InputMethodProxy_ShowKeyboard_001
1345  * @tc.desc: input parameters is nullptr
1346  * @tc.type: FUNC
1347  */
1348 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_ShowKeyboard_001, TestSize.Level0)
1349 {
1350     auto ret = OH_InputMethodProxy_ShowKeyboard(nullptr);
1351     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1352 }
1353 
1354 /**
1355  * @tc.name: OH_InputMethodProxy_HideKeyboard_001
1356  * @tc.desc: input parameters is nullptr
1357  * @tc.type: FUNC
1358  */
1359 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_HideKeyboard_001, TestSize.Level0)
1360 {
1361     auto ret = OH_InputMethodProxy_HideKeyboard(nullptr);
1362     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1363 }
1364 
1365 /**
1366  * @tc.name: OH_InputMethodProxy_NotifySelectionChange_001
1367  * @tc.desc: input parameters is nullptr
1368  * @tc.type: FUNC
1369  */
1370 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_NotifySelectionChange_001, TestSize.Level0)
1371 {
1372     size_t length = 0;
1373     int start = 0;
1374     int end = 0;
1375     auto ret = OH_InputMethodProxy_NotifySelectionChange(nullptr, nullptr, length, start, end);
1376     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1377 }
1378 
1379 /**
1380  * @tc.name: OH_InputMethodProxy_NotifyConfigurationChange_001
1381  * @tc.desc: input parameters is nullptr
1382  * @tc.type: FUNC
1383  */
1384 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_NotifyConfigurationChange_001, TestSize.Level0)
1385 {
1386     InputMethod_EnterKeyType enterKey = IME_ENTER_KEY_UNSPECIFIED;
1387     InputMethod_TextInputType expInput = IME_TEXT_INPUT_TYPE_NUMBER_DECIMAL;
1388     auto ret = OH_InputMethodProxy_NotifyConfigurationChange(nullptr, enterKey, expInput);
1389     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1390 }
1391 
1392 /**
1393  * @tc.name: OH_InputMethodProxy_NotifyCursorUpdate_001
1394  * @tc.desc: input parameters is nullptr
1395  * @tc.type: FUNC
1396  */
1397 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_NotifyCursorUpdate_001, TestSize.Level0)
1398 {
1399     double left = 0;
1400     double top = 1.0;
1401     double width = 2.0;
1402     double height = 3.0;
1403     InputMethod_CursorInfo *cursorInfo = OH_CursorInfo_Create(left, top, width, height);
1404     auto ret = OH_InputMethodProxy_NotifyCursorUpdate(nullptr, nullptr);
1405     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1406     ret = OH_InputMethodProxy_NotifyCursorUpdate(nullptr, cursorInfo);
1407     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1408 }
1409 
1410 /**
1411  * @tc.name: OH_InputMethodProxy_SendPrivateCommand_001
1412  * @tc.desc: input parameters is nullptr
1413  * @tc.type: FUNC
1414  */
1415 HWTEST_F(InputMethodControllerCapiTest, OH_InputMethodProxy_SendPrivateCommand_001, TestSize.Level0)
1416 {
1417     char key[] = "example key";
1418     size_t keyLength = strlen(key);
1419     char key1[] = "example key";
1420     size_t keyLength1 = strlen(key);
1421     InputMethod_PrivateCommand *privateCommand[] = { OH_PrivateCommand_Create(key, keyLength),
1422         OH_PrivateCommand_Create(key1, keyLength1), nullptr };
1423     size_t size = 3;
1424     auto ret = OH_InputMethodProxy_SendPrivateCommand(nullptr, nullptr, size);
1425     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1426     ret = OH_InputMethodProxy_SendPrivateCommand(nullptr, privateCommand, size);
1427     EXPECT_EQ(ret, IME_ERR_NULL_POINTER);
1428 }
1429 
1430 /**
1431  * @tc.name: TestAttachWithNullParam_001
1432  * @tc.desc: input parameters is nullptr
1433  * @tc.type: FUNC
1434  */
1435 HWTEST_F(InputMethodControllerCapiTest, TestAttachWithNullParam_001, TestSize.Level0)
1436 {
1437     auto ret = OH_InputMethodController_Attach(nullptr, nullptr, nullptr);
1438     EXPECT_EQ(IME_ERR_NULL_POINTER, ret);
1439 
1440     auto textEditorProxy = OH_TextEditorProxy_Create();
1441     EXPECT_NE(nullptr, textEditorProxy);
1442 
1443     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1444 
1445     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetTextConfigFunc(textEditorProxy, GetTextConfigFunc));
1446     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1447 
1448     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetInsertTextFunc(textEditorProxy, InsertTextFunc));
1449     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1450 
1451     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetDeleteForwardFunc(textEditorProxy, DeleteForwardFunc));
1452     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1453 
1454     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetDeleteBackwardFunc(textEditorProxy, DeleteBackwardFunc));
1455     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1456 
1457     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSendKeyboardStatusFunc(textEditorProxy, SendKeyboardStatusFunc));
1458     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1459 
1460     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSendEnterKeyFunc(textEditorProxy, SendEnterKeyFunc));
1461     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1462 
1463     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetMoveCursorFunc(textEditorProxy, MoveCursorFunc));
1464     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1465 
1466     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetHandleSetSelectionFunc(textEditorProxy, HandleSetSelectionFunc));
1467     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1468 
1469     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetHandleExtendActionFunc(textEditorProxy, HandleExtendActionFunc));
1470     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1471 
1472     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetLeftTextOfCursorFunc(textEditorProxy, GetleftTextOfCursorFunc));
1473     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1474 
1475     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetRightTextOfCursorFunc(textEditorProxy, GetRightTextOfCursorFunc));
1476     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1477 
1478     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetGetTextIndexAtCursorFunc(textEditorProxy, GetTextIndexAtCursorFunc));
1479     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1480 
1481     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetReceivePrivateCommandFunc(textEditorProxy, ReceivePrivateCommandFunc));
1482     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1483 
1484     EXPECT_EQ(IME_ERR_OK, OH_TextEditorProxy_SetSetPreviewTextFunc(textEditorProxy, SetPreviewTextFunc));
1485     EXPECT_EQ(IME_ERR_NULL_POINTER, OH_InputMethodController_Attach(textEditorProxy, nullptr, nullptr));
1486 
1487     OH_TextEditorProxy_Destroy(textEditorProxy);
1488 }
1489 
1490 /**
1491  * @tc.name: TestAttachWithNorrmalParam_001
1492  * @tc.desc: input parameters is normal
1493  * @tc.type: FUNC
1494  */
1495 HWTEST_F(InputMethodControllerCapiTest, TestAttachWithNorrmalParam_001, TestSize.Level0)
1496 {
1497     auto textEditorProxy = OH_TextEditorProxy_Create();
1498     EXPECT_NE(nullptr, textEditorProxy);
1499     ConstructTextEditorProxy(textEditorProxy);
1500 
1501     auto options = OH_AttachOptions_Create(true);
1502     EXPECT_NE(nullptr, options);
1503     InputMethod_InputMethodProxy *inputMethodProxy = nullptr;
1504     EXPECT_EQ(IME_ERR_IMCLIENT, OH_InputMethodController_Attach(textEditorProxy, options, &inputMethodProxy));
1505     EXPECT_EQ(IME_ERR_IMCLIENT, OH_InputMethodController_Attach(textEditorProxy, options, &inputMethodProxy));
1506 
1507     auto textEditorProxy2 = OH_TextEditorProxy_Create();
1508     EXPECT_NE(nullptr, textEditorProxy2);
1509     ConstructTextEditorProxy(textEditorProxy2);
1510     EXPECT_EQ(IME_ERR_IMCLIENT, OH_InputMethodController_Attach(textEditorProxy2, options, &inputMethodProxy));
1511     OH_TextEditorProxy_Destroy(textEditorProxy2);
1512 
1513     OH_AttachOptions_Destroy(options);
1514     OH_TextEditorProxy_Destroy(textEditorProxy);
1515 }