• 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 int64_t INVALID_CHILD_ID = -1;
34     constexpr int INVALID_ID = -1;
35     constexpr int32_t WINDOW_ID = 2;
36     constexpr int64_t ELEMENT_ID = 1;
37 } // namespace
38 
39 class AccessibleAbilityClientImplTest : public ::testing::Test {
40 public:
AccessibleAbilityClientImplTest()41     AccessibleAbilityClientImplTest()
42     {}
~AccessibleAbilityClientImplTest()43     ~AccessibleAbilityClientImplTest()
44     {}
45 
46     std::shared_ptr<AccessibleAbilityClientImpl> instance_ = nullptr;
47     std::shared_ptr<AccessibleAbilityListener> listener_ = nullptr;
48     sptr<MockAccessibleAbilityChannelStub> stub_ = nullptr;
49     sptr<IAccessibleAbilityChannel> channel_ = nullptr;
50 
SetUpTestCase()51     static void SetUpTestCase()
52     {
53         Singleton<AccessibleAbilityManagerService>::GetInstance().OnStart();
54         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest Start";
55     }
TearDownTestCase()56     static void TearDownTestCase()
57     {
58         Singleton<AccessibleAbilityManagerService>::GetInstance().OnStop();
59         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest End";
60     }
SetUp()61     void SetUp()
62     {
63         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest SetUp()";
64         instance_ = std::make_shared<AccessibleAbilityClientImpl>();
65         ASSERT_TRUE(instance_);
66         listener_ = std::make_shared<MockAccessibleAbilityListener>();
67         ASSERT_TRUE(listener_);
68         stub_ = new MockAccessibleAbilityChannelStub();
69         ASSERT_TRUE(stub_);
70         channel_ = iface_cast<IAccessibleAbilityChannel>(stub_);
71         ASSERT_TRUE(channel_);
72     };
TearDown()73     void TearDown()
74     {
75         GTEST_LOG_(INFO) << "AccessibleAbilityClientImplTest TearDown()";
76         AccessibilityAbilityHelper::GetInstance().SetTestChannelId(INVALID_CHANNEL_ID);
77         AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(INVALID_ID);
78         AccessibilityAbilityHelper::GetInstance().SetTestEventType(INVALID_ID);
79         stub_ = nullptr;
80         channel_ = nullptr;
81         listener_ = nullptr;
82         instance_ = nullptr;
83     }
84 
85     void Connect();
86 };
87 
Connect()88 void AccessibleAbilityClientImplTest::Connect()
89 {
90     EXPECT_EQ(instance_->RegisterAbilityListener(listener_), RET_OK);
91     instance_->Init(channel_, CHANNEL_ID);
92     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
93 }
94 
95 /**
96  * @tc.number: Disconnect_001
97  * @tc.name: Disconnect
98  * @tc.desc: Test function Disconnect
99  */
100 HWTEST_F(AccessibleAbilityClientImplTest, Disconnect_001, TestSize.Level1)
101 {
102     GTEST_LOG_(INFO) << "Disconnect_001 start";
103     Connect();
104     instance_->Disconnect(CHANNEL_ID);
105     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(INVALID_CHANNEL_ID));
106     GTEST_LOG_(INFO) << "Disconnect_001 end";
107 }
108 
109 /**
110  * @tc.number: OnAccessibilityEvent_001
111  * @tc.name: OnAccessibilityEvent
112  * @tc.desc: Test function OnAccessibilityEvent
113  */
114 HWTEST_F(AccessibleAbilityClientImplTest, OnAccessibilityEvent_001, TestSize.Level1)
115 {
116     GTEST_LOG_(INFO) << "OnAccessibilityEvent_001 start";
117     Connect();
118     AccessibilityEventInfo eventInfo {};
119     eventInfo.SetEventType(EventType::TYPE_TOUCH_BEGIN);
120     instance_->OnAccessibilityEvent(eventInfo);
121     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestEventType(),
122         static_cast<int>(EventType::TYPE_TOUCH_BEGIN));
123     GTEST_LOG_(INFO) << "OnAccessibilityEvent_001 end";
124 }
125 
126 /**
127  * @tc.number: OnAccessibilityEvent_002
128  * @tc.name: OnAccessibilityEvent
129  * @tc.desc: Test function OnAccessibilityEvent
130  */
131 HWTEST_F(AccessibleAbilityClientImplTest, OnAccessibilityEvent_002, TestSize.Level1)
132 {
133     GTEST_LOG_(INFO) << "OnAccessibilityEvent_002 start";
134     AccessibilityEventInfo eventInfo;
135     eventInfo.SetEventType(EventType::TYPE_GESTURE_EVENT);
136     instance_->OnAccessibilityEvent(eventInfo);
137     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestEventType(), static_cast<int>(TYPE_GESTURE_EVENT));
138     GTEST_LOG_(INFO) << "OnAccessibilityEvent_002 end";
139 }
140 
141 /**
142  * @tc.number: GetFocus_001
143  * @tc.name: GetFocus
144  * @tc.desc: Test function GetFocus
145  */
146 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_001, TestSize.Level1)
147 {
148     GTEST_LOG_(INFO) << "GetFocus_001 start";
149     Connect();
150     AccessibilityElementInfo info {};
151     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
152     GTEST_LOG_(INFO) << "GetFocus_001 end";
153 }
154 
155 /**
156  * @tc.number: GetFocus_002
157  * @tc.name: GetFocus
158  * @tc.desc: Test function GetFocus
159  */
160 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_002, TestSize.Level1)
161 {
162     GTEST_LOG_(INFO) << "GetFocus_002 start";
163     AccessibilityElementInfo info {};
164     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INVALID, info), RET_ERR_NO_CONNECTION);
165     GTEST_LOG_(INFO) << "GetFocus_002 end";
166 }
167 
168 /**
169  * @tc.number: GetFocus_003
170  * @tc.name: GetFocus
171  * @tc.desc: Test function GetFocus
172  */
173 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_003, TestSize.Level1)
174 {
175     GTEST_LOG_(INFO) << "GetFocus_003 start";
176     AccessibilityElementInfo info {};
177     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_INPUT, info), RET_ERR_NO_CONNECTION);
178     GTEST_LOG_(INFO) << "GetFocus_003 end";
179 }
180 
181 /**
182  * @tc.number: GetFocus_004
183  * @tc.name: GetFocus
184  * @tc.desc: Test function GetFocus
185  */
186 HWTEST_F(AccessibleAbilityClientImplTest, GetFocus_004, TestSize.Level1)
187 {
188     GTEST_LOG_(INFO) << "GetFocus_004 start";
189     Connect();
190     AccessibilityElementInfo info {};
191     EXPECT_EQ(instance_->GetFocus(FOCUS_TYPE_ACCESSIBILITY, info), RET_ERR_TIME_OUT);
192     GTEST_LOG_(INFO) << "GetFocus_004 end";
193 }
194 
195 /**
196  * @tc.number: GetRemoteObject_001
197  * @tc.name: GetRemoteObject
198  * @tc.desc: Test function GetRemoteObject
199  */
200 HWTEST_F(AccessibleAbilityClientImplTest, GetRemoteObject_001, TestSize.Level1)
201 {
202     GTEST_LOG_(INFO) << "GetRemoteObject_001 start";
203     EXPECT_TRUE(AccessibleAbilityClient::GetInstance()->GetRemoteObject());
204     GTEST_LOG_(INFO) << "GetRemoteObject_001 end";
205 }
206 
207 /**
208  * @tc.number: RegisterAbilityListener_001
209  * @tc.name: RegisterAbilityListener
210  * @tc.desc: Test function RegisterAbilityListener
211  */
212 HWTEST_F(AccessibleAbilityClientImplTest, RegisterAbilityListener_001, TestSize.Level1)
213 {
214     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 start";
215     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
216     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
217     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_ERR_REGISTER_EXIST);
218     GTEST_LOG_(INFO) << "RegisterAbilityListener_001 end";
219 }
220 
221 /**
222  * @tc.number: Init_001
223  * @tc.name: Init
224  * @tc.desc: Test function Init
225  */
226 HWTEST_F(AccessibleAbilityClientImplTest, Init_001, TestSize.Level1)
227 {
228     GTEST_LOG_(INFO) << "Init_001 start";
229     sptr<IAccessibleAbilityChannel> channel = nullptr;
230     instance_->Init(channel, CHANNEL_ID);
231     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
232     GTEST_LOG_(INFO) << "Init_001 end";
233 }
234 
235 /**
236  * @tc.number: Init_002
237  * @tc.name: Init
238  * @tc.desc: Test function Init
239  */
240 HWTEST_F(AccessibleAbilityClientImplTest, Init_002, TestSize.Level1)
241 {
242     GTEST_LOG_(INFO) << "Init_002 start";
243     std::shared_ptr<AccessibleAbilityListener> listener = std::make_shared<MockAccessibleAbilityListener>();
244     EXPECT_EQ(instance_->RegisterAbilityListener(listener), RET_OK);
245 
246     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
247     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
248     instance_->Init(channel, CHANNEL_ID);
249     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
250     GTEST_LOG_(INFO) << "Init_002 end";
251 }
252 
253 /**
254  * @tc.number: Init_003
255  * @tc.name: Init
256  * @tc.desc: Test function Init
257  */
258 HWTEST_F(AccessibleAbilityClientImplTest, Init_003, TestSize.Level1)
259 {
260     GTEST_LOG_(INFO) << "Init_003 start";
261     sptr<MockAccessibleAbilityChannelStub> stub = new MockAccessibleAbilityChannelStub();
262     sptr<IAccessibleAbilityChannel> channel = new MockAccessibleAbilityChannelProxy(stub->AsObject());
263     instance_->Init(channel, CHANNEL_ID);
264     EXPECT_NE(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
265     GTEST_LOG_(INFO) << "Init_003 end";
266 }
267 
268 /**
269  * @tc.number: GetFocusByElementInfo_001
270  * @tc.name: GetFocusByElementInfo
271  * @tc.desc: Test function GetFocusByElementInfo
272  */
273 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_001, TestSize.Level1)
274 {
275     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 start";
276     Connect();
277     AccessibilityElementInfo sourceInfo {};
278     AccessibilityElementInfo elementInfo {};
279     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_TIME_OUT);
280     GTEST_LOG_(INFO) << "GetFocusByElementInfo_001 end";
281 }
282 
283 /**
284  * @tc.number: GetFocusByElementInfo_002
285  * @tc.name: GetFocusByElementInfo
286  * @tc.desc: Test function GetFocusByElementInfo
287  */
288 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_002, TestSize.Level1)
289 {
290     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 start";
291     AccessibilityElementInfo sourceInfo {};
292     AccessibilityElementInfo elementInfo {};
293     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INVALID, elementInfo), RET_ERR_NO_CONNECTION);
294     GTEST_LOG_(INFO) << "GetFocusByElementInfo_002 end";
295 }
296 
297 /**
298  * @tc.number: GetFocusByElementInfo_003
299  * @tc.name: GetFocusByElementInfo
300  * @tc.desc: Test function GetFocusByElementInfo
301  */
302 HWTEST_F(AccessibleAbilityClientImplTest, GetFocusByElementInfo_003, TestSize.Level1)
303 {
304     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 start";
305     AccessibilityElementInfo sourceInfo {};
306     AccessibilityElementInfo elementInfo {};
307     EXPECT_EQ(instance_->GetFocusByElementInfo(sourceInfo, FOCUS_TYPE_INPUT, elementInfo), RET_ERR_NO_CONNECTION);
308     GTEST_LOG_(INFO) << "GetFocusByElementInfo_003 end";
309 }
310 
311 /**
312  * @tc.number: InjectGesture_001
313  * @tc.name: InjectGesture
314  * @tc.desc: Test function InjectGesture
315  */
316 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_001, TestSize.Level1)
317 {
318     GTEST_LOG_(INFO) << "InjectGesture_001 start";
319     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
320     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
321     GTEST_LOG_(INFO) << "InjectGesture_001 end";
322 }
323 
324 /**
325  * @tc.number: InjectGesture_002
326  * @tc.name: InjectGesture
327  * @tc.desc: Test function InjectGesture
328  */
329 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_002, TestSize.Level1)
330 {
331     GTEST_LOG_(INFO) << "InjectGesture_002 start";
332     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = nullptr;
333     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
334     GTEST_LOG_(INFO) << "InjectGesture_002 end";
335 }
336 
337 /**
338  * @tc.number: InjectGesture_003
339  * @tc.name: InjectGesture
340  * @tc.desc: Test function InjectGesture
341  */
342 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_003, TestSize.Level1)
343 {
344     GTEST_LOG_(INFO) << "InjectGesture_003 start";
345     EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
346     Connect();
347     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
348     AccessibilityGesturePosition position;
349     gesturePath->AddPosition(position);
350     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_OK);
351     GTEST_LOG_(INFO) << "InjectGesture_003 end";
352 }
353 
354 /**
355  * @tc.number: InjectGesture_004
356  * @tc.name: InjectGesture
357  * @tc.desc: Test function InjectGesture
358  */
359 HWTEST_F(AccessibleAbilityClientImplTest, InjectGesture_004, TestSize.Level1)
360 {
361     GTEST_LOG_(INFO) << "InjectGesture_004 start";
362     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
363     AccessibilityGesturePosition position;
364     gesturePath->AddPosition(position);
365     EXPECT_EQ(instance_->InjectGesture(gesturePath), RET_ERR_NO_CONNECTION);
366     GTEST_LOG_(INFO) << "InjectGesture_004 end";
367 }
368 
369 /**
370  * @tc.number: GetRoot_001
371  * @tc.name: GetRoot
372  * @tc.desc: Test function GetRoot
373  */
374 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_001, TestSize.Level1)
375 {
376     GTEST_LOG_(INFO) << "GetRoot_001 start";
377     Connect();
378     AccessibilityElementInfo info {};
379     instance_->SetCacheMode(0);
380     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_TIME_OUT);
381     GTEST_LOG_(INFO) << "GetRoot_001 end";
382 }
383 
384 /**
385  * @tc.number: GetRoot_002
386  * @tc.name: GetRoot
387  * @tc.desc: Test function GetRoot
388  */
389 HWTEST_F(AccessibleAbilityClientImplTest, GetRoot_002, TestSize.Level1)
390 {
391     GTEST_LOG_(INFO) << "GetRoot_002 start";
392     AccessibilityElementInfo info {};
393     instance_->SetCacheMode(INVALID_ID);
394     EXPECT_EQ(instance_->GetRoot(info), RET_ERR_NO_CONNECTION);
395     GTEST_LOG_(INFO) << "GetRoot_002 end";
396 }
397 
398 /**
399  * @tc.number: GetRootByWindow_001
400  * @tc.name: GetRootByWindow
401  * @tc.desc: Test function GetRootByWindow
402  */
403 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_001, TestSize.Level1)
404 {
405     GTEST_LOG_(INFO) << "GetRootByWindow_001 start";
406     Connect();
407     AccessibilityElementInfo info {};
408     AccessibilityWindowInfo windowInfo {};
409     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_TIME_OUT);
410 
411     GTEST_LOG_(INFO) << "GetRootByWindow_001 end";
412 }
413 
414 /**
415  * @tc.number: GetRootByWindow_002
416  * @tc.name: GetRootByWindow
417  * @tc.desc: Test function GetRootByWindow
418  */
419 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindow_002, TestSize.Level1)
420 {
421     GTEST_LOG_(INFO) << "GetRootByWindow_002 start";
422     AccessibilityElementInfo info {};
423     AccessibilityWindowInfo windowInfo {};
424     EXPECT_EQ(instance_->GetRootByWindow(windowInfo, info), RET_ERR_NO_CONNECTION);
425 
426     GTEST_LOG_(INFO) << "GetRootByWindow_002 end";
427 }
428 
429 /**
430  * @tc.number: GetNext_001
431  * @tc.name: GetNext
432  * @tc.desc: Test function GetNext
433  */
434 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_001, TestSize.Level1)
435 {
436     GTEST_LOG_(INFO) << "GetNext_001 start";
437     Connect();
438     AccessibilityElementInfo info {};
439     AccessibilityElementInfo nextElementInfo {};
440     FocusMoveDirection direction = DIRECTION_INVALID;
441     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_INVALID_PARAM);
442     GTEST_LOG_(INFO) << "GetNext_001 end";
443 }
444 
445 /**
446  * @tc.number: GetNext_002
447  * @tc.name: GetNext
448  * @tc.desc: Test function GetNext
449  */
450 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_002, TestSize.Level1)
451 {
452     GTEST_LOG_(INFO) << "GetNext_002 start";
453     AccessibilityElementInfo info {};
454     AccessibilityElementInfo nextElementInfo {};
455     FocusMoveDirection direction = UP;
456     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_NO_CONNECTION);
457     GTEST_LOG_(INFO) << "GetNext_002 end";
458 }
459 
460 /**
461  * @tc.number: GetNext_003
462  * @tc.name: GetNext
463  * @tc.desc: Test function GetNext
464  */
465 HWTEST_F(AccessibleAbilityClientImplTest, GetNext_003, TestSize.Level1)
466 {
467     GTEST_LOG_(INFO) << "GetNext_003 start";
468     Connect();
469     AccessibilityElementInfo info {};
470     AccessibilityElementInfo nextElementInfo {};
471     FocusMoveDirection direction = DOWN;
472     EXPECT_EQ(instance_->GetNext(info, direction, nextElementInfo), RET_ERR_TIME_OUT);
473     GTEST_LOG_(INFO) << "GetNext_003 end";
474 }
475 
476 /**
477  * @tc.number: GetByContent_001
478  * @tc.name: GetByContent
479  * @tc.desc: Test function GetByContent
480  */
481 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_001, TestSize.Level1)
482 {
483     GTEST_LOG_(INFO) << "GetByContent_001 start";
484     Connect();
485     AccessibilityElementInfo elementInfo {};
486     std::vector<AccessibilityElementInfo> inelementInfosfos;
487     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_TIME_OUT);
488     GTEST_LOG_(INFO) << "GetByContent_001 end";
489 }
490 
491 /**
492  * @tc.number: GetByContent_002
493  * @tc.name: GetByContent
494  * @tc.desc: Test function GetByContent
495  */
496 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_002, TestSize.Level1)
497 {
498     GTEST_LOG_(INFO) << "GetByContent_002 start";
499     AccessibilityElementInfo elementInfo {};
500     std::vector<AccessibilityElementInfo> inelementInfosfos;
501     EXPECT_EQ(instance_->GetByContent(elementInfo, TEST, inelementInfosfos), RET_ERR_NO_CONNECTION);
502     GTEST_LOG_(INFO) << "GetByContent_002 end";
503 }
504 
505 /**
506  * @tc.number: GetSource_001
507  * @tc.name: GetSource
508  * @tc.desc: Test function GetSource
509  */
510 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_001, TestSize.Level1)
511 {
512     GTEST_LOG_(INFO) << "GetSource_001 start";
513     Connect();
514     AccessibilityEventInfo eventInfo {};
515     AccessibilityElementInfo elementInfo {};
516     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_TIME_OUT);
517     GTEST_LOG_(INFO) << "GetSource_001 end";
518 }
519 
520 /**
521  * @tc.number: GetSource_002
522  * @tc.name: GetSource
523  * @tc.desc: Test function GetSource
524  */
525 HWTEST_F(AccessibleAbilityClientImplTest, GetSource_002, TestSize.Level1)
526 {
527     GTEST_LOG_(INFO) << "GetSource_002 start";
528     AccessibilityEventInfo eventInfo {};
529     AccessibilityElementInfo elementInfo {};
530     EXPECT_EQ(instance_->GetSource(eventInfo, elementInfo), RET_ERR_NO_CONNECTION);
531     GTEST_LOG_(INFO) << "GetSource_002 end";
532 }
533 
534 /**
535  * @tc.number: GetParentElementInfo_001
536  * @tc.name: GetParentElementInfo
537  * @tc.desc: Test function GetParentElementInfo
538  */
539 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_001, TestSize.Level1)
540 {
541     GTEST_LOG_(INFO) << "GetParentElementInfo_001 start";
542     Connect();
543     AccessibilityElementInfo parent {};
544     AccessibilityElementInfo child {};
545     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_TIME_OUT);
546     GTEST_LOG_(INFO) << "GetParentElementInfo_001 end";
547 }
548 
549 /**
550  * @tc.number: GetParentElementInfo_002
551  * @tc.name: GetParentElementInfo
552  * @tc.desc: Test function GetParentElementInfo
553  */
554 HWTEST_F(AccessibleAbilityClientImplTest, GetParentElementInfo_002, TestSize.Level1)
555 {
556     GTEST_LOG_(INFO) << "GetParentElementInfo_002 start";
557     AccessibilityElementInfo parent {};
558     AccessibilityElementInfo child {};
559     EXPECT_EQ(instance_->GetParentElementInfo(child, parent), RET_ERR_NO_CONNECTION);
560     GTEST_LOG_(INFO) << "GetParentElementInfo_002 end";
561 }
562 
563 /**
564  * @tc.number: EnableScreenCurtain_001
565  * @tc.name: EnableScreenCurtain
566  * @tc.desc: Test function EnableScreenCurtain
567 */
568 HWTEST_F(AccessibleAbilityClientImplTest, EnableScreenCurtain_001, TestSize.Level1)
569 {
570     GTEST_LOG_(INFO) << "EnableScreenCurtain_001 start";
571     Connect();
572     EXPECT_NE(instance_->EnableScreenCurtain(true), RET_OK);
573     GTEST_LOG_(INFO) << "EnableScreenCurtain_001 end";
574 }
575 
576 /**
577  * @tc.number: HoldRunningLock_001
578  * @tc.name: HoldRunningLock
579  * @tc.desc: Test function HoldRunningLock
580 */
581 HWTEST_F(AccessibleAbilityClientImplTest, HoldRunningLock_001, TestSize.Level1)
582 {
583     GTEST_LOG_(INFO) << "HoldRunningLock_001 start";
584     Connect();
585     EXPECT_EQ(instance_->HoldRunningLock(), RET_OK);
586     GTEST_LOG_(INFO) << "HoldRunningLock_001 end";
587 }
588 
589 /**
590  * @tc.number: UnholdRunningLock_001
591  * @tc.name: UnholdRunningLock
592  * @tc.desc: Test function UnholdRunningLock
593 */
594 HWTEST_F(AccessibleAbilityClientImplTest, UnholdRunningLock_001, TestSize.Level1)
595 {
596     GTEST_LOG_(INFO) << "UnholdRunningLock_001 start";
597     Connect();
598     EXPECT_EQ(instance_->UnholdRunningLock(), RET_OK);
599     GTEST_LOG_(INFO) << "UnholdRunningLock_001 end";
600 }
601 
602 /**
603  * @tc.number: GetByElementId_001
604  * @tc.name: GetByElementId
605  * @tc.desc: Test function GetByElementId
606  */
607 HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_001, TestSize.Level1)
608 {
609     GTEST_LOG_(INFO) << "GetByElementId_001 start";
610     Connect();
611     int64_t elementId = 10;
612     int32_t windowId = 1;
613     AccessibilityElementInfo targetElementInfo {};
614     EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_TIME_OUT);
615     GTEST_LOG_(INFO) << "GetByElementId_001 end";
616 }
617 
618 /**
619  * @tc.number: GetByElementId_002
620  * @tc.name: GetByElementId
621  * @tc.desc: Test function GetByElementId
622  */
623 HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_002, TestSize.Level1)
624 {
625     GTEST_LOG_(INFO) << "GetByElementId_002 start";
626     int64_t elementId = 10;
627     int32_t windowId = 1;
628     AccessibilityElementInfo targetElementInfo {};
629     EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_NO_CONNECTION);
630     GTEST_LOG_(INFO) << "GetByElementId_002 end";
631 }
632 
633 /**
634  * @tc.number: ExecuteAction_001
635  * @tc.name: ExecuteAction
636  * @tc.desc: Test function ExecuteAction
637  */
638 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_001, TestSize.Level1)
639 {
640     GTEST_LOG_(INFO) << "ExecuteAction_001 start";
641     Connect();
642     AccessibilityElementInfo elementInfo {};
643     ActionType action = ACCESSIBILITY_ACTION_INVALID;
644     std::map<std::string, std::string> actionArguments {};
645     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_INVALID_PARAM);
646     GTEST_LOG_(INFO) << "ExecuteAction_001 end";
647 }
648 
649 /**
650  * @tc.number: ExecuteAction_002
651  * @tc.name: ExecuteAction
652  * @tc.desc: Test function ExecuteAction
653  */
654 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_002, TestSize.Level1)
655 {
656     GTEST_LOG_(INFO) << "ExecuteAction_002 start";
657     AccessibilityElementInfo elementInfo {};
658     ActionType action = ACCESSIBILITY_ACTION_SELECT;
659     std::map<std::string, std::string> actionArguments {};
660     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NO_CONNECTION);
661     GTEST_LOG_(INFO) << "ExecuteAction_002 end";
662 }
663 
664 /**
665  * @tc.number: ExecuteAction_003
666  * @tc.name: ExecuteAction
667  * @tc.desc: Test function ExecuteAction
668  */
669 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
670 {
671     GTEST_LOG_(INFO) << "ExecuteAction_003 start";
672     Connect();
673     AccessibilityElementInfo elementInfo {};
674     ActionType action = ACCESSIBILITY_ACTION_SELECT;
675     std::map<std::string, std::string> actionArguments {};
676     EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_TIME_OUT);
677     GTEST_LOG_(INFO) << "ExecuteAction_003 end";
678 }
679 
680 /**
681  * @tc.number: ExecuteAction_004
682  * @tc.name: ExecuteAction
683  * @tc.desc: Test function ExecuteAction
684  */
685 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_004, TestSize.Level1)
686 {
687     GTEST_LOG_(INFO) << "ExecuteAction_004 start";
688     Connect();
689     AccessibilityElementInfo elementInfo {};
690     std::vector<ActionType> actions;
691     actions.push_back(ACCESSIBILITY_ACTION_HOME);
692     actions.push_back(ACCESSIBILITY_ACTION_BACK);
693     actions.push_back(ACCESSIBILITY_ACTION_RECENTTASK);
694     actions.push_back(ACCESSIBILITY_ACTION_NOTIFICATIONCENTER);
695     actions.push_back(ACCESSIBILITY_ACTION_CONTROLCENTER);
696     for (int32_t i = 0; i < actions.size(); i++) {
697         std::map<std::string, std::string> actionArguments {};
698         EXPECT_EQ(instance_->ExecuteAction(elementInfo, actions[i], actionArguments), RET_ERR_TIME_OUT);
699         GTEST_LOG_(INFO) << "ExecuteAction_004 action=" << actions[i];
700     }
701     GTEST_LOG_(INFO) << "ExecuteAction_004 end";
702 }
703 
704 /**
705  * @tc.number: GetCursorPosition_001
706  * @tc.name: GetCursorPosition
707  * @tc.desc: Test function GetCursorPosition
708  */
709 HWTEST_F(AccessibleAbilityClientImplTest, GetCursorPosition_001, TestSize.Level1)
710 {
711     GTEST_LOG_(INFO) << "GetCursorPosition_001 start";
712     Connect();
713     AccessibilityElementInfo elementInfo {};
714     int32_t position;
715     EXPECT_EQ(instance_->GetCursorPosition(elementInfo, position), RET_ERR_TIME_OUT);
716     GTEST_LOG_(INFO) << "GetCursorPosition_001 end";
717 }
718 
719 /**
720  * @tc.number: ResetAAClient_001
721  * @tc.name: ResetAAClient
722  * @tc.desc: Test function ResetAAClient
723  */
724 HWTEST_F(AccessibleAbilityClientImplTest, ResetAAClient_001, TestSize.Level1)
725 {
726     GTEST_LOG_(INFO) << "ResetAAClient_001 start";
727     EXPECT_CALL(*stub_, GetWindows(_, _)).Times(1).WillOnce(Return(RET_OK));
728     Connect();
729     wptr<IRemoteObject> remote = nullptr;
730     instance_->ResetAAClient(remote);
731     instance_->SetConnectionState(true);
732     std::vector<AccessibilityWindowInfo> infos;
733     EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
734     GTEST_LOG_(INFO) << "ResetAAClient_001 end";
735 }
736 
737 /**
738  * @tc.number: OnKeyPressEvent_001
739  * @tc.name: OnKeyPressEvent
740  * @tc.desc: Test function OnKeyPressEvent
741  */
742 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_001, TestSize.Level1)
743 {
744     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 start";
745     Connect();
746     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
747     event->SetKeyCode(1);
748     instance_->OnKeyPressEvent(*event, SEQUENCE);
749     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), 1);
750     GTEST_LOG_(INFO) << "OnKeyPressEvent_001 end";
751 }
752 
753 /**
754  * @tc.number: OnKeyPressEvent_002
755  * @tc.name: OnKeyPressEvent
756  * @tc.desc: Test function OnKeyPressEvent
757  */
758 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_002, TestSize.Level1)
759 {
760     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 start";
761     std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
762     event->SetKeyCode(1);
763     instance_->OnKeyPressEvent(*event, SEQUENCE);
764     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), INVALID_ID);
765     GTEST_LOG_(INFO) << "OnKeyPressEvent_002 end";
766 }
767 
768 /**
769  * @tc.number: GetWindows_001
770  * @tc.name: GetWindows
771  * @tc.desc: Test function GetWindows
772  */
773 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
774 {
775     GTEST_LOG_(INFO) << "GetWindows_001 start";
776     EXPECT_CALL(*stub_, GetWindows(_, _)).Times(1).WillOnce(Return(RET_OK));
777     Connect();
778     std::vector<AccessibilityWindowInfo> infos;
779     EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
780     GTEST_LOG_(INFO) << "GetWindows_001 end";
781 }
782 
783 /**
784  * @tc.number: GetWindows_002
785  * @tc.name: GetWindows
786  * @tc.desc: Test function GetWindows
787  */
788 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_002, TestSize.Level1)
789 {
790     GTEST_LOG_(INFO) << "GetWindows_002 start";
791     EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _, _)).Times(1).WillOnce(Return(RET_OK));
792     Connect();
793     std::vector<AccessibilityWindowInfo> infos;
794     EXPECT_EQ(instance_->GetWindows(0, infos), RET_OK);
795     GTEST_LOG_(INFO) << "GetWindows_002 end";
796 }
797 
798 /**
799  * @tc.number: GetWindows_003
800  * @tc.name: GetWindows
801  * @tc.desc: Test function GetWindows
802  */
803 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_003, TestSize.Level1)
804 {
805     GTEST_LOG_(INFO) << "GetWindows_003 start";
806     std::vector<AccessibilityWindowInfo> infos;
807     EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
808     GTEST_LOG_(INFO) << "GetWindows_003 end";
809 }
810 
811 /**
812  * @tc.number: GetWindows_004
813  * @tc.name: GetWindows
814  * @tc.desc: Test function GetWindows
815  */
816 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_004, TestSize.Level1)
817 {
818     GTEST_LOG_(INFO) << "GetWindows_004 start";
819     std::vector<AccessibilityWindowInfo> infos;
820     EXPECT_EQ(instance_->GetWindows(0, infos), RET_ERR_NO_CONNECTION);
821     GTEST_LOG_(INFO) << "GetWindows_004 end";
822 }
823 
824 /**
825  * @tc.number: GetChildElementInfo_001
826  * @tc.name: GetChildElementInfo
827  * @tc.desc: Test function GetChildElementInfo
828  */
829 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_001, TestSize.Level1)
830 {
831     GTEST_LOG_(INFO) << "GetChildElementInfo_001 start";
832     AccessibilityElementInfo parent;
833     AccessibilityElementInfo child;
834     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_NO_CONNECTION);
835     GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
836 }
837 
838 /**
839  * @tc.number: GetChildElementInfo_002
840  * @tc.name: GetChildElementInfo
841  * @tc.desc: Test function GetChildElementInfo
842  */
843 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_002, TestSize.Level1)
844 {
845     GTEST_LOG_(INFO) << "GetChildElementInfo_002 start";
846     Connect();
847     AccessibilityElementInfo parent;
848     AccessibilityElementInfo child;
849     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_INVALID_PARAM);
850     GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
851 }
852 
853 /**
854  * @tc.number: GetChildElementInfo_003
855  * @tc.name: GetChildElementInfo
856  * @tc.desc: Test function GetChildElementInfo
857  */
858 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_003, TestSize.Level1)
859 {
860     GTEST_LOG_(INFO) << "GetChildElementInfo_003 start";
861     Connect();
862 
863     AccessibilityElementInfo parent;
864     parent.AddChild(1);
865     AccessibilityElementInfo child;
866     EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_TIME_OUT);
867     GTEST_LOG_(INFO) << "GetChildElementInfo_003 end";
868 }
869 
870 /**
871  * @tc.number: GetChildren_001
872  * @tc.name: GetChildren
873  * @tc.desc: Test function GetChildren
874  */
875 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_001, TestSize.Level1)
876 {
877     GTEST_LOG_(INFO) << "GetChildren_001 start";
878     AccessibilityElementInfo parent;
879     std::vector<AccessibilityElementInfo> children;
880     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_NO_CONNECTION);
881     GTEST_LOG_(INFO) << "GetChildren_001 end";
882 }
883 
884 /**
885  * @tc.number: GetChildren_002
886  * @tc.name: GetChildren
887  * @tc.desc: Test function GetChildren
888  */
889 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_002, TestSize.Level1)
890 {
891     GTEST_LOG_(INFO) << "GetChildren_002 start";
892     Connect();
893 
894     AccessibilityElementInfo parent;
895     parent.AddChild(INVALID_CHILD_ID);
896     std::vector<AccessibilityElementInfo> children;
897     EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_INVALID_PARAM);
898     GTEST_LOG_(INFO) << "GetChildren_002 end";
899 }
900 
901 /**
902  * @tc.number: GetChildren_003
903  * @tc.name: GetChildren
904  * @tc.desc: Test function GetChildren
905  */
906 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_003, TestSize.Level1)
907 {
908     GTEST_LOG_(INFO) << "GetChildren_003 start";
909     Connect();
910 
911     AccessibilityElementInfo parent;
912     parent.AddChild(1);
913     std::vector<AccessibilityElementInfo> children;
914     EXPECT_EQ(instance_->GetChildren(parent, children), RET_OK);
915     GTEST_LOG_(INFO) << "GetChildren_003 end";
916 }
917 
918 /**
919  * @tc.number: SetTargetBundleName_001
920  * @tc.name: SetTargetBundleName
921  * @tc.desc: Test function SetTargetBundleName
922  */
923 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Level1)
924 {
925     GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
926     std::vector<std::string> targetBundleNames;
927     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
928     GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
929 }
930 
931 /**
932  * @tc.number: SetTargetBundleName_002
933  * @tc.name: SetTargetBundleName
934  * @tc.desc: Test function SetTargetBundleName
935  */
936 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_002, TestSize.Level1)
937 {
938     GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
939     EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
940     Connect();
941     std::vector<std::string> targetBundleNames;
942     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
943     GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
944 }
945 
946 /**
947  * @tc.number: GetWindow_001
948  * @tc.name: GetWindow
949  * @tc.desc: Test function GetWindow
950  */
951 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
952 {
953     GTEST_LOG_(INFO) << "GetWindow_001 start";
954     AccessibilityWindowInfo windowInfo;
955     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_ERR_NO_CONNECTION);
956     GTEST_LOG_(INFO) << "GetWindow_001 end";
957 }
958 
959 /**
960  * @tc.number: GetWindow_002
961  * @tc.name: GetWindow
962  * @tc.desc: Test function GetWindow
963  */
964 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_002, TestSize.Level1)
965 {
966     GTEST_LOG_(INFO) << "GetWindow_002 start";
967     EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
968     Connect();
969     AccessibilityWindowInfo windowInfo;
970     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
971     GTEST_LOG_(INFO) << "GetWindow_002 end";
972 }
973 
974 /**
975  * @tc.number: NotifyServiceDied_001
976  * @tc.name: NotifyServiceDied
977  * @tc.desc: Test function NotifyServiceDied
978  */
979 HWTEST_F(AccessibleAbilityClientImplTest, NotifyServiceDied_001, TestSize.Level1)
980 {
981     GTEST_LOG_(INFO) << "NotifyServiceDied_001 start";
982     Connect();
983     wptr<IRemoteObject> remote = nullptr;
984     instance_->NotifyServiceDied(remote);
985     EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
986     GTEST_LOG_(INFO) << "NotifyServiceDied_001 end";
987 }
988 
989 /**
990  * @tc.number: GetRootByWindowBatch_001
991  * @tc.name: GetRootByWindowBatch
992  * @tc.desc: Test function GetRootByWindowBatch
993  */
994 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindowBatch_001, TestSize.Level1)
995 {
996     GTEST_LOG_(INFO) << "GetRootByWindowBatch_001 start";
997     Connect();
998     std::vector<AccessibilityElementInfo> info;
999     AccessibilityWindowInfo windowInfo {};
1000     EXPECT_EQ(instance_->GetRootByWindowBatch(windowInfo, info, true, false), RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE);
1001     GTEST_LOG_(INFO) << "GetRootByWindowBatch_001 end";
1002 }
1003 
1004 /**
1005  * @tc.number: GetRootBatch_001
1006  * @tc.name: GetRootBatch
1007  * @tc.desc: Test function GetRootBatch
1008  */
1009 HWTEST_F(AccessibleAbilityClientImplTest, GetRootBatch_001, TestSize.Level1)
1010 {
1011     GTEST_LOG_(INFO) << "GetRootBatch_001 start";
1012     Connect();
1013     std::vector<AccessibilityElementInfo> info;
1014     instance_->SetCacheMode(0);
1015     EXPECT_EQ(instance_->GetRootBatch(info), RET_ERR_TIME_OUT);
1016     GTEST_LOG_(INFO) << "GetRootBatch_001 end";
1017 }
1018 
1019 /**
1020  * @tc.number: AddCacheByWMS_001
1021  * @tc.name: AddCacheByWMS
1022  * @tc.desc: Test function AddCacheByWMS
1023  */
1024 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByWMS_001, TestSize.Level1)
1025 {
1026     GTEST_LOG_(INFO) << "AddCacheByWMS_001 start";
1027     AccessibilityElementInfo elementInfo;
1028     elementInfo.SetAccessibilityId(ELEMENT_ID);
1029     std::vector<AccessibilityElementInfo> info;
1030     info.push_back(elementInfo);
1031     instance_->AddCacheByWMS(WINDOW_ID, ELEMENT_ID, info);
1032     std::vector<AccessibilityElementInfo> result;
1033     EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_OK);
1034     EXPECT_EQ(result.size(), 1);
1035     GTEST_LOG_(INFO) << "AddCacheByWMS_001 end";
1036 }
1037 
1038 /**
1039  * @tc.number: AddCacheByWMS_002
1040  * @tc.name: AddCacheByWMS
1041  * @tc.desc: Test function AddCacheByWMS
1042  */
1043 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByWMS_002, TestSize.Level1)
1044 {
1045     GTEST_LOG_(INFO) << "AddCacheByWMS_002 start";
1046     AccessibilityElementInfo elementInfo;
1047     elementInfo.SetAccessibilityId(ELEMENT_ID);
1048     std::vector<AccessibilityElementInfo> info;
1049     info.push_back(elementInfo);
1050     instance_->AddCacheByWMS(WINDOW_ID, ELEMENT_ID, info);
1051     std::vector<AccessibilityElementInfo> result;
1052     EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_OK);
1053     EXPECT_EQ(result.size(), 1);
1054 
1055     AccessibilityEventInfo eventInfo;
1056     eventInfo.SetWindowId(WINDOW_ID);
1057     eventInfo.SetEventType(TYPE_VIEW_TEXT_UPDATE_EVENT);
1058     instance_->RemoveCacheData(eventInfo);
1059     EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_ERR_FAILED);
1060     EXPECT_EQ(result.size(), 0);
1061     GTEST_LOG_(INFO) << "AddCacheByWMS_002 end";
1062 }
1063 
1064 /**
1065  * @tc.number: AddCacheByAce_001
1066  * @tc.name: AddCacheByAce
1067  * @tc.desc: Test function AddCacheByAce
1068  */
1069 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByAce_001, TestSize.Level1)
1070 {
1071     GTEST_LOG_(INFO) << "AddCacheByAce_001 start";
1072     AccessibilityElementInfo elementInfo;
1073     elementInfo.SetAccessibilityId(ELEMENT_ID);
1074     std::vector<AccessibilityElementInfo> info;
1075     info.push_back(elementInfo);
1076     instance_->AddCacheByAce(WINDOW_ID, ELEMENT_ID, info);
1077     std::vector<AccessibilityElementInfo> result;
1078     EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_OK);
1079     EXPECT_EQ(result.size(), 1);
1080     GTEST_LOG_(INFO) << "AddCacheByAce_001 end";
1081 }
1082 
1083 /**
1084  * @tc.number: GetByContent_003
1085  * @tc.name: GetByContent
1086  * @tc.desc: Test function GetByContent
1087  */
1088 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_003, TestSize.Level1)
1089 {
1090     GTEST_LOG_(INFO) << "GetByContent_003 start";
1091     Connect();
1092     AccessibilityElementInfo elementInfo {};
1093     std::vector<AccessibilityElementInfo> infos;
1094     EXPECT_EQ(instance_->GetByContent(elementInfo, "", infos), RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE);
1095     GTEST_LOG_(INFO) << "GetByContent_003 end";
1096 }
1097 
1098 /**
1099  * @tc.number: GetElements_001
1100  * @tc.name: GetElements
1101  * @tc.desc: Test function GetElements
1102  */
1103 HWTEST_F(AccessibleAbilityClientImplTest, GetElements_001, TestSize.Level1)
1104 {
1105     GTEST_LOG_(INFO) << "GetElements_001 start";
1106     Connect();
1107     std::vector<AccessibilityElementInfo> infos;
1108     EXPECT_EQ(instance_->GetElements(1, -1, infos), RET_ERR_TIME_OUT);
1109     EXPECT_EQ(instance_->GetElements(1, 1, infos), RET_ERR_TIME_OUT);
1110     EXPECT_EQ(instance_->GetElements(1, -2, infos), RET_ERR_INVALID_PARAM);
1111     EXPECT_EQ(instance_->GetElements(-1, -1, infos), RET_ERR_INVALID_PARAM);
1112     GTEST_LOG_(INFO) << "GetElements_001 end";
1113 }
1114 } // namespace Accessibility
1115 } // namespace OHOS