• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 #include <securec.h>
19 
20 #include "anco_channel_death_recipient.h"
21 #include "anco_channel_proxy.h"
22 #include "iremote_object.h"
23 #include "message_parcel_mock.h"
24 #include "mmi_log.h"
25 #include "multimodal_input_connect_proxy.h"
26 
27 #undef MMI_LOG_TAG
28 #define MMI_LOG_TAG "MultimodalInputConnectProxyTest"
29 
30 namespace OHOS {
31 namespace MMI {
32 namespace {
33 using namespace testing::ext;
34 using namespace testing;
35 constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
36 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
37 constexpr int32_t MIDDLE_PIXEL_MAP_WIDTH { 400 };
38 constexpr int32_t MIDDLE_PIXEL_MAP_HEIGHT { 400 };
39 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
40 constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
41 constexpr int32_t MAX_PIXEL_MAP_HEIGHT { 600 };
42 constexpr int32_t INT32_BYTE { 4 };
43 
44 class RemoteObjectTest : public IRemoteObject {
45 public:
RemoteObjectTest(std::u16string descriptor)46     explicit RemoteObjectTest(std::u16string descriptor) : IRemoteObject(descriptor) {}
~RemoteObjectTest()47     ~RemoteObjectTest() {}
48 
GetObjectRefCount()49     int32_t GetObjectRefCount() { return 0; }
SendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)50     int SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { return 0; }
AddDeathRecipient(const sptr<DeathRecipient> & recipient)51     bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) { return true; }
RemoveDeathRecipient(const sptr<DeathRecipient> & recipient)52     bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) { return true; }
Dump(int fd,const std::vector<std::u16string> & args)53     int Dump(int fd, const std::vector<std::u16string> &args) { return 0; }
54 };
55 } // namespace
56 
57 class MultimodalInputConnectProxyTest : public testing::Test {
58 public:
59     static void SetUpTestCase(void);
60     static void TearDownTestCase();
61     static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
SetUp()62     void SetUp() {}
TearDown()63     void TearDown() {}
64 
65     static inline std::shared_ptr<MessageParcelMock> messageParcelMock_ = nullptr;
66 };
67 
SetUpTestCase(void)68 void MultimodalInputConnectProxyTest::SetUpTestCase(void)
69 {
70     messageParcelMock_ = std::make_shared<MessageParcelMock>();
71     MessageParcelMock::messageParcel = messageParcelMock_;
72 }
TearDownTestCase()73 void MultimodalInputConnectProxyTest::TearDownTestCase()
74 {
75     MessageParcelMock::messageParcel = nullptr;
76     messageParcelMock_ = nullptr;
77 }
78 
CreatePixelMap(int32_t width,int32_t height)79 std::shared_ptr<Media::PixelMap> MultimodalInputConnectProxyTest::CreatePixelMap(int32_t width, int32_t height)
80 {
81     CALL_DEBUG_ENTER;
82     if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
83         return nullptr;
84     }
85     Media::InitializationOptions opts;
86     opts.size.height = height;
87     opts.size.width = width;
88     opts.pixelFormat = Media::PixelFormat::BGRA_8888;
89     opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
90     opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
91 
92     int32_t colorLen = width * height;
93     uint32_t *pixelColors = new (std::nothrow) uint32_t[colorLen];
94     CHKPP(pixelColors);
95     int32_t colorByteCount = colorLen * INT32_BYTE;
96     errno_t ret = memset_s(pixelColors, colorByteCount, DEFAULT_ICON_COLOR, colorByteCount);
97     if (ret != EOK) {
98         delete[] pixelColors;
99         return nullptr;
100     }
101     std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
102     if (pixelMap == nullptr) {
103         delete[] pixelColors;
104         return nullptr;
105     }
106     delete[] pixelColors;
107     return pixelMap;
108 }
109 
110 class MockPointerEvent : public PointerEvent {
111 public:
112     int32_t eventType;
MockPointerEvent(int32_t eventType)113     explicit MockPointerEvent(int32_t eventType) : PointerEvent(eventType), eventType(eventType) {}
114     MOCK_METHOD(bool, WriteToParcel, (Parcel& data));
115 };
116 
117 class MockIRemoteObject : public IRemoteObject {
118 public:
119     MockIRemoteObject() = default;
120     ~MockIRemoteObject() override = default;
121 };
122 
123 /**
124  * @tc.name: MultimodalInputConnectProxyTest_SubscribeSwitchEvent_001
125  * @tc.desc: Cover if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) branch
126  * @tc.type: FUNC
127  * @tc.require:
128  */
129 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SubscribeSwitchEvent_001, TestSize.Level1)
130 {
131     CALL_TEST_DEBUG;
132     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
133     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
134     MultimodalInputConnectProxy proxy(remote);
135     int32_t subscribeId = 10;
136     int32_t switchType = 1;
137     EXPECT_EQ(proxy.SubscribeSwitchEvent(subscribeId, switchType), ERR_INVALID_VALUE);
138 }
139 
140 /**
141  * @tc.name: MultimodalInputConnectProxyTest_SubscribeSwitchEvent_002
142  * @tc.desc: Cover the else branch of if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor()))
143  * @tc.type: FUNC
144  * @tc.require:
145  */
146 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SubscribeSwitchEvent_002, TestSize.Level1)
147 {
148     CALL_TEST_DEBUG;
149     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
150     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
151     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
152     MultimodalInputConnectProxy proxy(remote);
153     int32_t subscribeId = 10;
154     int32_t switchType = 1;
155     EXPECT_EQ(proxy.SubscribeSwitchEvent(subscribeId, switchType), RET_OK);
156 }
157 
158 /**
159  * @tc.name: MultimodalInputConnectProxyTest_UnsubscribeSwitchEvent_001
160  * @tc.desc: Cover if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) branch
161  * @tc.type: FUNC
162  * @tc.require:
163  */
164 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_UnsubscribeSwitchEvent_001, TestSize.Level1)
165 {
166     CALL_TEST_DEBUG;
167     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
168     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
169     MultimodalInputConnectProxy proxy(remote);
170     int32_t subscribeId = 10;
171     EXPECT_EQ(proxy.UnsubscribeSwitchEvent(subscribeId), ERR_INVALID_VALUE);
172 }
173 
174 /**
175  * @tc.name: MultimodalInputConnectProxyTest_UnsubscribeSwitchEvent_002
176  * @tc.desc: Cover the else branch of if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor()))
177  * @tc.type: FUNC
178  * @tc.require:
179  */
180 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_UnsubscribeSwitchEvent_002, TestSize.Level1)
181 {
182     CALL_TEST_DEBUG;
183     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
184     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
185     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
186     MultimodalInputConnectProxy proxy(remote);
187     int32_t subscribeId = 10;
188     EXPECT_EQ(proxy.UnsubscribeSwitchEvent(subscribeId), RET_OK);
189 }
190 
191 /**
192  * @tc.name: MultimodalInputConnectProxyTest_QuerySwitchStatus_001
193  * @tc.desc: Cover if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) branch
194  * @tc.type: FUNC
195  * @tc.require:
196  */
197 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_QuerySwitchStatus_001, TestSize.Level1)
198 {
199     CALL_TEST_DEBUG;
200     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
201     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
202     MultimodalInputConnectProxy proxy(remote);
203     int32_t switchType = 0;
204     int32_t switchState = 0;
205     EXPECT_EQ(proxy.QuerySwitchStatus(switchType, switchState), ERR_INVALID_VALUE);
206 }
207 
208 /**
209  * @tc.name: MultimodalInputConnectProxyTest_QuerySwitchStatus_002
210  * @tc.desc: Cover the else branch of if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor()))
211  * @tc.type: FUNC
212  * @tc.require:
213  */
214 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_QuerySwitchStatus_002, TestSize.Level1)
215 {
216     CALL_TEST_DEBUG;
217     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
218     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
219     EXPECT_CALL(*messageParcelMock_, ReadInt32(_)).WillRepeatedly(Return(true));
220     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
221     MultimodalInputConnectProxy proxy(remote);
222     int32_t switchType = 0;
223     int32_t switchState = 0;
224     EXPECT_EQ(proxy.QuerySwitchStatus(switchType, switchState), RET_OK);
225 }
226 
227 /**
228  * @tc.name: MultimodalInputConnectProxyTest_SetMouseHotSpot_001
229  * @tc.desc: Cover if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor())) branch
230  * @tc.type: FUNC
231  * @tc.require:
232  */
233 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SetMouseHotSpot_001, TestSize.Level1)
234 {
235     CALL_TEST_DEBUG;
236     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
237     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
238     MultimodalInputConnectProxy proxy(remote);
239     int32_t pid = 1000;
240     int32_t windowId = 50;
241     int32_t hotSpotX = 300;
242     int32_t hotSpotY = 300;
243     EXPECT_EQ(proxy.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY), ERR_INVALID_VALUE);
244 }
245 
246 /**
247  * @tc.name: MultimodalInputConnectProxyTest_SetMouseHotSpot_002
248  * @tc.desc: Cover the else branch of if (!data.WriteInterfaceToken(MultimodalInputConnectProxy::GetDescriptor()))
249  * @tc.type: FUNC
250  * @tc.require:
251  */
252 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SetMouseHotSpot_002, TestSize.Level1)
253 {
254     CALL_TEST_DEBUG;
255     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
256     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
257     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
258     MultimodalInputConnectProxy proxy(remote);
259     int32_t pid = 1000;
260     int32_t windowId = 50;
261     int32_t hotSpotX = 300;
262     int32_t hotSpotY = 300;
263     EXPECT_EQ(proxy.SetMouseHotSpot(pid, windowId, hotSpotX, hotSpotY), RET_OK);
264 }
265 
266 /**
267  * @tc.name: MultimodalInputConnectProxyTest_SyncInputPointEvent_001
268  * @tc.desc: Test the function SyncInputPointEvent
269  * @tc.type: FUNC
270  * @tc.require:
271  */
272 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SyncInputPointEvent_001, TestSize.Level1)
273 {
274     CALL_TEST_DEBUG;
275     sptr<IRemoteObject> remoteObject;
276     OHOS::MMI::AncoChannelProxy ancoChannelProxy(remoteObject);
277     auto pointerEvent = PointerEvent::Create();
278     ASSERT_NE(pointerEvent, nullptr);
279     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
280     int32_t ret = ancoChannelProxy.SyncInputPointEvent(*pointerEvent);
281     EXPECT_EQ(ret, ERR_INVALID_VALUE);
282     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(true));
283     ret = ancoChannelProxy.SyncInputPointEvent(*pointerEvent);
284     EXPECT_EQ(ret, ERR_INVALID_DATA);
285 }
286 
287 /**
288  * @tc.name: MultimodalInputConnectProxyTest_SyncInputPointEvent_002
289  * @tc.desc: Test the function SyncInputPointEvent
290  * @tc.type: FUNC
291  * @tc.require:
292  */
293 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SyncInputPointEvent_002, TestSize.Level1)
294 {
295     CALL_TEST_DEBUG;
296     sptr<IRemoteObject> remoteObject;
297     OHOS::MMI::AncoChannelProxy ancoChannelProxy(remoteObject);
298     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(true));
299     int32_t eventType = 1;
300     auto pointerEvent = std::make_shared<MockPointerEvent>(eventType);
301     EXPECT_CALL(*pointerEvent, WriteToParcel(_)).WillRepeatedly(Return(true));
302     int32_t ret = ancoChannelProxy.SyncInputPointEvent(*pointerEvent);
303     EXPECT_EQ(ret, ERR_INVALID_DATA);
304 }
305 
306 /**
307  * @tc.name: MultimodalInputConnectProxyTest_SyncInputKeyEvent_003
308  * @tc.desc: Test the function SyncInputKeyEvent
309  * @tc.type: FUNC
310  * @tc.require:
311  */
312 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SyncInputKeyEvent_003, TestSize.Level1)
313 {
314     CALL_TEST_DEBUG;
315     sptr<IRemoteObject> remoteObject;
316     OHOS::MMI::AncoChannelProxy ancoChannelProxy(remoteObject);
317     auto keyEvent = KeyEvent::Create();
318     ASSERT_NE(keyEvent, nullptr);
319     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
320     int32_t ret = ancoChannelProxy.SyncInputKeyEvent(*keyEvent);
321     EXPECT_EQ(ret, ERR_INVALID_VALUE);
322     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(true));
323     ret = ancoChannelProxy.SyncInputKeyEvent(*keyEvent);
324     EXPECT_EQ(ret, ERR_INVALID_DATA);
325 }
326 
327 /**
328  * @tc.name: MultimodalInputConnectProxyTest_SyncInputKeyEvent_004
329  * @tc.desc: Test the function SyncInputKeyEvent
330  * @tc.type: FUNC
331  * @tc.require:
332  */
333 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SyncInputKeyEvent_004, TestSize.Level1)
334 {
335     CALL_TEST_DEBUG;
336     sptr<IRemoteObject> remoteObject;
337     OHOS::MMI::AncoChannelProxy ancoChannelProxy(remoteObject);
338     std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
339     ASSERT_NE(keyEvent, nullptr);
340     keyEvent->SetKeyCode(KeyEvent::KEYCODE_HOME);
341     keyEvent->SetActionTime(100);
342     keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
343     keyEvent->ActionToString(KeyEvent::KEY_ACTION_DOWN);
344     keyEvent->KeyCodeToString(KeyEvent::KEYCODE_HOME);
345     KeyEvent::KeyItem item;
346     item.SetKeyCode(KeyEvent::KEYCODE_HOME);
347     item.SetDownTime(100);
348     item.SetPressed(true);
349     keyEvent->AddKeyItem(item);
350     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(true));
351     int32_t ret = ancoChannelProxy.SyncInputKeyEvent(*keyEvent);
352     EXPECT_EQ(ret, ERR_INVALID_DATA);
353 }
354 
355 /**
356  * @tc.name: MultimodalInputConnectProxyTest_UpdateWindowInfo_001
357  * @tc.desc: Test the function UpdateWindowInfo
358  * @tc.type: FUNC
359  * @tc.require:
360  */
361 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_UpdateWindowInfo_001, TestSize.Level1)
362 {
363     CALL_TEST_DEBUG;
364     sptr<IRemoteObject> remoteObject;
365     OHOS::MMI::AncoChannelProxy ancoChannelProxy(remoteObject);
366     auto windows = std::make_shared<AncoWindows>();
367     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
368     int32_t ret = ancoChannelProxy.UpdateWindowInfo(*windows);
369     EXPECT_EQ(ret, ERR_INVALID_VALUE);
370     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(true));
371     ret = ancoChannelProxy.UpdateWindowInfo(*windows);
372     EXPECT_EQ(ret, ERR_INVALID_DATA);
373 }
374 
375 /**
376  * @tc.name: MultimodalInputConnectProxyTest_OnRemoteDied_001
377  * @tc.desc: Test the function OnRemoteDied
378  * @tc.type: FUNC
379  * @tc.require:
380  */
381 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_OnRemoteDied_001, TestSize.Level1)
382 {
383     CALL_TEST_DEBUG;
384     bool callbackCalled = false;
__anon7d5ae1860202(const wptr<IRemoteObject>& object) 385     auto deathCallback = [&callbackCalled](const wptr<IRemoteObject>& object) {
386         callbackCalled = true;
387     };
388     OHOS::MMI::AncoChannelDeathRecipient recipient(deathCallback);
389     OHOS::sptr<OHOS::IRemoteObject> object;
390     auto remoteObjectWptr = wptr<OHOS::IRemoteObject>(object);
391     EXPECT_NO_FATAL_FAILURE(recipient.OnRemoteDied(remoteObjectWptr));
392 }
393 
394 /**
395  * @tc.name: MultimodalInputConnectProxyTest_OnRemoteDied_002
396  * @tc.desc: Test the function OnRemoteDied
397  * @tc.type: FUNC
398  * @tc.require:
399  */
400 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_OnRemoteDied_002, TestSize.Level1)
401 {
402     CALL_TEST_DEBUG;
403     OHOS::MMI::AncoChannelDeathRecipient recipient(nullptr);
404     OHOS::sptr<OHOS::IRemoteObject> object;
405     auto remoteObjectWptr = wptr<OHOS::IRemoteObject>(object);
406     EXPECT_NO_FATAL_FAILURE(recipient.OnRemoteDied(remoteObjectWptr));
407 }
408 
409 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
410 /**
411  * @tc.name: MultimodalInputConnectProxyTest_GetPointerSnapshot
412  * @tc.desc: Test the function GetPointerSnapshot
413  * @tc.type: FUNC
414  * @tc.require:
415  */
416 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_GetPointerSnapshot, TestSize.Level1)
417 {
418     CALL_TEST_DEBUG;
419     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
420     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
421     MultimodalInputConnectProxy proxy(remote);
422     std::shared_ptr<Media::PixelMap> pixelMapPtr = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
423     EXPECT_EQ(proxy.GetPointerSnapshot((void *)pixelMapPtr.get()), ERR_INVALID_VALUE);
424 }
425 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
426 
427 /**
428  * @tc.name: MultimodalInputConnectProxyTest_SetInputDeviceConsumer
429  * @tc.desc: Test the function SetInputDeviceConsumer
430  * @tc.type: FUNC
431  * @tc.require:
432  */
433 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SetInputDeviceConsumer, TestSize.Level1)
434 {
435     CALL_TEST_DEBUG;
436     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
437     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
438     MultimodalInputConnectProxy proxy(remote);
439     std::vector<std::string> deviceNames;
440     deviceNames.push_back("test1");
441     deviceNames.push_back("test2");
442     auto ret = proxy.SetInputDeviceConsumer(deviceNames);
443     EXPECT_NE(ret, RET_OK);
444 }
445 
446 /**
447  * @tc.name: MultimodalInputConnectProxyTest_ClearInputDeviceConsumer
448  * @tc.desc: Test the function ClearInputDeviceConsumer
449  * @tc.type: FUNC
450  * @tc.require:
451  */
452 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_ClearInputDeviceConsumer, TestSize.Level1)
453 {
454     CALL_TEST_DEBUG;
455     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillRepeatedly(Return(false));
456     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
457     MultimodalInputConnectProxy proxy(remote);
458     std::vector<std::string> deviceNames;
459     deviceNames.push_back("test1");
460     deviceNames.push_back("test2");
461     auto ret = proxy.ClearInputDeviceConsumer(deviceNames);
462     EXPECT_NE(ret, RET_OK);
463 }
464 
465 /**
466  * @tc.name: MultimodalInputConnectProxyTest_SubscribeInputActive_001
467  * @tc.desc: SubscribeInputActive
468  * @tc.type: FUNC
469  * @tc.require:
470  */
471 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SubscribeInputActive_001, TestSize.Level1)
472 {
473     CALL_TEST_DEBUG;
474     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
475     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
476     MultimodalInputConnectProxy proxy(remote);
477     int32_t subscribeId = 0;
478     int64_t interval = 500;
479     EXPECT_EQ(proxy.SubscribeInputActive(subscribeId, interval), ERR_INVALID_VALUE);
480 }
481 
482 /**
483  * @tc.name: MultimodalInputConnectProxyTest_SubscribeInputActive_002
484  * @tc.desc: SubscribeInputActive
485  * @tc.type: FUNC
486  * @tc.require:
487  */
488 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_SubscribeInputActive_002, TestSize.Level1)
489 {
490     CALL_TEST_DEBUG;
491     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
492     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
493     EXPECT_CALL(*messageParcelMock_, WriteInt64(_)).WillRepeatedly(Return(true));
494     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
495     MultimodalInputConnectProxy proxy(remote);
496     int32_t subscribeId = 0;
497     int64_t interval = 500;
498     EXPECT_EQ(proxy.SubscribeInputActive(subscribeId, interval), RET_OK);
499 }
500 
501 /**
502  * @tc.name: MultimodalInputConnectProxyTest_UnsubscribeInputActive_001
503  * @tc.desc: UnsubscribeInputActive
504  * @tc.type: FUNC
505  * @tc.require:
506  */
507 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_UnsubscribeInputActive_001, TestSize.Level1)
508 {
509     CALL_TEST_DEBUG;
510     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(false));
511     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
512     MultimodalInputConnectProxy proxy(remote);
513     int32_t subscribeId = 0;
514     EXPECT_EQ(proxy.UnsubscribeInputActive(subscribeId), ERR_INVALID_VALUE);
515 }
516 
517 /**
518  * @tc.name: MultimodalInputConnectProxyTest_UnsubscribeInputActive_002
519  * @tc.desc: UnsubscribeInputActive
520  * @tc.type: FUNC
521  * @tc.require:
522  */
523 HWTEST_F(MultimodalInputConnectProxyTest, MultimodalInputConnectProxyTest_UnsubscribeInputActive_002, TestSize.Level1)
524 {
525     CALL_TEST_DEBUG;
526     EXPECT_CALL(*messageParcelMock_, WriteInterfaceToken(_)).WillOnce(Return(true));
527     EXPECT_CALL(*messageParcelMock_, WriteInt32(_)).WillRepeatedly(Return(true));
528     sptr<RemoteObjectTest> remote = new RemoteObjectTest(u"test");
529     MultimodalInputConnectProxy proxy(remote);
530     int32_t subscribeId = 0;
531     EXPECT_EQ(proxy.UnsubscribeInputActive(subscribeId), RET_OK);
532 }
533 } // namespace MMI
534 } // namespace OHOS