• 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_NO_CONNECTION);
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: GetFocus_004
181  * @tc.name: GetFocus
182  * @tc.desc: Test function GetFocus
183  */
184 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_004, TestSize.Level1)
185 {
186     GTEST_LOG_(INFO) << "GetFocus_004 start";
187     Connect();
188     AccessibilityElementInfo info {};
189     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_ACCESSIBILITY, info), RET_ERR_TIME_OUT);
190     GTEST_LOG_(INFO) << "GetFocus_004 end";
191 }
192 
193 /**
194  * @tc.number: GetRemoteObject_001
195  * @tc.name: GetRemoteObject
196  * @tc.desc: Test function GetRemoteObject
197  */
198 HWTEST_F(AccessibleAbilityClientImplTest, GetRemoteObject_001, TestSize.Level1)
199 {
200     GTEST_LOG_(INFO) << "GetRemoteObject_001 start";
201     EXPECT_TRUE(AccessibleAbilityClient::GetInstance()->GetRemoteObject());
202     GTEST_LOG_(INFO) << "GetRemoteObject_001 end";
203 }
204 
205 /**
206  * @tc.number: RegisterAbilityListener_001
207  * @tc.name: RegisterAbilityListener
208  * @tc.desc: Test function RegisterAbilityListener
209  */
210 HWTEST_F(AccessibleAbilityClientImplTest, RegisterAbilityListener_001, TestSize.Level1)
211 {
212     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 start";
213     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
214     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
215     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_REGISTER_EXIST);
216     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 end";
217 }
218 
219 /**
220  * @tc.number: Init_001
221  * @tc.name: Init
222  * @tc.desc: Test function Init
223  */
224 HWTEST_F(AccessibleAbilityClientImplTest, Init_001, TestSize.Level1)
225 {
226     GTEST_LOG_(INFO) << "Init_001 start";
227     sptr<IAccessibleAbilityChannel> channel = nullptr;
228     instance_->Init(channel, CHANNEL_ID);
229     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
230     GTEST_LOG_(INFO) << "Init_001 end";
231 }
232 
233 /**
234  * @tc.number: Init_002
235  * @tc.name: Init
236  * @tc.desc: Test function Init
237  */
238 HWTEST_F(AccessibleAbilityClientImplTest, Init_002, TestSize.Level1)
239 {
240     GTEST_LOG_(INFO) << "Init_002 start";
241     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
242     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
243 
244     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
245     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
246     instance_->Init(channel, CHANNEL_ID);
247     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
248     GTEST_LOG_(INFO) << "Init_002 end";
249 }
250 
251 /**
252  * @tc.number: Init_003
253  * @tc.name: Init
254  * @tc.desc: Test function Init
255  */
256 HWTEST_F(AccessibleAbilityClientImplTest, Init_003, TestSize.Level1)
257 {
258     GTEST_LOG_(INFO) << "Init_003 start";
259     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
260     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
261     instance_->Init(channel, CHANNEL_ID);
262     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
263     GTEST_LOG_(INFO) << "Init_003 end";
264 }
265 
266 /**
267  * @tc.number: GetFocusByElementInfo_001
268  * @tc.name: GetFocusByElementInfo
269  * @tc.desc: Test function GetFocusByElementInfo
270  */
271 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_001, TestSize.Level1)
272 {
273     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 start";
274     Connect();
275     AccessibilityElementInfo sourceInfo {};
276     AccessibilityElementInfo elementInfo {};
277     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_TIME_OUT);
278     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 end";
279 }
280 
281 /**
282  * @tc.number: GetFocusByElementInfo_002
283  * @tc.name: GetFocusByElementInfo
284  * @tc.desc: Test function GetFocusByElementInfo
285  */
286 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_002, TestSize.Level1)
287 {
288     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 start";
289     AccessibilityElementInfo sourceInfo {};
290     AccessibilityElementInfo elementInfo {};
291     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INVALID, elementInfo), RET_ERR_NO_CONNECTION);
292     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 end";
293 }
294 
295 /**
296  * @tc.number: GetFocusByElementInfo_003
297  * @tc.name: GetFocusByElementInfo
298  * @tc.desc: Test function GetFocusByElementInfo
299  */
300 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_003, TestSize.Level1)
301 {
302     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 start";
303     AccessibilityElementInfo sourceInfo {};
304     AccessibilityElementInfo elementInfo {};
305     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_NO_CONNECTION);
306     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 end";
307 }
308 
309 /**
310  * @tc.number: InjectGesture_001
311  * @tc.name: InjectGesture
312  * @tc.desc: Test function InjectGesture
313  */
314 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_001, TestSize.Level1)
315 {
316     GTEST_LOG_(INFO) << "InjectGesture_001 start";
317     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
318     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
319     GTEST_LOG_(INFO) << "InjectGesture_001 end";
320 }
321 
322 /**
323  * @tc.number: InjectGesture_002
324  * @tc.name: InjectGesture
325  * @tc.desc: Test function InjectGesture
326  */
327 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_002, TestSize.Level1)
328 {
329     GTEST_LOG_(INFO) << "InjectGesture_002 start";
330     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = nullptr;
331     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
332     GTEST_LOG_(INFO) << "InjectGesture_002 end";
333 }
334 
335 /**
336  * @tc.number: InjectGesture_003
337  * @tc.name: InjectGesture
338  * @tc.desc: Test function InjectGesture
339  */
340 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_003, TestSize.Level1)
341 {
342     GTEST_LOG_(INFO) << "InjectGesture_003 start";
343     EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
344     Connect();
345     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
346     AccessibilityGesturePosition position;
347     gesturePath->AddPosition(position);
348     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_OK);
349     GTEST_LOG_(INFO) << "InjectGesture_003 end";
350 }
351 
352 /**
353  * @tc.number: InjectGesture_004
354  * @tc.name: InjectGesture
355  * @tc.desc: Test function InjectGesture
356  */
357 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_004, TestSize.Level1)
358 {
359     GTEST_LOG_(INFO) << "InjectGesture_004 start";
360     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
361     AccessibilityGesturePosition position;
362     gesturePath->AddPosition(position);
363     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
364     GTEST_LOG_(INFO) << "InjectGesture_004 end";
365 }
366 
367 /**
368  * @tc.number: GetRoot_001
369  * @tc.name: GetRoot
370  * @tc.desc: Test function GetRoot
371  */
372 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_001, TestSize.Level1)
373 {
374     GTEST_LOG_(INFO) << "GetRoot_001 start";
375     Connect();
376     AccessibilityElementInfo info {};
377     instance_->SetCacheMode(0);
378     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_TIME_OUT);
379     GTEST_LOG_(INFO) << "GetRoot_001 end";
380 }
381 
382 /**
383  * @tc.number: GetRoot_002
384  * @tc.name: GetRoot
385  * @tc.desc: Test function GetRoot
386  */
387 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_002, TestSize.Level1)
388 {
389     GTEST_LOG_(INFO) << "GetRoot_002 start";
390     AccessibilityElementInfo info {};
391     instance_->SetCacheMode(INVALID_ID);
392     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_NO_CONNECTION);
393     GTEST_LOG_(INFO) << "GetRoot_002 end";
394 }
395 
396 /**
397  * @tc.number: GetRootByWindow_001
398  * @tc.name: GetRootByWindow
399  * @tc.desc: Test function GetRootByWindow
400  */
401 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_001, TestSize.Level1)
402 {
403     GTEST_LOG_(INFO) << "GetRootByWindow_001 start";
404     Connect();
405     AccessibilityElementInfo info {};
406     AccessibilityWindowInfo windowInfo {};
407     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_TIME_OUT);
408 
409     GTEST_LOG_(INFO) << "GetRootByWindow_001 end";
410 }
411 
412 /**
413  * @tc.number: GetRootByWindow_002
414  * @tc.name: GetRootByWindow
415  * @tc.desc: Test function GetRootByWindow
416  */
417 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_002, TestSize.Level1)
418 {
419     GTEST_LOG_(INFO) << "GetRootByWindow_002 start";
420     AccessibilityElementInfo info {};
421     AccessibilityWindowInfo windowInfo {};
422     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_NO_CONNECTION);
423 
424     GTEST_LOG_(INFO) << "GetRootByWindow_002 end";
425 }
426 
427 /**
428  * @tc.number: GetNext_001
429  * @tc.name: GetNext
430  * @tc.desc: Test function GetNext
431  */
432 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_001, TestSize.Level1)
433 {
434     GTEST_LOG_(INFO) << "GetNext_001 start";
435     Connect();
436     AccessibilityElementInfo info {};
437     AccessibilityElementInfo nextElementInfo {};
438     FocusMoveDirection direction = DIRECTION_INVALID;
439     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_INVALID_PARAM);
440     GTEST_LOG_(INFO) << "GetNext_001 end";
441 }
442 
443 /**
444  * @tc.number: GetNext_002
445  * @tc.name: GetNext
446  * @tc.desc: Test function GetNext
447  */
448 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_002, TestSize.Level1)
449 {
450     GTEST_LOG_(INFO) << "GetNext_002 start";
451     AccessibilityElementInfo info {};
452     AccessibilityElementInfo nextElementInfo {};
453     FocusMoveDirection direction = UP;
454     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_NO_CONNECTION);
455     GTEST_LOG_(INFO) << "GetNext_002 end";
456 }
457 
458 /**
459  * @tc.number: GetNext_003
460  * @tc.name: GetNext
461  * @tc.desc: Test function GetNext
462  */
463 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_003, TestSize.Level1)
464 {
465     GTEST_LOG_(INFO) << "GetNext_003 start";
466     Connect();
467     AccessibilityElementInfo info {};
468     AccessibilityElementInfo nextElementInfo {};
469     FocusMoveDirection direction = DOWN;
470     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_TIME_OUT);
471     GTEST_LOG_(INFO) << "GetNext_003 end";
472 }
473 
474 /**
475  * @tc.number: GetByContent_001
476  * @tc.name: GetByContent
477  * @tc.desc: Test function GetByContent
478  */
479 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_001, TestSize.Level1)
480 {
481     GTEST_LOG_(INFO) << "GetByContent_001 start";
482     Connect();
483     AccessibilityElementInfo elementInfo {};
484     std::vector<AccessibilityElementInfo> inelementInfosfos;
485     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_TIME_OUT);
486     GTEST_LOG_(INFO) << "GetByContent_001 end";
487 }
488 
489 /**
490  * @tc.number: GetByContent_002
491  * @tc.name: GetByContent
492  * @tc.desc: Test function GetByContent
493  */
494 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_002, TestSize.Level1)
495 {
496     GTEST_LOG_(INFO) << "GetByContent_002 start";
497     AccessibilityElementInfo elementInfo {};
498     std::vector<AccessibilityElementInfo> inelementInfosfos;
499     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_NO_CONNECTION);
500     GTEST_LOG_(INFO) << "GetByContent_002 end";
501 }
502 
503 /**
504  * @tc.number: GetSource_001
505  * @tc.name: GetSource
506  * @tc.desc: Test function GetSource
507  */
508 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_001, TestSize.Level1)
509 {
510     GTEST_LOG_(INFO) << "GetSource_001 start";
511     Connect();
512     AccessibilityEventInfo eventInfo {};
513     AccessibilityElementInfo elementInfo {};
514     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_TIME_OUT);
515     GTEST_LOG_(INFO) << "GetSource_001 end";
516 }
517 
518 /**
519  * @tc.number: GetSource_002
520  * @tc.name: GetSource
521  * @tc.desc: Test function GetSource
522  */
523 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_002, TestSize.Level1)
524 {
525     GTEST_LOG_(INFO) << "GetSource_002 start";
526     AccessibilityEventInfo eventInfo {};
527     AccessibilityElementInfo elementInfo {};
528     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_NO_CONNECTION);
529     GTEST_LOG_(INFO) << "GetSource_002 end";
530 }
531 
532 /**
533  * @tc.number: GetParentElementInfo_001
534  * @tc.name: GetParentElementInfo
535  * @tc.desc: Test function GetParentElementInfo
536  */
537 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_001, TestSize.Level1)
538 {
539     GTEST_LOG_(INFO) << "GetParentElementInfo_001 start";
540     Connect();
541     AccessibilityElementInfo parent {};
542     AccessibilityElementInfo child {};
543     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_TIME_OUT);
544     GTEST_LOG_(INFO) << "GetParentElementInfo_001 end";
545 }
546 
547 /**
548  * @tc.number: GetParentElementInfo_002
549  * @tc.name: GetParentElementInfo
550  * @tc.desc: Test function GetParentElementInfo
551  */
552 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_002, TestSize.Level1)
553 {
554     GTEST_LOG_(INFO) << "GetParentElementInfo_002 start";
555     AccessibilityElementInfo parent {};
556     AccessibilityElementInfo child {};
557     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_NO_CONNECTION);
558     GTEST_LOG_(INFO) << "GetParentElementInfo_002 end";
559 }
560 
561 /**
562  * @tc.number: ExecuteAction_001
563  * @tc.name: ExecuteAction
564  * @tc.desc: Test function ExecuteAction
565  */
566 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_001, TestSize.Level1)
567 {
568     GTEST_LOG_(INFO) << "ExecuteAction_001 start";
569     Connect();
570     AccessibilityElementInfo elementInfo {};
571     ActionType action = ACCESSIBILITY_ACTION_INVALID;
572     std::map<std::string, std::string> actionArguments {};
573     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_INVALID_PARAM);
574     GTEST_LOG_(INFO) << "ExecuteAction_001 end";
575 }
576 
577 /**
578  * @tc.number: ExecuteAction_002
579  * @tc.name: ExecuteAction
580  * @tc.desc: Test function ExecuteAction
581  */
582 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_002, TestSize.Level1)
583 {
584     GTEST_LOG_(INFO) << "ExecuteAction_002 start";
585     AccessibilityElementInfo elementInfo {};
586     ActionType action = ACCESSIBILITY_ACTION_SELECT;
587     std::map<std::string, std::string> actionArguments {};
588     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NO_CONNECTION);
589     GTEST_LOG_(INFO) << "ExecuteAction_002 end";
590 }
591 
592 /**
593  * @tc.number: ExecuteAction_003
594  * @tc.name: ExecuteAction
595  * @tc.desc: Test function ExecuteAction
596  */
597 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
598 {
599     GTEST_LOG_(INFO) << "ExecuteAction_003 start";
600     Connect();
601     AccessibilityElementInfo elementInfo {};
602     ActionType action = ACCESSIBILITY_ACTION_SELECT;
603     std::map<std::string, std::string> actionArguments {};
604     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_TIME_OUT);
605     GTEST_LOG_(INFO) << "ExecuteAction_003 end";
606 }
607 
608 /**
609  * @tc.number: ResetAAClient_001
610  * @tc.name: ResetAAClient
611  * @tc.desc: Test function ResetAAClient
612  */
613 HWTEST_F(AccessibleAbilityClientImplTest, ResetAAClient_001, TestSize.Level1)
614 {
615     GTEST_LOG_(INFO) << "ResetAAClient_001 start";
616     Connect();
617     wptr<IRemoteObject> remote = nullptr;
618     instance_->ResetAAClient(remote);
619     std::vector<AccessibilityWindowInfo> infos;
620     EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
621     GTEST_LOG_(INFO) << "ResetAAClient_001 end";
622 }
623 
624 /**
625  * @tc.number: OnKeyPressEvent_001
626  * @tc.name: OnKeyPressEvent
627  * @tc.desc: Test function OnKeyPressEvent
628  */
629 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_001, TestSize.Level1)
630 {
631     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 start";
632     Connect();
633     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
634     event->SetKeyCode(1);
635     instance_->OnKeyPressEvent(*event, SEQUENCE);
636     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), 1);
637     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 end";
638 }
639 
640 /**
641  * @tc.number: OnKeyPressEvent_002
642  * @tc.name: OnKeyPressEvent
643  * @tc.desc: Test function OnKeyPressEvent
644  */
645 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_002, TestSize.Level1)
646 {
647     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 start";
648     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
649     event->SetKeyCode(1);
650     instance_->OnKeyPressEvent(*event, SEQUENCE);
651     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), INVALID_ID);
652     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 end";
653 }
654 
655 /**
656  * @tc.number: GetWindows_001
657  * @tc.name: GetWindows
658  * @tc.desc: Test function GetWindows
659  */
660 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
661 {
662     GTEST_LOG_(INFO) << "GetWindows_001 start";
663     EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
664     Connect();
665     std::vector<AccessibilityWindowInfo> infos;
666     EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
667     GTEST_LOG_(INFO) << "GetWindows_001 end";
668 }
669 
670 /**
671  * @tc.number: GetWindows_002
672  * @tc.name: GetWindows
673  * @tc.desc: Test function GetWindows
674  */
675 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_002, TestSize.Level1)
676 {
677     GTEST_LOG_(INFO) << "GetWindows_002 start";
678     EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
679     Connect();
680     std::vector<AccessibilityWindowInfo> infos;
681     EXPECT_EQ(instance_->GetWindows(0, infos), RET_OK);
682     GTEST_LOG_(INFO) << "GetWindows_002 end";
683 }
684 
685 /**
686  * @tc.number: GetWindows_003
687  * @tc.name: GetWindows
688  * @tc.desc: Test function GetWindows
689  */
690 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_003, TestSize.Level1)
691 {
692     GTEST_LOG_(INFO) << "GetWindows_003 start";
693     std::vector<AccessibilityWindowInfo> infos;
694     EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
695     GTEST_LOG_(INFO) << "GetWindows_003 end";
696 }
697 
698 /**
699  * @tc.number: GetWindows_004
700  * @tc.name: GetWindows
701  * @tc.desc: Test function GetWindows
702  */
703 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_004, TestSize.Level1)
704 {
705     GTEST_LOG_(INFO) << "GetWindows_004 start";
706     std::vector<AccessibilityWindowInfo> infos;
707     EXPECT_EQ(instance_->GetWindows(0, infos), RET_ERR_NO_CONNECTION);
708     GTEST_LOG_(INFO) << "GetWindows_004 end";
709 }
710 
711 /**
712  * @tc.number: GetChildElementInfo_001
713  * @tc.name: GetChildElementInfo
714  * @tc.desc: Test function GetChildElementInfo
715  */
716 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_001, TestSize.Level1)
717 {
718     GTEST_LOG_(INFO) << "GetChildElementInfo_001 start";
719     AccessibilityElementInfo parent;
720     AccessibilityElementInfo child;
721     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_NO_CONNECTION);
722     GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
723 }
724 
725 /**
726  * @tc.number: GetChildElementInfo_002
727  * @tc.name: GetChildElementInfo
728  * @tc.desc: Test function GetChildElementInfo
729  */
730 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_002, TestSize.Level1)
731 {
732     GTEST_LOG_(INFO) << "GetChildElementInfo_002 start";
733     Connect();
734     AccessibilityElementInfo parent;
735     AccessibilityElementInfo child;
736     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_INVALID_PARAM);
737     GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
738 }
739 
740 /**
741  * @tc.number: GetChildElementInfo_003
742  * @tc.name: GetChildElementInfo
743  * @tc.desc: Test function GetChildElementInfo
744  */
745 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_003, TestSize.Level1)
746 {
747     GTEST_LOG_(INFO) << "GetChildElementInfo_003 start";
748     Connect();
749 
750     AccessibilityElementInfo parent;
751     parent.AddChild(1);
752     AccessibilityElementInfo child;
753     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_TIME_OUT);
754     GTEST_LOG_(INFO) << "GetChildElementInfo_003 end";
755 }
756 
757 /**
758  * @tc.number: GetChildren_001
759  * @tc.name: GetChildren
760  * @tc.desc: Test function GetChildren
761  */
762 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_001, TestSize.Level1)
763 {
764     GTEST_LOG_(INFO) << "GetChildren_001 start";
765     AccessibilityElementInfo parent;
766     std::vector<AccessibilityElementInfo> children;
767     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_NO_CONNECTION);
768     GTEST_LOG_(INFO) << "GetChildren_001 end";
769 }
770 
771 /**
772  * @tc.number: GetChildren_002
773  * @tc.name: GetChildren
774  * @tc.desc: Test function GetChildren
775  */
776 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_002, TestSize.Level1)
777 {
778     GTEST_LOG_(INFO) << "GetChildren_002 start";
779     Connect();
780 
781     AccessibilityElementInfo parent;
782     parent.AddChild(INVALID_CHILD_ID);
783     std::vector<AccessibilityElementInfo> children;
784     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_INVALID_PARAM);
785     GTEST_LOG_(INFO) << "GetChildren_002 end";
786 }
787 
788 /**
789  * @tc.number: GetChildren_003
790  * @tc.name: GetChildren
791  * @tc.desc: Test function GetChildren
792  */
793 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_003, TestSize.Level1)
794 {
795     GTEST_LOG_(INFO) << "GetChildren_003 start";
796     Connect();
797 
798     AccessibilityElementInfo parent;
799     parent.AddChild(1);
800     std::vector<AccessibilityElementInfo> children;
801     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_TIME_OUT);
802     GTEST_LOG_(INFO) << "GetChildren_003 end";
803 }
804 
805 /**
806  * @tc.number: SetTargetBundleName_001
807  * @tc.name: SetTargetBundleName
808  * @tc.desc: Test function SetTargetBundleName
809  */
810 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Level1)
811 {
812     GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
813     std::vector<std::string> targetBundleNames;
814     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
815     GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
816 }
817 
818 /**
819  * @tc.number: SetTargetBundleName_002
820  * @tc.name: SetTargetBundleName
821  * @tc.desc: Test function SetTargetBundleName
822  */
823 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_002, TestSize.Level1)
824 {
825     GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
826     EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
827     Connect();
828     std::vector<std::string> targetBundleNames;
829     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
830     GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
831 }
832 
833 /**
834  * @tc.number: GetWindow_001
835  * @tc.name: GetWindow
836  * @tc.desc: Test function GetWindow
837  */
838 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
839 {
840     GTEST_LOG_(INFO) << "GetWindow_001 start";
841     AccessibilityWindowInfo windowInfo;
842     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_ERR_NO_CONNECTION);
843     GTEST_LOG_(INFO) << "GetWindow_001 end";
844 }
845 
846 /**
847  * @tc.number: GetWindow_002
848  * @tc.name: GetWindow
849  * @tc.desc: Test function GetWindow
850  */
851 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_002, TestSize.Level1)
852 {
853     GTEST_LOG_(INFO) << "GetWindow_002 start";
854     EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
855     Connect();
856     AccessibilityWindowInfo windowInfo;
857     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
858     GTEST_LOG_(INFO) << "GetWindow_002 end";
859 }
860 
861 /**
862  * @tc.number: NotifyServiceDied_001
863  * @tc.name: NotifyServiceDied
864  * @tc.desc: Test function NotifyServiceDied
865  */
866 HWTEST_F(AccessibleAbilityClientImplTest, NotifyServiceDied_001, TestSize.Level1)
867 {
868     GTEST_LOG_(INFO) << "NotifyServiceDied_001 start";
869     Connect();
870     wptr<IRemoteObject> remote = nullptr;
871     instance_->NotifyServiceDied(remote);
872     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
873     GTEST_LOG_(INFO) << "NotifyServiceDied_001 end";
874 }
875 } // namespace Accessibility
876 } // namespace OHOS