• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 <gtest/gtest.h>
17 #include "accessibility_ut_helper.h"
18 #include "accessible_ability_client_impl.h"
19 #include "accessible_ability_manager_service.h"
20 #include "mock_accessible_ability_channel_proxy.h"
21 #include "mock_accessible_ability_channel_stub.h"
22 #include "mock_accessible_ability_listener.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace Accessibility {
29 namespace {
30     const std::string TEST = "test";
31     constexpr int32_t CHANNEL_ID = 1;
32     constexpr int32_t SEQUENCE = 1;
33     constexpr int32_t INVALID_CHILD_ID = -1;
34     constexpr int INVALID_ID = -1;
35 } // namespace
36 
37 class AccessibleAbilityClientImplTest : public ::testing::Test {
38 public:
AccessibleAbilityClientImplTest()39     AccessibleAbilityClientImplTest()
40     {}
~AccessibleAbilityClientImplTest()41     ~AccessibleAbilityClientImplTest()
42     {}
43 
44     std::shared_ptr<AccessibleAbilityClientImpl> instance_ = nullptr;
45     std::shared_ptr<AccessibleAbilityListener> listener_ = nullptr;
46     sptr<MockAccessibleAbilityChannelStub> stub_ = nullptr;
47     sptr<IAccessibleAbilityChannel> channel_ = nullptr;
48 
SetUpTestCase()49     static void SetUpTestCase()
50     {
51         Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
52         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest Start";
53     }
TearDownTestCase()54     static void TearDownTestCase()
55     {
56         Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
57         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest End";
58     }
SetUp()59     void SetUp()
60     {
61         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest SetUp()";
62         instance_ = std::make_shared<AccessibleAbilityClientImpl>();
63         ASSERT_TRUE(instance_);
64         listener_ = std::make_shared<MockAccessibleAbilityListener>();
65         ASSERT_TRUE(listener_);
66         stub_ = new MockAccessibleAbilityChannelStub();
67         ASSERT_TRUE(stub_);
68         channel_ = iface_cast<IAccessibleAbilityChannel>(stub_);
69         ASSERT_TRUE(channel_);
70     };
TearDown()71     void TearDown()
72     {
73         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest TearDown()";
74         AccessibilityAbilityHelper::GetInstance().SetTestChannelId(INVALID_CHANNEL_ID);
75         AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(INVALID_ID);
76         AccessibilityAbilityHelper::GetInstance().SetTestEventType(INVALID_ID);
77         stub_ = nullptr;
78         channel_ = nullptr;
79         listener_ = nullptr;
80         instance_ = nullptr;
81     }
82 
83     void Connect();
84 };
85 
Connect()86 void AccessibleAbilityClientImplTest::Connect()
87 {
88     EXPECT_EQ(instance_->RegisterAbilityListener(listener_), RET_OK);
89     instance_->Init(channel_, CHANNEL_ID);
90     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
91 }
92 
93 /**
94  * @tc.number: Disconnect_001
95  * @tc.name: Disconnect
96  * @tc.desc: Test function Disconnect
97  */
98 HWTEST_F(AccessibleAbilityClientImplTest, Disconnect_001, TestSize.Level1)
99 {
100     GTEST_LOG_(INFO) << "Disconnect_001 start";
101     Connect();
102     instance_->Disconnect(CHANNEL_ID);
103     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(INVALID_CHANNEL_ID));
104     GTEST_LOG_(INFO) << "Disconnect_001 end";
105 }
106 
107 /**
108  * @tc.number: OnAccessibilityEvent_001
109  * @tc.name: OnAccessibilityEvent
110  * @tc.desc: Test function OnAccessibilityEvent
111  */
112 HWTEST_F(AccessibleAbilityClientImplTest, OnAccessibilityEvent_001, TestSize.Level1)
113 {
114     GTEST_LOG_(INFO) << "OnAccessibilityEvent_001 start";
115     Connect();
116     AccessibilityEventInfo eventInfo {};
117     eventInfo.SetEventType(EventType::TYPE_TOUCH_BEGIN);
118     instance_->OnAccessibilityEvent(eventInfo);
119     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestEventType(),
120         static_cast<int>(EventType::TYPE_TOUCH_BEGIN));
121     GTEST_LOG_(INFO) << "OnAccessibilityEvent_001 end";
122 }
123 
124 /**
125  * @tc.number: OnAccessibilityEvent_002
126  * @tc.name: OnAccessibilityEvent
127  * @tc.desc: Test function OnAccessibilityEvent
128  */
129 HWTEST_F(AccessibleAbilityClientImplTest, OnAccessibilityEvent_002, TestSize.Level1)
130 {
131     GTEST_LOG_(INFO) << "OnAccessibilityEvent_002 start";
132     AccessibilityEventInfo eventInfo;
133     eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT);
134     instance_->OnAccessibilityEvent(eventInfo);
135     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestEventType(), static_cast<int>(TYPE_GESTURE_EVENT));
136     GTEST_LOG_(INFO) << "OnAccessibilityEvent_002 end";
137 }
138 
139 /**
140  * @tc.number: GetFocus_001
141  * @tc.name: GetFocus
142  * @tc.desc: Test function GetFocus
143  */
144 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_001, TestSize.Level1)
145 {
146     GTEST_LOG_(INFO) << "GetFocus_001 start";
147     Connect();
148     AccessibilityElementInfo info {};
149     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
150     GTEST_LOG_(INFO) << "GetFocus_001 end";
151 }
152 
153 /**
154  * @tc.number: GetFocus_002
155  * @tc.name: GetFocus
156  * @tc.desc: Test function GetFocus
157  */
158 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_002, TestSize.Level1)
159 {
160     GTEST_LOG_(INFO) << "GetFocus_002 start";
161     AccessibilityElementInfo info {};
162     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INVALID, info), RET_ERR_INVALID_PARAM);
163     GTEST_LOG_(INFO) << "GetFocus_002 end";
164 }
165 
166 /**
167  * @tc.number: GetFocus_003
168  * @tc.name: GetFocus
169  * @tc.desc: Test function GetFocus
170  */
171 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_003, TestSize.Level1)
172 {
173     GTEST_LOG_(INFO) << "GetFocus_003 start";
174     AccessibilityElementInfo info {};
175     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_NO_CONNECTION);
176     GTEST_LOG_(INFO) << "GetFocus_003 end";
177 }
178 
179 /**
180  * @tc.number: GetRemoteObject_001
181  * @tc.name: GetRemoteObject
182  * @tc.desc: Test function GetRemoteObject
183  */
184 HWTEST_F(AccessibleAbilityClientImplTest, GetRemoteObject_001, TestSize.Level1)
185 {
186     GTEST_LOG_(INFO) << "GetRemoteObject_001 start";
187     EXPECT_TRUE(AccessibleAbilityClient::GetInstance()->GetRemoteObject());
188     GTEST_LOG_(INFO) << "GetRemoteObject_001 end";
189 }
190 
191 /**
192  * @tc.number: RegisterAbilityListener_001
193  * @tc.name: RegisterAbilityListener
194  * @tc.desc: Test function RegisterAbilityListener
195  */
196 HWTEST_F(AccessibleAbilityClientImplTest, RegisterAbilityListener_001, TestSize.Level1)
197 {
198     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 start";
199     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
200     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
201     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_REGISTER_EXIST);
202     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 end";
203 }
204 
205 /**
206  * @tc.number: Init_001
207  * @tc.name: Init
208  * @tc.desc: Test function Init
209  */
210 HWTEST_F(AccessibleAbilityClientImplTest, Init_001, TestSize.Level1)
211 {
212     GTEST_LOG_(INFO) << "Init_001 start";
213     sptr<IAccessibleAbilityChannel> channel = nullptr;
214     instance_->Init(channel, CHANNEL_ID);
215     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
216     GTEST_LOG_(INFO) << "Init_001 end";
217 }
218 
219 /**
220  * @tc.number: Init_002
221  * @tc.name: Init
222  * @tc.desc: Test function Init
223  */
224 HWTEST_F(AccessibleAbilityClientImplTest, Init_002, TestSize.Level1)
225 {
226     GTEST_LOG_(INFO) << "Init_002 start";
227     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
228     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
229 
230     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
231     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
232     instance_->Init(channel, CHANNEL_ID);
233     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
234     GTEST_LOG_(INFO) << "Init_002 end";
235 }
236 
237 /**
238  * @tc.number: Init_003
239  * @tc.name: Init
240  * @tc.desc: Test function Init
241  */
242 HWTEST_F(AccessibleAbilityClientImplTest, Init_003, TestSize.Level1)
243 {
244     GTEST_LOG_(INFO) << "Init_003 start";
245     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
246     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
247     instance_->Init(channel, CHANNEL_ID);
248     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
249     GTEST_LOG_(INFO) << "Init_003 end";
250 }
251 
252 /**
253  * @tc.number: GetFocusByElementInfo_001
254  * @tc.name: GetFocusByElementInfo
255  * @tc.desc: Test function GetFocusByElementInfo
256  */
257 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_001, TestSize.Level1)
258 {
259     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 start";
260     Connect();
261     AccessibilityElementInfo sourceInfo {};
262     AccessibilityElementInfo elementInfo {};
263     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_TIME_OUT);
264     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 end";
265 }
266 
267 /**
268  * @tc.number: GetFocusByElementInfo_002
269  * @tc.name: GetFocusByElementInfo
270  * @tc.desc: Test function GetFocusByElementInfo
271  */
272 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_002, TestSize.Level1)
273 {
274     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 start";
275     AccessibilityElementInfo sourceInfo {};
276     AccessibilityElementInfo elementInfo {};
277     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INVALID, elementInfo), RET_ERR_INVALID_PARAM);
278     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 end";
279 }
280 
281 /**
282  * @tc.number: GetFocusByElementInfo_003
283  * @tc.name: GetFocusByElementInfo
284  * @tc.desc: Test function GetFocusByElementInfo
285  */
286 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_003, TestSize.Level1)
287 {
288     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 start";
289     AccessibilityElementInfo sourceInfo {};
290     AccessibilityElementInfo elementInfo {};
291     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_NO_CONNECTION);
292     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 end";
293 }
294 
295 /**
296  * @tc.number: InjectGesture_001
297  * @tc.name: InjectGesture
298  * @tc.desc: Test function InjectGesture
299  */
300 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_001, TestSize.Level1)
301 {
302     GTEST_LOG_(INFO) << "InjectGesture_001 start";
303     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
304     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_INVALID_PARAM);
305     GTEST_LOG_(INFO) << "InjectGesture_001 end";
306 }
307 
308 /**
309  * @tc.number: InjectGesture_002
310  * @tc.name: InjectGesture
311  * @tc.desc: Test function InjectGesture
312  */
313 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_002, TestSize.Level1)
314 {
315     GTEST_LOG_(INFO) << "InjectGesture_002 start";
316     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = nullptr;
317     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_INVALID_PARAM);
318     GTEST_LOG_(INFO) << "InjectGesture_002 end";
319 }
320 
321 /**
322  * @tc.number: InjectGesture_003
323  * @tc.name: InjectGesture
324  * @tc.desc: Test function InjectGesture
325  */
326 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_003, TestSize.Level1)
327 {
328     GTEST_LOG_(INFO) << "InjectGesture_003 start";
329     EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
330     Connect();
331     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
332     AccessibilityGesturePosition position;
333     gesturePath->AddPosition(position);
334     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_OK);
335     GTEST_LOG_(INFO) << "InjectGesture_003 end";
336 }
337 
338 /**
339  * @tc.number: InjectGesture_004
340  * @tc.name: InjectGesture
341  * @tc.desc: Test function InjectGesture
342  */
343 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_004, TestSize.Level1)
344 {
345     GTEST_LOG_(INFO) << "InjectGesture_004 start";
346     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
347     AccessibilityGesturePosition position;
348     gesturePath->AddPosition(position);
349     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
350     GTEST_LOG_(INFO) << "InjectGesture_004 end";
351 }
352 
353 /**
354  * @tc.number: GetRoot_001
355  * @tc.name: GetRoot
356  * @tc.desc: Test function GetRoot
357  */
358 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_001, TestSize.Level1)
359 {
360     GTEST_LOG_(INFO) << "GetRoot_001 start";
361     Connect();
362     AccessibilityElementInfo info {};
363     instance_->SetCacheMode(0);
364     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_TIME_OUT);
365     GTEST_LOG_(INFO) << "GetRoot_001 end";
366 }
367 
368 /**
369  * @tc.number: GetRoot_002
370  * @tc.name: GetRoot
371  * @tc.desc: Test function GetRoot
372  */
373 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_002, TestSize.Level1)
374 {
375     GTEST_LOG_(INFO) << "GetRoot_002 start";
376     AccessibilityElementInfo info {};
377     instance_->SetCacheMode(INVALID_ID);
378     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_NO_CONNECTION);
379     GTEST_LOG_(INFO) << "GetRoot_002 end";
380 }
381 
382 /**
383  * @tc.number: GetRootByWindow_001
384  * @tc.name: GetRootByWindow
385  * @tc.desc: Test function GetRootByWindow
386  */
387 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_001, TestSize.Level1)
388 {
389     GTEST_LOG_(INFO) << "GetRootByWindow_001 start";
390     Connect();
391     AccessibilityElementInfo info {};
392     AccessibilityWindowInfo windowInfo {};
393     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_TIME_OUT);
394 
395     GTEST_LOG_(INFO) << "GetRootByWindow_001 end";
396 }
397 
398 /**
399  * @tc.number: GetRootByWindow_002
400  * @tc.name: GetRootByWindow
401  * @tc.desc: Test function GetRootByWindow
402  */
403 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_002, TestSize.Level1)
404 {
405     GTEST_LOG_(INFO) << "GetRootByWindow_002 start";
406     AccessibilityElementInfo info {};
407     AccessibilityWindowInfo windowInfo {};
408     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_NO_CONNECTION);
409 
410     GTEST_LOG_(INFO) << "GetRootByWindow_002 end";
411 }
412 
413 /**
414  * @tc.number: GetNext_001
415  * @tc.name: GetNext
416  * @tc.desc: Test function GetNext
417  */
418 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_001, TestSize.Level1)
419 {
420     GTEST_LOG_(INFO) << "GetNext_001 start";
421     Connect();
422     AccessibilityElementInfo info {};
423     AccessibilityElementInfo nextElementInfo {};
424     FocusMoveDirection direction = DIRECTION_INVALID;
425     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_INVALID_PARAM);
426     GTEST_LOG_(INFO) << "GetNext_001 end";
427 }
428 
429 /**
430  * @tc.number: GetNext_002
431  * @tc.name: GetNext
432  * @tc.desc: Test function GetNext
433  */
434 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_002, TestSize.Level1)
435 {
436     GTEST_LOG_(INFO) << "GetNext_002 start";
437     AccessibilityElementInfo info {};
438     AccessibilityElementInfo nextElementInfo {};
439     FocusMoveDirection direction = UP;
440     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_NO_CONNECTION);
441     GTEST_LOG_(INFO) << "GetNext_002 end";
442 }
443 
444 /**
445  * @tc.number: GetNext_003
446  * @tc.name: GetNext
447  * @tc.desc: Test function GetNext
448  */
449 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_003, TestSize.Level1)
450 {
451     GTEST_LOG_(INFO) << "GetNext_003 start";
452     Connect();
453     AccessibilityElementInfo info {};
454     AccessibilityElementInfo nextElementInfo {};
455     FocusMoveDirection direction = DOWN;
456     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_TIME_OUT);
457     GTEST_LOG_(INFO) << "GetNext_003 end";
458 }
459 
460 /**
461  * @tc.number: GetByContent_001
462  * @tc.name: GetByContent
463  * @tc.desc: Test function GetByContent
464  */
465 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_001, TestSize.Level1)
466 {
467     GTEST_LOG_(INFO) << "GetByContent_001 start";
468     Connect();
469     AccessibilityElementInfo elementInfo {};
470     std::vector<AccessibilityElementInfo> inelementInfosfos;
471     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_TIME_OUT);
472     GTEST_LOG_(INFO) << "GetByContent_001 end";
473 }
474 
475 /**
476  * @tc.number: GetByContent_002
477  * @tc.name: GetByContent
478  * @tc.desc: Test function GetByContent
479  */
480 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_002, TestSize.Level1)
481 {
482     GTEST_LOG_(INFO) << "GetByContent_002 start";
483     AccessibilityElementInfo elementInfo {};
484     std::vector<AccessibilityElementInfo> inelementInfosfos;
485     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_NO_CONNECTION);
486     GTEST_LOG_(INFO) << "GetByContent_002 end";
487 }
488 
489 /**
490  * @tc.number: GetSource_001
491  * @tc.name: GetSource
492  * @tc.desc: Test function GetSource
493  */
494 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_001, TestSize.Level1)
495 {
496     GTEST_LOG_(INFO) << "GetSource_001 start";
497     Connect();
498     AccessibilityEventInfo eventInfo {};
499     AccessibilityElementInfo elementInfo {};
500     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_TIME_OUT);
501     GTEST_LOG_(INFO) << "GetSource_001 end";
502 }
503 
504 /**
505  * @tc.number: GetSource_002
506  * @tc.name: GetSource
507  * @tc.desc: Test function GetSource
508  */
509 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_002, TestSize.Level1)
510 {
511     GTEST_LOG_(INFO) << "GetSource_002 start";
512     AccessibilityEventInfo eventInfo {};
513     AccessibilityElementInfo elementInfo {};
514     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_NO_CONNECTION);
515     GTEST_LOG_(INFO) << "GetSource_002 end";
516 }
517 
518 /**
519  * @tc.number: GetParentElementInfo_001
520  * @tc.name: GetParentElementInfo
521  * @tc.desc: Test function GetParentElementInfo
522  */
523 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_001, TestSize.Level1)
524 {
525     GTEST_LOG_(INFO) << "GetParentElementInfo_001 start";
526     Connect();
527     AccessibilityElementInfo parent {};
528     AccessibilityElementInfo child {};
529     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_TIME_OUT);
530     GTEST_LOG_(INFO) << "GetParentElementInfo_001 end";
531 }
532 
533 /**
534  * @tc.number: GetParentElementInfo_002
535  * @tc.name: GetParentElementInfo
536  * @tc.desc: Test function GetParentElementInfo
537  */
538 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_002, TestSize.Level1)
539 {
540     GTEST_LOG_(INFO) << "GetParentElementInfo_002 start";
541     AccessibilityElementInfo parent {};
542     AccessibilityElementInfo child {};
543     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_NO_CONNECTION);
544     GTEST_LOG_(INFO) << "GetParentElementInfo_002 end";
545 }
546 
547 /**
548  * @tc.number: ExecuteAction_001
549  * @tc.name: ExecuteAction
550  * @tc.desc: Test function ExecuteAction
551  */
552 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_001, TestSize.Level1)
553 {
554     GTEST_LOG_(INFO) << "ExecuteAction_001 start";
555     Connect();
556     AccessibilityElementInfo elementInfo {};
557     ActionType action = ACCESSIBILITY_ACTION_INVALID;
558     std::map<std::string, std::string> actionArguments {};
559     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_INVALID_PARAM);
560     GTEST_LOG_(INFO) << "ExecuteAction_001 end";
561 }
562 
563 /**
564  * @tc.number: ExecuteAction_002
565  * @tc.name: ExecuteAction
566  * @tc.desc: Test function ExecuteAction
567  */
568 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_002, TestSize.Level1)
569 {
570     GTEST_LOG_(INFO) << "ExecuteAction_002 start";
571     AccessibilityElementInfo elementInfo {};
572     ActionType action = ACCESSIBILITY_ACTION_SELECT;
573     std::map<std::string, std::string> actionArguments {};
574     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NO_CONNECTION);
575     GTEST_LOG_(INFO) << "ExecuteAction_002 end";
576 }
577 
578 /**
579  * @tc.number: ExecuteAction_003
580  * @tc.name: ExecuteAction
581  * @tc.desc: Test function ExecuteAction
582  */
583 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
584 {
585     GTEST_LOG_(INFO) << "ExecuteAction_003 start";
586     Connect();
587     AccessibilityElementInfo elementInfo {};
588     ActionType action = ACCESSIBILITY_ACTION_SELECT;
589     std::map<std::string, std::string> actionArguments {};
590     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_TIME_OUT);
591     GTEST_LOG_(INFO) << "ExecuteAction_003 end";
592 }
593 
594 /**
595  * @tc.number: ResetAAClient_001
596  * @tc.name: ResetAAClient
597  * @tc.desc: Test function ResetAAClient
598  */
599 HWTEST_F(AccessibleAbilityClientImplTest, ResetAAClient_001, TestSize.Level1)
600 {
601     GTEST_LOG_(INFO) << "ResetAAClient_001 start";
602     EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
603     Connect();
604     wptr<IRemoteObject> remote = nullptr;
605     instance_->ResetAAClient(remote);
606     std::vector<AccessibilityWindowInfo> infos;
607     EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
608     GTEST_LOG_(INFO) << "ResetAAClient_001 end";
609 }
610 
611 /**
612  * @tc.number: OnKeyPressEvent_001
613  * @tc.name: OnKeyPressEvent
614  * @tc.desc: Test function OnKeyPressEvent
615  */
616 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_001, TestSize.Level1)
617 {
618     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 start";
619     Connect();
620     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
621     event->SetKeyCode(1);
622     instance_->OnKeyPressEvent(*event, SEQUENCE);
623     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), 1);
624     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 end";
625 }
626 
627 /**
628  * @tc.number: OnKeyPressEvent_002
629  * @tc.name: OnKeyPressEvent
630  * @tc.desc: Test function OnKeyPressEvent
631  */
632 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_002, TestSize.Level1)
633 {
634     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 start";
635     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
636     event->SetKeyCode(1);
637     instance_->OnKeyPressEvent(*event, SEQUENCE);
638     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), INVALID_ID);
639     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 end";
640 }
641 
642 /**
643  * @tc.number: GetWindows_001
644  * @tc.name: GetWindows
645  * @tc.desc: Test function GetWindows
646  */
647 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
648 {
649     GTEST_LOG_(INFO) << "GetWindows_001 start";
650     EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
651     Connect();
652     std::vector<AccessibilityWindowInfo> infos;
653     EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
654     GTEST_LOG_(INFO) << "GetWindows_001 end";
655 }
656 
657 /**
658  * @tc.number: GetWindows_002
659  * @tc.name: GetWindows
660  * @tc.desc: Test function GetWindows
661  */
662 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_002, TestSize.Level1)
663 {
664     GTEST_LOG_(INFO) << "GetWindows_002 start";
665     EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
666     Connect();
667     std::vector<AccessibilityWindowInfo> infos;
668     EXPECT_EQ(instance_->GetWindows(0, infos), RET_OK);
669     GTEST_LOG_(INFO) << "GetWindows_002 end";
670 }
671 
672 /**
673  * @tc.number: GetWindows_003
674  * @tc.name: GetWindows
675  * @tc.desc: Test function GetWindows
676  */
677 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_003, TestSize.Level1)
678 {
679     GTEST_LOG_(INFO) << "GetWindows_003 start";
680     std::vector<AccessibilityWindowInfo> infos;
681     EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
682     GTEST_LOG_(INFO) << "GetWindows_003 end";
683 }
684 
685 /**
686  * @tc.number: GetWindows_004
687  * @tc.name: GetWindows
688  * @tc.desc: Test function GetWindows
689  */
690 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_004, TestSize.Level1)
691 {
692     GTEST_LOG_(INFO) << "GetWindows_004 start";
693     std::vector<AccessibilityWindowInfo> infos;
694     EXPECT_EQ(instance_->GetWindows(0, infos), RET_ERR_NO_CONNECTION);
695     GTEST_LOG_(INFO) << "GetWindows_004 end";
696 }
697 
698 /**
699  * @tc.number: GetChildElementInfo_001
700  * @tc.name: GetChildElementInfo
701  * @tc.desc: Test function GetChildElementInfo
702  */
703 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_001, TestSize.Level1)
704 {
705     GTEST_LOG_(INFO) << "GetChildElementInfo_001 start";
706     AccessibilityElementInfo parent;
707     AccessibilityElementInfo child;
708     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_NO_CONNECTION);
709     GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
710 }
711 
712 /**
713  * @tc.number: GetChildElementInfo_002
714  * @tc.name: GetChildElementInfo
715  * @tc.desc: Test function GetChildElementInfo
716  */
717 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_002, TestSize.Level1)
718 {
719     GTEST_LOG_(INFO) << "GetChildElementInfo_002 start";
720     Connect();
721     AccessibilityElementInfo parent;
722     AccessibilityElementInfo child;
723     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_INVALID_PARAM);
724     GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
725 }
726 
727 /**
728  * @tc.number: GetChildElementInfo_003
729  * @tc.name: GetChildElementInfo
730  * @tc.desc: Test function GetChildElementInfo
731  */
732 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_003, TestSize.Level1)
733 {
734     GTEST_LOG_(INFO) << "GetChildElementInfo_003 start";
735     Connect();
736 
737     AccessibilityElementInfo parent;
738     parent.AddChild(1);
739     AccessibilityElementInfo child;
740     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_TIME_OUT);
741     GTEST_LOG_(INFO) << "GetChildElementInfo_003 end";
742 }
743 
744 /**
745  * @tc.number: GetChildren_001
746  * @tc.name: GetChildren
747  * @tc.desc: Test function GetChildren
748  */
749 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_001, TestSize.Level1)
750 {
751     GTEST_LOG_(INFO) << "GetChildren_001 start";
752     AccessibilityElementInfo parent;
753     std::vector<AccessibilityElementInfo> children;
754     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_NO_CONNECTION);
755     GTEST_LOG_(INFO) << "GetChildren_001 end";
756 }
757 
758 /**
759  * @tc.number: GetChildren_002
760  * @tc.name: GetChildren
761  * @tc.desc: Test function GetChildren
762  */
763 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_002, TestSize.Level1)
764 {
765     GTEST_LOG_(INFO) << "GetChildren_002 start";
766     Connect();
767 
768     AccessibilityElementInfo parent;
769     parent.AddChild(INVALID_CHILD_ID);
770     std::vector<AccessibilityElementInfo> children;
771     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_INVALID_PARAM);
772     GTEST_LOG_(INFO) << "GetChildren_002 end";
773 }
774 
775 /**
776  * @tc.number: GetChildren_003
777  * @tc.name: GetChildren
778  * @tc.desc: Test function GetChildren
779  */
780 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_003, TestSize.Level1)
781 {
782     GTEST_LOG_(INFO) << "GetChildren_003 start";
783     Connect();
784 
785     AccessibilityElementInfo parent;
786     parent.AddChild(1);
787     std::vector<AccessibilityElementInfo> children;
788     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_TIME_OUT);
789     GTEST_LOG_(INFO) << "GetChildren_003 end";
790 }
791 
792 /**
793  * @tc.number: SetTargetBundleName_001
794  * @tc.name: SetTargetBundleName
795  * @tc.desc: Test function SetTargetBundleName
796  */
797 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Level1)
798 {
799     GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
800     std::vector<std::string> targetBundleNames;
801     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
802     GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
803 }
804 
805 /**
806  * @tc.number: SetTargetBundleName_002
807  * @tc.name: SetTargetBundleName
808  * @tc.desc: Test function SetTargetBundleName
809  */
810 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_002, TestSize.Level1)
811 {
812     GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
813     EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
814     Connect();
815     std::vector<std::string> targetBundleNames;
816     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
817     GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
818 }
819 
820 /**
821  * @tc.number: GetWindow_001
822  * @tc.name: GetWindow
823  * @tc.desc: Test function GetWindow
824  */
825 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
826 {
827     GTEST_LOG_(INFO) << "GetWindow_001 start";
828     AccessibilityWindowInfo windowInfo;
829     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_ERR_NO_CONNECTION);
830     GTEST_LOG_(INFO) << "GetWindow_001 end";
831 }
832 
833 /**
834  * @tc.number: GetWindow_002
835  * @tc.name: GetWindow
836  * @tc.desc: Test function GetWindow
837  */
838 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_002, TestSize.Level1)
839 {
840     GTEST_LOG_(INFO) << "GetWindow_002 start";
841     EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
842     Connect();
843     AccessibilityWindowInfo windowInfo;
844     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
845     GTEST_LOG_(INFO) << "GetWindow_002 end";
846 }
847 
848 /**
849  * @tc.number: NotifyServiceDied_001
850  * @tc.name: NotifyServiceDied
851  * @tc.desc: Test function NotifyServiceDied
852  */
853 HWTEST_F(AccessibleAbilityClientImplTest, NotifyServiceDied_001, TestSize.Level1)
854 {
855     GTEST_LOG_(INFO) << "NotifyServiceDied_001 start";
856     Connect();
857     wptr<IRemoteObject> remote = nullptr;
858     instance_->NotifyServiceDied(remote);
859     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
860     GTEST_LOG_(INFO) << "NotifyServiceDied_001 end";
861 }
862 } // namespace Accessibility
863 } // namespace OHOS