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_EQ(instance_->EnableScreenCurtain(true), RET_OK);
573 GTEST_LOG_(INFO) << "EnableScreenCurtain_001 end";
574 }
575
576 /**
577 * @tc.number: GetByElementId_001
578 * @tc.name: GetByElementId
579 * @tc.desc: Test function GetByElementId
580 */
581 HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_001, TestSize.Level1)
582 {
583 GTEST_LOG_(INFO) << "GetByElementId_001 start";
584 Connect();
585 int64_t elementId = 10;
586 int32_t windowId = 1;
587 AccessibilityElementInfo targetElementInfo {};
588 EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_TIME_OUT);
589 GTEST_LOG_(INFO) << "GetByElementId_001 end";
590 }
591
592 /**
593 * @tc.number: GetByElementId_002
594 * @tc.name: GetByElementId
595 * @tc.desc: Test function GetByElementId
596 */
597 HWTEST_F(AccessibleAbilityClientImplTest, GetByElementId_002, TestSize.Level1)
598 {
599 GTEST_LOG_(INFO) << "GetByElementId_002 start";
600 int64_t elementId = 10;
601 int32_t windowId = 1;
602 AccessibilityElementInfo targetElementInfo {};
603 EXPECT_EQ(instance_->GetByElementId(elementId, windowId, targetElementInfo), RET_ERR_NO_CONNECTION);
604 GTEST_LOG_(INFO) << "GetByElementId_002 end";
605 }
606
607 /**
608 * @tc.number: ExecuteAction_001
609 * @tc.name: ExecuteAction
610 * @tc.desc: Test function ExecuteAction
611 */
612 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_001, TestSize.Level1)
613 {
614 GTEST_LOG_(INFO) << "ExecuteAction_001 start";
615 Connect();
616 AccessibilityElementInfo elementInfo {};
617 ActionType action = ACCESSIBILITY_ACTION_INVALID;
618 std::map<std::string, std::string> actionArguments {};
619 EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_INVALID_PARAM);
620 GTEST_LOG_(INFO) << "ExecuteAction_001 end";
621 }
622
623 /**
624 * @tc.number: ExecuteAction_002
625 * @tc.name: ExecuteAction
626 * @tc.desc: Test function ExecuteAction
627 */
628 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_002, TestSize.Level1)
629 {
630 GTEST_LOG_(INFO) << "ExecuteAction_002 start";
631 AccessibilityElementInfo elementInfo {};
632 ActionType action = ACCESSIBILITY_ACTION_SELECT;
633 std::map<std::string, std::string> actionArguments {};
634 EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_NO_CONNECTION);
635 GTEST_LOG_(INFO) << "ExecuteAction_002 end";
636 }
637
638 /**
639 * @tc.number: ExecuteAction_003
640 * @tc.name: ExecuteAction
641 * @tc.desc: Test function ExecuteAction
642 */
643 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_003, TestSize.Level1)
644 {
645 GTEST_LOG_(INFO) << "ExecuteAction_003 start";
646 Connect();
647 AccessibilityElementInfo elementInfo {};
648 ActionType action = ACCESSIBILITY_ACTION_SELECT;
649 std::map<std::string, std::string> actionArguments {};
650 EXPECT_EQ(instance_->ExecuteAction(elementInfo, action, actionArguments), RET_ERR_TIME_OUT);
651 GTEST_LOG_(INFO) << "ExecuteAction_003 end";
652 }
653
654 /**
655 * @tc.number: ExecuteAction_004
656 * @tc.name: ExecuteAction
657 * @tc.desc: Test function ExecuteAction
658 */
659 HWTEST_F(AccessibleAbilityClientImplTest, ExecuteAction_004, TestSize.Level1)
660 {
661 GTEST_LOG_(INFO) << "ExecuteAction_004 start";
662 Connect();
663 AccessibilityElementInfo elementInfo {};
664 std::vector<ActionType> actions;
665 actions.push_back(ACCESSIBILITY_ACTION_HOME);
666 actions.push_back(ACCESSIBILITY_ACTION_BACK);
667 actions.push_back(ACCESSIBILITY_ACTION_RECENTTASK);
668 actions.push_back(ACCESSIBILITY_ACTION_NOTIFICATIONCENTER);
669 actions.push_back(ACCESSIBILITY_ACTION_CONTROLCENTER);
670 for (int32_t i = 0; i < actions.size(); i++) {
671 std::map<std::string, std::string> actionArguments {};
672 EXPECT_EQ(instance_->ExecuteAction(elementInfo, actions[i], actionArguments), RET_ERR_TIME_OUT);
673 GTEST_LOG_(INFO) << "ExecuteAction_004 action=" << actions[i];
674 }
675 GTEST_LOG_(INFO) << "ExecuteAction_004 end";
676 }
677
678 /**
679 * @tc.number: GetCursorPosition_001
680 * @tc.name: GetCursorPosition
681 * @tc.desc: Test function GetCursorPosition
682 */
683 HWTEST_F(AccessibleAbilityClientImplTest, GetCursorPosition_001, TestSize.Level1)
684 {
685 GTEST_LOG_(INFO) << "GetCursorPosition_001 start";
686 Connect();
687 AccessibilityElementInfo elementInfo {};
688 int32_t position;
689 EXPECT_EQ(instance_->GetCursorPosition(elementInfo, position), RET_ERR_TIME_OUT);
690 GTEST_LOG_(INFO) << "GetCursorPosition_001 end";
691 }
692
693 /**
694 * @tc.number: ResetAAClient_001
695 * @tc.name: ResetAAClient
696 * @tc.desc: Test function ResetAAClient
697 */
698 HWTEST_F(AccessibleAbilityClientImplTest, ResetAAClient_001, TestSize.Level1)
699 {
700 GTEST_LOG_(INFO) << "ResetAAClient_001 start";
701 EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
702 Connect();
703 wptr<IRemoteObject> remote = nullptr;
704 instance_->ResetAAClient(remote);
705 instance_->SetConnectionState(true);
706 std::vector<AccessibilityWindowInfo> infos;
707 EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
708 GTEST_LOG_(INFO) << "ResetAAClient_001 end";
709 }
710
711 /**
712 * @tc.number: OnKeyPressEvent_001
713 * @tc.name: OnKeyPressEvent
714 * @tc.desc: Test function OnKeyPressEvent
715 */
716 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_001, TestSize.Level1)
717 {
718 GTEST_LOG_(INFO) << "OnKeyPressEvent_001 start";
719 Connect();
720 std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
721 event->SetKeyCode(1);
722 instance_->OnKeyPressEvent(*event, SEQUENCE);
723 EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), 1);
724 GTEST_LOG_(INFO) << "OnKeyPressEvent_001 end";
725 }
726
727 /**
728 * @tc.number: OnKeyPressEvent_002
729 * @tc.name: OnKeyPressEvent
730 * @tc.desc: Test function OnKeyPressEvent
731 */
732 HWTEST_F(AccessibleAbilityClientImplTest, OnKeyPressEvent_002, TestSize.Level1)
733 {
734 GTEST_LOG_(INFO) << "OnKeyPressEvent_002 start";
735 std::shared_ptr<MMI::KeyEvent> event = MMI::KeyEvent::Create();
736 event->SetKeyCode(1);
737 instance_->OnKeyPressEvent(*event, SEQUENCE);
738 EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestKeyPressEvent(), INVALID_ID);
739 GTEST_LOG_(INFO) << "OnKeyPressEvent_002 end";
740 }
741
742 /**
743 * @tc.number: GetWindows_001
744 * @tc.name: GetWindows
745 * @tc.desc: Test function GetWindows
746 */
747 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_001, TestSize.Level1)
748 {
749 GTEST_LOG_(INFO) << "GetWindows_001 start";
750 EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
751 Connect();
752 std::vector<AccessibilityWindowInfo> infos;
753 EXPECT_EQ(instance_->GetWindows(infos), RET_OK);
754 GTEST_LOG_(INFO) << "GetWindows_001 end";
755 }
756
757 /**
758 * @tc.number: GetWindows_002
759 * @tc.name: GetWindows
760 * @tc.desc: Test function GetWindows
761 */
762 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_002, TestSize.Level1)
763 {
764 GTEST_LOG_(INFO) << "GetWindows_002 start";
765 EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
766 Connect();
767 std::vector<AccessibilityWindowInfo> infos;
768 EXPECT_EQ(instance_->GetWindows(0, infos), RET_OK);
769 GTEST_LOG_(INFO) << "GetWindows_002 end";
770 }
771
772 /**
773 * @tc.number: GetWindows_003
774 * @tc.name: GetWindows
775 * @tc.desc: Test function GetWindows
776 */
777 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_003, TestSize.Level1)
778 {
779 GTEST_LOG_(INFO) << "GetWindows_003 start";
780 std::vector<AccessibilityWindowInfo> infos;
781 EXPECT_EQ(instance_->GetWindows(infos), RET_ERR_NO_CONNECTION);
782 GTEST_LOG_(INFO) << "GetWindows_003 end";
783 }
784
785 /**
786 * @tc.number: GetWindows_004
787 * @tc.name: GetWindows
788 * @tc.desc: Test function GetWindows
789 */
790 HWTEST_F(AccessibleAbilityClientImplTest, GetWindows_004, TestSize.Level1)
791 {
792 GTEST_LOG_(INFO) << "GetWindows_004 start";
793 std::vector<AccessibilityWindowInfo> infos;
794 EXPECT_EQ(instance_->GetWindows(0, infos), RET_ERR_NO_CONNECTION);
795 GTEST_LOG_(INFO) << "GetWindows_004 end";
796 }
797
798 /**
799 * @tc.number: GetChildElementInfo_001
800 * @tc.name: GetChildElementInfo
801 * @tc.desc: Test function GetChildElementInfo
802 */
803 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_001, TestSize.Level1)
804 {
805 GTEST_LOG_(INFO) << "GetChildElementInfo_001 start";
806 AccessibilityElementInfo parent;
807 AccessibilityElementInfo child;
808 EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_NO_CONNECTION);
809 GTEST_LOG_(INFO) << "GetChildElementInfo_001 end";
810 }
811
812 /**
813 * @tc.number: GetChildElementInfo_002
814 * @tc.name: GetChildElementInfo
815 * @tc.desc: Test function GetChildElementInfo
816 */
817 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_002, TestSize.Level1)
818 {
819 GTEST_LOG_(INFO) << "GetChildElementInfo_002 start";
820 Connect();
821 AccessibilityElementInfo parent;
822 AccessibilityElementInfo child;
823 EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_INVALID_PARAM);
824 GTEST_LOG_(INFO) << "GetChildElementInfo_002 end";
825 }
826
827 /**
828 * @tc.number: GetChildElementInfo_003
829 * @tc.name: GetChildElementInfo
830 * @tc.desc: Test function GetChildElementInfo
831 */
832 HWTEST_F(AccessibleAbilityClientImplTest, GetChildElementInfo_003, TestSize.Level1)
833 {
834 GTEST_LOG_(INFO) << "GetChildElementInfo_003 start";
835 Connect();
836
837 AccessibilityElementInfo parent;
838 parent.AddChild(1);
839 AccessibilityElementInfo child;
840 EXPECT_EQ(instance_->GetChildElementInfo(0, parent, child), RET_ERR_TIME_OUT);
841 GTEST_LOG_(INFO) << "GetChildElementInfo_003 end";
842 }
843
844 /**
845 * @tc.number: GetChildren_001
846 * @tc.name: GetChildren
847 * @tc.desc: Test function GetChildren
848 */
849 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_001, TestSize.Level1)
850 {
851 GTEST_LOG_(INFO) << "GetChildren_001 start";
852 AccessibilityElementInfo parent;
853 std::vector<AccessibilityElementInfo> children;
854 EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_NO_CONNECTION);
855 GTEST_LOG_(INFO) << "GetChildren_001 end";
856 }
857
858 /**
859 * @tc.number: GetChildren_002
860 * @tc.name: GetChildren
861 * @tc.desc: Test function GetChildren
862 */
863 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_002, TestSize.Level1)
864 {
865 GTEST_LOG_(INFO) << "GetChildren_002 start";
866 Connect();
867
868 AccessibilityElementInfo parent;
869 parent.AddChild(INVALID_CHILD_ID);
870 std::vector<AccessibilityElementInfo> children;
871 EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_INVALID_PARAM);
872 GTEST_LOG_(INFO) << "GetChildren_002 end";
873 }
874
875 /**
876 * @tc.number: GetChildren_003
877 * @tc.name: GetChildren
878 * @tc.desc: Test function GetChildren
879 */
880 HWTEST_F(AccessibleAbilityClientImplTest, GetChildren_003, TestSize.Level1)
881 {
882 GTEST_LOG_(INFO) << "GetChildren_003 start";
883 Connect();
884
885 AccessibilityElementInfo parent;
886 parent.AddChild(1);
887 std::vector<AccessibilityElementInfo> children;
888 EXPECT_EQ(instance_->GetChildren(parent, children), RET_ERR_TIME_OUT);
889 GTEST_LOG_(INFO) << "GetChildren_003 end";
890 }
891
892 /**
893 * @tc.number: SetTargetBundleName_001
894 * @tc.name: SetTargetBundleName
895 * @tc.desc: Test function SetTargetBundleName
896 */
897 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_001, TestSize.Level1)
898 {
899 GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
900 std::vector<std::string> targetBundleNames;
901 EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_ERR_NO_CONNECTION);
902 GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
903 }
904
905 /**
906 * @tc.number: SetTargetBundleName_002
907 * @tc.name: SetTargetBundleName
908 * @tc.desc: Test function SetTargetBundleName
909 */
910 HWTEST_F(AccessibleAbilityClientImplTest, SetTargetBundleName_002, TestSize.Level1)
911 {
912 GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
913 EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
914 Connect();
915 std::vector<std::string> targetBundleNames;
916 EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
917 GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
918 }
919
920 /**
921 * @tc.number: GetWindow_001
922 * @tc.name: GetWindow
923 * @tc.desc: Test function GetWindow
924 */
925 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_001, TestSize.Level1)
926 {
927 GTEST_LOG_(INFO) << "GetWindow_001 start";
928 AccessibilityWindowInfo windowInfo;
929 EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_ERR_NO_CONNECTION);
930 GTEST_LOG_(INFO) << "GetWindow_001 end";
931 }
932
933 /**
934 * @tc.number: GetWindow_002
935 * @tc.name: GetWindow
936 * @tc.desc: Test function GetWindow
937 */
938 HWTEST_F(AccessibleAbilityClientImplTest, GetWindow_002, TestSize.Level1)
939 {
940 GTEST_LOG_(INFO) << "GetWindow_002 start";
941 EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
942 Connect();
943 AccessibilityWindowInfo windowInfo;
944 EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
945 GTEST_LOG_(INFO) << "GetWindow_002 end";
946 }
947
948 /**
949 * @tc.number: NotifyServiceDied_001
950 * @tc.name: NotifyServiceDied
951 * @tc.desc: Test function NotifyServiceDied
952 */
953 HWTEST_F(AccessibleAbilityClientImplTest, NotifyServiceDied_001, TestSize.Level1)
954 {
955 GTEST_LOG_(INFO) << "NotifyServiceDied_001 start";
956 Connect();
957 wptr<IRemoteObject> remote = nullptr;
958 instance_->NotifyServiceDied(remote);
959 EXPECT_EQ(AccessibilityAbilityHelper::GetInstance().GetTestChannelId(), static_cast<int>(CHANNEL_ID));
960 GTEST_LOG_(INFO) << "NotifyServiceDied_001 end";
961 }
962
963 /**
964 * @tc.number: GetRootByWindowBatch_001
965 * @tc.name: GetRootByWindowBatch
966 * @tc.desc: Test function GetRootByWindowBatch
967 */
968 HWTEST_F(AccessibleAbilityClientImplTest, GetRootByWindowBatch_001, TestSize.Level1)
969 {
970 GTEST_LOG_(INFO) << "GetRootByWindowBatch_001 start";
971 Connect();
972 std::vector<AccessibilityElementInfo> info;
973 AccessibilityWindowInfo windowInfo {};
974 EXPECT_EQ(instance_->GetRootByWindowBatch(windowInfo, info, true), RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE);
975 GTEST_LOG_(INFO) << "GetRootByWindowBatch_001 end";
976 }
977
978 /**
979 * @tc.number: GetRootBatch_001
980 * @tc.name: GetRootBatch
981 * @tc.desc: Test function GetRootBatch
982 */
983 HWTEST_F(AccessibleAbilityClientImplTest, GetRootBatch_001, TestSize.Level1)
984 {
985 GTEST_LOG_(INFO) << "GetRootBatch_001 start";
986 Connect();
987 std::vector<AccessibilityElementInfo> info;
988 instance_->SetCacheMode(0);
989 EXPECT_EQ(instance_->GetRootBatch(info), RET_ERR_TIME_OUT);
990 GTEST_LOG_(INFO) << "GetRootBatch_001 end";
991 }
992
993 /**
994 * @tc.number: AddCacheByWMS_001
995 * @tc.name: AddCacheByWMS
996 * @tc.desc: Test function AddCacheByWMS
997 */
998 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByWMS_001, TestSize.Level1)
999 {
1000 GTEST_LOG_(INFO) << "AddCacheByWMS_001 start";
1001 AccessibilityElementInfo elementInfo;
1002 elementInfo.SetAccessibilityId(ELEMENT_ID);
1003 std::vector<AccessibilityElementInfo> info;
1004 info.push_back(elementInfo);
1005 instance_->AddCacheByWMS(WINDOW_ID, ELEMENT_ID, info);
1006 std::vector<AccessibilityElementInfo> result;
1007 EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_OK);
1008 EXPECT_EQ(result.size(), 1);
1009 GTEST_LOG_(INFO) << "AddCacheByWMS_001 end";
1010 }
1011
1012 /**
1013 * @tc.number: AddCacheByWMS_002
1014 * @tc.name: AddCacheByWMS
1015 * @tc.desc: Test function AddCacheByWMS
1016 */
1017 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByWMS_002, TestSize.Level1)
1018 {
1019 GTEST_LOG_(INFO) << "AddCacheByWMS_002 start";
1020 AccessibilityElementInfo elementInfo;
1021 elementInfo.SetAccessibilityId(ELEMENT_ID);
1022 std::vector<AccessibilityElementInfo> info;
1023 info.push_back(elementInfo);
1024 instance_->AddCacheByWMS(WINDOW_ID, ELEMENT_ID, info);
1025 std::vector<AccessibilityElementInfo> result;
1026 EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_OK);
1027 EXPECT_EQ(result.size(), 1);
1028
1029 AccessibilityEventInfo eventInfo;
1030 eventInfo.SetWindowId(WINDOW_ID);
1031 eventInfo.SetEventType(TYPE_VIEW_TEXT_UPDATE_EVENT);
1032 instance_->RemoveCacheData(eventInfo);
1033 EXPECT_EQ(instance_->GetElementInfoFromCache(WINDOW_ID, ELEMENT_ID, result), RET_ERR_FAILED);
1034 EXPECT_EQ(result.size(), 0);
1035 GTEST_LOG_(INFO) << "AddCacheByWMS_002 end";
1036 }
1037
1038 /**
1039 * @tc.number: AddCacheByAce_001
1040 * @tc.name: AddCacheByAce
1041 * @tc.desc: Test function AddCacheByAce
1042 */
1043 HWTEST_F(AccessibleAbilityClientImplTest, AddCacheByAce_001, TestSize.Level1)
1044 {
1045 GTEST_LOG_(INFO) << "AddCacheByAce_001 start";
1046 AccessibilityElementInfo elementInfo;
1047 elementInfo.SetAccessibilityId(ELEMENT_ID);
1048 std::vector<AccessibilityElementInfo> info;
1049 info.push_back(elementInfo);
1050 instance_->AddCacheByAce(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 GTEST_LOG_(INFO) << "AddCacheByAce_001 end";
1055 }
1056
1057 /**
1058 * @tc.number: GetByContent_003
1059 * @tc.name: GetByContent
1060 * @tc.desc: Test function GetByContent.
1061 */
1062 HWTEST_F(AccessibleAbilityClientImplTest, GetByContent_003, TestSize.Level1)
1063 {
1064 GTEST_LOG_(INFO) << "GetByContent_003 start";
1065 Connect();
1066 AccessibilityElementInfo elementInfo {};
1067 std::vector<AccessibilityElementInfo> infos;
1068 EXPECT_EQ(instance_->GetByContent(elementInfo, "", infos), RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE);
1069 GTEST_LOG_(INFO) << "GetByContent_003 end";
1070 }
1071 } // namespace Accessibility
1072 } // namespace OHOS