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 <memory>
18 #include "accessibility_element_operator_callback_impl.h"
19 #include "accessibility_system_ability_client_impl.h"
20 #include "mock_accessibility_element_operator.h"
21 #include "mock_accessibility_element_operator_callback_impl.h"
22
23 using namespace testing;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace Accessibility {
28 namespace {
29 const std::string TEST = "test";
30 constexpr int64_t ELEMENT_ID = 1;
31 constexpr int32_t REQUEST_ID = 1;
32 constexpr int32_t REQUEST_ID_2 = 2;
33 constexpr int32_t MODE = 0;
34 constexpr int32_t FOCUS_TYPE = 1;
35 constexpr int32_t DIRECTION = 1;
36 constexpr int32_t ACTION = 1;
37 constexpr int32_t REQUEST_ID_MASK_BIT = 16;
38 } // namespace
39
40 class AccessibilityElementOperatorImplUnitTest : public ::testing::Test {
41 public:
42 sptr<AccessibilityElementOperatorImpl> mockStub_ = nullptr;
AccessibilityElementOperatorImplUnitTest()43 AccessibilityElementOperatorImplUnitTest()
44 {}
~AccessibilityElementOperatorImplUnitTest()45 ~AccessibilityElementOperatorImplUnitTest()
46 {}
47 int32_t windowID_ = 1;
48 std::shared_ptr<MockAccessibilityElementOperator> operation_ = nullptr;
49 std::shared_ptr<AccessibilitySystemAbilityClientImpl> asac_ = nullptr;
SetUpTestCase()50 static void SetUpTestCase()
51 {
52 GTEST_LOG_(INFO) << "AccessibilityElementOperatorImplUnitTest Start";
53 }
TearDownTestCase()54 static void TearDownTestCase()
55 {
56 GTEST_LOG_(INFO) << "AccessibilityElementOperatorImplUnitTest End";
57 }
SetUp()58 void SetUp()
59 {
60 GTEST_LOG_(INFO) << "AccessibilityElementOperatorImplUnitTest SetUp() Start";
61 operation_ = std::make_shared<MockAccessibilityElementOperator>();
62 asac_ = std::make_shared<AccessibilitySystemAbilityClientImpl>();
63 mockStub_ = new AccessibilityElementOperatorImpl(windowID_, operation_, *asac_);
64 GTEST_LOG_(INFO) << "AccessibilityElementOperatorImplUnitTest SetUp() End";
65 };
TearDown()66 void TearDown()
67 {
68 GTEST_LOG_(INFO) << "AccessibilityElementOperatorImplUnitTest TearDown()";
69 mockStub_ = nullptr;
70 }
71
72 int32_t CompositeId(int32_t requestId);
73 };
74
CompositeId(int32_t requestId)75 int32_t AccessibilityElementOperatorImplUnitTest::CompositeId(int32_t requestId)
76 {
77 uint32_t compositionRequestId = static_cast<uint32_t>(requestId) |
78 (static_cast<uint32_t>(windowID_) << REQUEST_ID_MASK_BIT);
79 return static_cast<int32_t>(compositionRequestId);
80 }
81
82 /**
83 * @tc.number: SearchElementInfoByAccessibilityId_001
84 * @tc.name: SearchElementInfoByAccessibilityId
85 * @tc.desc: Test function SearchElementInfoByAccessibilityId
86 */
87 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SearchElementInfoByAccessibilityId_001, TestSize.Level1)
88 {
89 GTEST_LOG_(INFO) << "SearchElementInfoByAccessibilityId_001 start";
90 if (!mockStub_) {
91 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
92 return;
93 }
94 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
95 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
96 EXPECT_CALL(*operation_, SearchElementInfoByAccessibilityId(_, _, _, _)).Times(1);
97 mockStub_->SearchElementInfoByAccessibilityId(ELEMENT_ID, REQUEST_ID, elementOperator, MODE);
98 GTEST_LOG_(INFO) << "SearchElementInfoByAccessibilityId_001 end";
99 }
100
101 /**
102 * @tc.number: SearchElementInfosByText_001
103 * @tc.name: SearchElementInfosByText
104 * @tc.desc: Test function SearchElementInfosByText
105 */
106 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SearchElementInfosByText_001, TestSize.Level1)
107 {
108 GTEST_LOG_(INFO) << "SearchElementInfosByText_001 start";
109 if (!mockStub_) {
110 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
111 return;
112 }
113
114 EXPECT_CALL(*operation_, SearchElementInfosByText(_, _, _, _)).Times(1);
115 mockStub_->SearchElementInfosByText(ELEMENT_ID, TEST, REQUEST_ID, nullptr);
116 GTEST_LOG_(INFO) << "SearchElementInfosByText_001 end";
117 }
118
119 /**
120 * @tc.number: FindFocusedElementInfo_001
121 * @tc.name: FindFocusedElementInfo
122 * @tc.desc: Test function FindFocusedElementInfo
123 */
124 HWTEST_F(AccessibilityElementOperatorImplUnitTest, FindFocusedElementInfo_001, TestSize.Level1)
125 {
126 GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 start";
127 if (!mockStub_) {
128 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
129 return;
130 }
131
132 EXPECT_CALL(*operation_, FindFocusedElementInfo(_, _, _, _)).Times(1);
133 mockStub_->FindFocusedElementInfo(ELEMENT_ID, FOCUS_TYPE, REQUEST_ID, nullptr);
134 GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 end";
135 }
136
137 /**
138 * @tc.number: FocusMoveSearch_001
139 * @tc.name: FocusMoveSearch
140 * @tc.desc: Test function FocusMoveSearch
141 */
142 HWTEST_F(AccessibilityElementOperatorImplUnitTest, FocusMoveSearch_001, TestSize.Level1)
143 {
144 GTEST_LOG_(INFO) << "FocusMoveSearch_001 start";
145 if (!mockStub_) {
146 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
147 return;
148 }
149
150 EXPECT_CALL(*operation_, FocusMoveSearch(_, _, _, _)).Times(1);
151 mockStub_->FocusMoveSearch(ELEMENT_ID, DIRECTION, REQUEST_ID, nullptr);
152 GTEST_LOG_(INFO) << "FocusMoveSearch_001 end";
153 }
154
155 /**
156 * @tc.number: ExecuteAction_001
157 * @tc.name: ExecuteAction
158 * @tc.desc: Test function ExecuteAction
159 */
160 HWTEST_F(AccessibilityElementOperatorImplUnitTest, ExecuteAction_001, TestSize.Level1)
161 {
162 GTEST_LOG_(INFO) << "ExecuteAction_001 start";
163 if (!mockStub_) {
164 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
165 return;
166 }
167
168 EXPECT_CALL(*operation_, ExecuteAction(_, _, _, _, _)).Times(1);
169 std::map<std::string, std::string> actionArguments;
170 mockStub_->ExecuteAction(ELEMENT_ID, ACTION, actionArguments, REQUEST_ID, nullptr);
171 GTEST_LOG_(INFO) << "ExecuteAction_001 end";
172 }
173
174 /**
175 * @tc.number: ClearFocus_001
176 * @tc.name: ClearFocus
177 * @tc.desc: Test function ClearFocus
178 */
179 HWTEST_F(AccessibilityElementOperatorImplUnitTest, ClearFocus_001, TestSize.Level1)
180 {
181 GTEST_LOG_(INFO) << "ClearFocus_001 start";
182 if (!mockStub_) {
183 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
184 return;
185 }
186
187 EXPECT_CALL(*operation_, ClearFocus()).Times(1);
188 mockStub_->ClearFocus();
189 GTEST_LOG_(INFO) << "ClearFocus_001 end";
190 }
191
192 /**
193 * @tc.number: OutsideTouch_001
194 * @tc.name: OutsideTouch
195 * @tc.desc: Test function OutsideTouch
196 */
197 HWTEST_F(AccessibilityElementOperatorImplUnitTest, OutsideTouch_001, TestSize.Level1)
198 {
199 GTEST_LOG_(INFO) << "OutsideTouch_001 start";
200 if (!mockStub_) {
201 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
202 return;
203 }
204
205 EXPECT_CALL(*operation_, OutsideTouch()).Times(1);
206 mockStub_->OutsideTouch();
207 GTEST_LOG_(INFO) << "OutsideTouch_001 end";
208 }
209
210 /**
211 * @tc.number: GetWindowId
212 * @tc.name: GetWindowId
213 * @tc.desc: Test function GetWindowId
214 */
215 HWTEST_F(AccessibilityElementOperatorImplUnitTest, GetWindowId, TestSize.Level1)
216 {
217 GTEST_LOG_(INFO) << "GetWindowId start";
218 if (!mockStub_) {
219 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
220 return;
221 }
222 EXPECT_EQ(1, mockStub_->GetWindowId());
223 GTEST_LOG_(INFO) << "GetWindowId end";
224 }
225
226 /**
227 * @tc.number: SetSearchElementInfoByAccessibilityIdResult_001
228 * @tc.name: SetSearchElementInfoByAccessibilityIdResult
229 * @tc.desc: Test function SetSearchElementInfoByAccessibilityIdResult
230 */
231 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetSearchElementInfoByAccessibilityIdResult_001, TestSize.Level1)
232 {
233 GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_001 start";
234 if (!mockStub_) {
235 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
236 return;
237 }
238
239 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
240 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
241 EXPECT_CALL(*elementOperator, SetSearchElementInfoByAccessibilityIdResult(_, _)).Times(0);
242 std::list<AccessibilityElementInfo> infos;
243 AccessibilityElementInfo info {};
244 infos.push_back(info);
245 mockStub_->SetSearchElementInfoByAccessibilityIdResult(infos, REQUEST_ID);
246 GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_001 end";
247 }
248
249 /**
250 * @tc.number: SetSearchElementInfoByAccessibilityIdResult_002
251 * @tc.name: SetSearchElementInfoByAccessibilityIdResult
252 * @tc.desc: Test function SetSearchElementInfoByAccessibilityIdResult
253 */
254 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetSearchElementInfoByAccessibilityIdResult_002, TestSize.Level1)
255 {
256 GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_002 start";
257 if (!mockStub_) {
258 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
259 return;
260 }
261
262 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
263 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
264 EXPECT_CALL(*elementOperator, SetSearchElementInfoByAccessibilityIdResult(_, _)).Times(1);
265 mockStub_->SearchElementInfoByAccessibilityId(ELEMENT_ID, REQUEST_ID_2, elementOperator, MODE, false);
266 std::list<AccessibilityElementInfo> infos;
267 AccessibilityElementInfo info {};
268 infos.push_back(info);
269 mockStub_->SetSearchElementInfoByAccessibilityIdResult(infos, REQUEST_ID_2);
270 GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_002 end";
271 }
272
273 /**
274 * @tc.number: SetSearchElementInfoByTextResult_001
275 * @tc.name: SetSearchElementInfoByTextResult
276 * @tc.desc: Test function SetSearchElementInfoByTextResult
277 */
278 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetSearchElementInfoByTextResult_001, TestSize.Level1)
279 {
280 GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 start";
281 if (!mockStub_) {
282 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
283 return;
284 }
285
286 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
287 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
288 EXPECT_CALL(*elementOperator, SetSearchElementInfoByTextResult(_, _)).Times(0);
289 std::list<AccessibilityElementInfo> infos;
290 AccessibilityElementInfo info {};
291 infos.push_back(info);
292 mockStub_->SetSearchElementInfoByTextResult(infos, REQUEST_ID);
293 GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 end";
294 }
295
296 /**
297 * @tc.number: SetSearchElementInfoByTextResult_002
298 * @tc.name: SetSearchElementInfoByTextResult
299 * @tc.desc: Test function SetSearchElementInfoByTextResult
300 */
301 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetSearchElementInfoByTextResult_002, TestSize.Level1)
302 {
303 GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_002 start";
304 if (!mockStub_) {
305 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
306 return;
307 }
308 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
309 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
310 EXPECT_CALL(*elementOperator, SetSearchElementInfoByTextResult(_, _)).Times(1);
311 mockStub_->SearchElementInfosByText(ELEMENT_ID, TEST, REQUEST_ID_2, elementOperator);
312 std::list<AccessibilityElementInfo> infos;
313 AccessibilityElementInfo info {};
314 infos.push_back(info);
315 mockStub_->SetSearchElementInfoByTextResult(infos, REQUEST_ID_2);
316 GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_002 end";
317 }
318
319 /**
320 * @tc.number: SetFindFocusedElementInfoResult_001
321 * @tc.name: SetFindFocusedElementInfoResult
322 * @tc.desc: Test function SetFindFocusedElementInfoResult
323 */
324 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetFindFocusedElementInfoResult_001, TestSize.Level1)
325 {
326 GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 start";
327 if (!mockStub_) {
328 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
329 return;
330 }
331
332 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
333 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
334 EXPECT_CALL(*elementOperator, SetFindFocusedElementInfoResult(_, _)).Times(0);
335 AccessibilityElementInfo info {};
336 mockStub_->SetFindFocusedElementInfoResult(info, REQUEST_ID);
337 GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 end";
338 }
339
340 /**
341 * @tc.number: SetFindFocusedElementInfoResult_002
342 * @tc.name: SetFindFocusedElementInfoResult
343 * @tc.desc: Test function SetFindFocusedElementInfoResult
344 */
345 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetFindFocusedElementInfoResult_002, TestSize.Level1)
346 {
347 GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_002 start";
348 if (!mockStub_) {
349 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
350 return;
351 }
352
353 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
354 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
355 EXPECT_CALL(*elementOperator, SetFindFocusedElementInfoResult(_, _)).Times(1);
356 mockStub_->FindFocusedElementInfo(ELEMENT_ID, FOCUS_TYPE, REQUEST_ID_2, elementOperator);
357 AccessibilityElementInfo info {};
358 mockStub_->SetFindFocusedElementInfoResult(info, REQUEST_ID_2);
359 GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_002 end";
360 }
361
362 /**
363 * @tc.number: SetFocusMoveSearchResult_001
364 * @tc.name: SetFocusMoveSearchResult
365 * @tc.desc: Test function SetFocusMoveSearchResult
366 */
367 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetFocusMoveSearchResult_001, TestSize.Level1)
368 {
369 GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 start";
370 if (!mockStub_) {
371 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
372 return;
373 }
374
375 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
376 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
377 EXPECT_CALL(*elementOperator, SetFocusMoveSearchResult(_, _)).Times(0);
378 AccessibilityElementInfo info {};
379 mockStub_->SetFocusMoveSearchResult(info, REQUEST_ID);
380 GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 end";
381 }
382
383 /**
384 * @tc.number: SetFocusMoveSearchResult_002
385 * @tc.name: SetFocusMoveSearchResult
386 * @tc.desc: Test function SetFocusMoveSearchResult
387 */
388 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetFocusMoveSearchResult_002, TestSize.Level1)
389 {
390 GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_002 start";
391 if (!mockStub_) {
392 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
393 return;
394 }
395
396 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
397 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
398 EXPECT_CALL(*elementOperator, SetFocusMoveSearchResult(_, _)).Times(1);
399 mockStub_->FocusMoveSearch(ELEMENT_ID, DIRECTION, REQUEST_ID_2, elementOperator);
400 AccessibilityElementInfo info {};
401 mockStub_->SetFocusMoveSearchResult(info, REQUEST_ID_2);
402 GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_002 end";
403 }
404
405 /**
406 * @tc.number: SetExecuteActionResult_001
407 * @tc.name: SetExecuteActionResult
408 * @tc.desc: Test function SetExecuteActionResult
409 */
410 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetExecuteActionResult_001, TestSize.Level1)
411 {
412 GTEST_LOG_(INFO) << "SetExecuteActionResult_001 start";
413 if (!mockStub_) {
414 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
415 return;
416 }
417 mockStub_->SetExecuteActionResult(true, REQUEST_ID);
418 EXPECT_NE(mockStub_.GetRefPtr(), nullptr);
419 GTEST_LOG_(INFO) << "SetExecuteActionResult_001 end";
420 }
421
422 /**
423 * @tc.number: SetExecuteActionResult_002
424 * @tc.name: SetExecuteActionResult
425 * @tc.desc: Test function SetExecuteActionResult
426 */
427 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetExecuteActionResult_002, TestSize.Level1)
428 {
429 GTEST_LOG_(INFO) << "SetExecuteActionResult_002 start";
430 if (!mockStub_) {
431 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
432 return;
433 }
434 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
435 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
436 std::map<std::string, std::string> actionArguments;
437 mockStub_->ExecuteAction(ELEMENT_ID, ACTION, actionArguments, REQUEST_ID_2, elementOperator);
438 mockStub_->SetExecuteActionResult(true, CompositeId(REQUEST_ID_2));
439 EXPECT_NE(mockStub_.GetRefPtr(), nullptr);
440 GTEST_LOG_(INFO) << "SetExecuteActionResult_002 end";
441 }
442
443 /**
444 * @tc.number: GetCursorPosition_001
445 * @tc.name: GetCursorPosition
446 * @tc.desc: Test function GetCursorPosition
447 */
448 HWTEST_F(AccessibilityElementOperatorImplUnitTest, GetCursorPosition_001, TestSize.Level1)
449 {
450 GTEST_LOG_(INFO) << "GetCursorPosition_001 start";
451 if (!mockStub_) {
452 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
453 return;
454 }
455
456 EXPECT_CALL(*operation_, GetCursorPosition(_, _, _)).Times(1);
457 mockStub_->GetCursorPosition(ELEMENT_ID, REQUEST_ID, nullptr);
458 GTEST_LOG_(INFO) << "GetCursorPosition_001 end";
459 }
460
461 /**
462 * @tc.number: SetChildTreeIdAndWinId_001
463 * @tc.name: SetChildTreeIdAndWinId
464 * @tc.desc: Test function SetChildTreeIdAndWinId
465 */
466 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetChildTreeIdAndWinId_001, TestSize.Level1)
467 {
468 GTEST_LOG_(INFO) << "SetChildTreeIdAndWinId_001 start";
469 if (!mockStub_) {
470 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
471 return;
472 }
473 int64_t nodeId = 1;
474 int32_t childTreeId = 1;
475 int32_t childWindowId = 1;
476 EXPECT_CALL(*operation_, SetChildTreeIdAndWinId(_, _, _)).Times(1);
477 mockStub_->SetChildTreeIdAndWinId(nodeId, childTreeId, childWindowId);
478 GTEST_LOG_(INFO) << "SetChildTreeIdAndWinId_001 end";
479 }
480
481 /**
482 * @tc.number: SetFiltering_001
483 * @tc.name: SetFiltering
484 * @tc.desc: Test function SetFiltering
485 */
486 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetFiltering_001, TestSize.Level1)
487 {
488 GTEST_LOG_(INFO) << "SetFiltering_001 start";
489 if (!mockStub_) {
490 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
491 return;
492 }
493 std::vector<AccessibilityElementInfo> filterInfos;
494 mockStub_->SetFiltering(filterInfos);
495 GTEST_LOG_(INFO) << "SetFiltering_001 end";
496 }
497
498 /**
499 * @tc.number: SetCursorPositionResult_001
500 * @tc.name: SetCursorPositionResult
501 * @tc.desc: Test function SetCursorPositionResult
502 */
503 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetCursorPositionResult_001, TestSize.Level1)
504 {
505 GTEST_LOG_(INFO) << "SetCursorPositionResult_001 start";
506 if (!mockStub_) {
507 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
508 return;
509 }
510 int32_t cursorPosition = 1;
511 mockStub_->SetCursorPositionResult(cursorPosition, REQUEST_ID);
512 EXPECT_NE(mockStub_.GetRefPtr(), nullptr);
513 GTEST_LOG_(INFO) << "SetCursorPositionResult_001 end";
514 }
515
516 /**
517 * @tc.number: SetCursorPositionResult_002
518 * @tc.name: SetCursorPositionResult
519 * @tc.desc: Test function SetCursorPositionResult
520 */
521 HWTEST_F(AccessibilityElementOperatorImplUnitTest, SetCursorPositionResult_002, TestSize.Level1)
522 {
523 GTEST_LOG_(INFO) << "SetCursorPositionResult_002 start";
524 if (!mockStub_) {
525 GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorImpl mockStub_";
526 return;
527 }
528 sptr<MockAccessibilityElementOperatorCallbackImpl> elementOperator =
529 new(std::nothrow) MockAccessibilityElementOperatorCallbackImpl();
530 int32_t cursorPosition = 1;
531 mockStub_->GetCursorPosition(ELEMENT_ID, REQUEST_ID, elementOperator);
532 mockStub_->SetCursorPositionResult(cursorPosition, CompositeId(REQUEST_ID_2));
533 EXPECT_NE(mockStub_.GetRefPtr(), nullptr);
534 GTEST_LOG_(INFO) << "SetCursorPositionResult_002 end";
535 }
536 } // namespace Accessibility
537 } // namespace OHOS