• 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 "accessible_ability_channel_client.h"
18 #include "mock_accessible_ability_channel_proxy.h"
19 #include "mock_accessible_ability_channel_stub.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Accessibility {
26 namespace {
27     const std::string TEST = "test";
28     constexpr int32_t SEQUENCE = 1;
29     constexpr int32_t ACCESSIBILITY_WINDOW_ID = 1;
30     constexpr int64_t ELEMENT_ID = 1;
31     constexpr int32_t MODE = 1;
32     constexpr int32_t CHANNEL_ID = 1;
33     constexpr int32_t TREE_ID = 1;
34 } // namespace
35 
36 class AccessibleAbilityChannelClientTest : public ::testing::Test {
37 public:
AccessibleAbilityChannelClientTest()38     AccessibleAbilityChannelClientTest()
39     {}
~AccessibleAbilityChannelClientTest()40     ~AccessibleAbilityChannelClientTest()
41     {}
42 
43     sptr<MockAccessibleAbilityChannelStub> stub_ = nullptr;
44     sptr<IAccessibleAbilityChannel> channel_ = nullptr;
45     std::shared_ptr<AccessibleAbilityChannelClient> instance_ = nullptr;
46 
SetUpTestCase()47     static void SetUpTestCase()
48     {
49         GTEST_LOG_(INFO) << "AccessibleAbilityChannelClientTest Start";
50     }
TearDownTestCase()51     static void TearDownTestCase()
52     {
53         GTEST_LOG_(INFO) << "AccessibleAbilityChannelClientTest End";
54     }
SetUp()55     void SetUp()
56     {
57         GTEST_LOG_(INFO) << "AccessibleAbilityChannelClientTest SetUp()";
58         stub_ = new MockAccessibleAbilityChannelStub();
59         ASSERT_TRUE(stub_);
60         channel_ = iface_cast<IAccessibleAbilityChannel>(stub_);
61         ASSERT_TRUE(channel_);
62         instance_ = std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, channel_);
63         ASSERT_TRUE(instance_);
64     };
TearDown()65     void TearDown()
66     {
67         GTEST_LOG_(INFO) << "AccessibleAbilityChannelClientTest TearDown()";
68         stub_ = nullptr;
69         channel_ = nullptr;
70         instance_ = nullptr;
71     }
72 };
73 
74 /**
75  * @tc.number: GetRemote_001
76  * @tc.name: GetRemote
77  * @tc.desc: Test function GetRemote
78  */
79 HWTEST_F(AccessibleAbilityChannelClientTest, GetRemote_001, TestSize.Level1)
80 {
81     GTEST_LOG_(INFO) << "GetRemote_001 start";
82     EXPECT_TRUE(instance_->GetRemote());
83     GTEST_LOG_(INFO) << "GetRemote_001 end";
84 }
85 
86 /**
87  * @tc.number: SetOnKeyPressEventResult_001
88  * @tc.name: SetOnKeyPressEventResult
89  * @tc.desc: Test function SetOnKeyPressEventResult
90  */
91 HWTEST_F(AccessibleAbilityChannelClientTest, SetOnKeyPressEventResult, TestSize.Level1)
92 {
93     GTEST_LOG_(INFO) << "SetOnKeyPressEventResult_001 start";
94     if (!instance_) {
95         GTEST_LOG_(INFO) << "Cann't get AccessibleAbilityChannelClient instance_";
96     } else {
97         instance_->SetOnKeyPressEventResult(true, SEQUENCE);
98         EXPECT_NE(instance_.get(), nullptr);
99     }
100     GTEST_LOG_(INFO) << "SetOnKeyPressEventResult_001 end";
101 }
102 
103 /**
104  * @tc.number: FindFocusedElementInfo_001
105  * @tc.name: FindFocusedElementInfo
106  * @tc.desc: Test function FindFocusedElementInfo
107  */
108 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_001, TestSize.Level1)
109 {
110     GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 start";
111     EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
112     AccessibilityElementInfo info {};
113     EXPECT_EQ(instance_->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID,
114         ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_FAILED);
115     GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 end";
116 }
117 
118 /**
119  * @tc.number: FindFocusedElementInfo_002
120  * @tc.name: FindFocusedElementInfo
121  * @tc.desc: Test function FindFocusedElementInfo
122  */
123 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_002, TestSize.Level1)
124 {
125     GTEST_LOG_(INFO) << "FindFocusedElementInfo_002 start";
126     std::shared_ptr<AccessibleAbilityChannelClient> client =
127         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
128     ASSERT_TRUE(client);
129     AccessibilityElementInfo info {};
130     EXPECT_EQ(client->FindFocusedElementInfo(
131         ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_SAMGR);
132     GTEST_LOG_(INFO) << "FindFocusedElementInfo_002 end";
133 }
134 
135 /**
136  * @tc.number: FindFocusedElementInfo_003
137  * @tc.name: FindFocusedElementInfo
138  * @tc.desc: Test function FindFocusedElementInfo
139  */
140 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_003, TestSize.Level1)
141 {
142     GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 start";
143     EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
144     AccessibilityElementInfo info {};
145     EXPECT_EQ(instance_->FindFocusedElementInfo(
146         ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
147     GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 end";
148 }
149 
150 /**
151  * @tc.number: SendSimulateGesture_001
152  * @tc.name: SendSimulateGesture
153  * @tc.desc: Test function SendSimulateGesture
154  */
155 HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_001, TestSize.Level1)
156 {
157     GTEST_LOG_(INFO) << "SendSimulateGesture_001 start";
158     EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
159     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
160     EXPECT_EQ(instance_->SendSimulateGesture(gesturePath), RET_OK);
161     GTEST_LOG_(INFO) << "SendSimulateGesture_001 end";
162 }
163 
164 /**
165  * @tc.number: SendSimulateGesture_002
166  * @tc.name: SendSimulateGesture
167  * @tc.desc: Test function SendSimulateGesture
168  */
169 HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_002, TestSize.Level1)
170 {
171     GTEST_LOG_(INFO) << "SendSimulateGesture_002 start";
172     std::shared_ptr<AccessibleAbilityChannelClient> client =
173         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
174     ASSERT_TRUE(client);
175     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
176     EXPECT_EQ(client->SendSimulateGesture(gesturePath), RET_ERR_SAMGR);
177     GTEST_LOG_(INFO) << "SendSimulateGesture_002 end";
178 }
179 
180 /**
181  * @tc.number: ExecuteAction_001
182  * @tc.name: ExecuteAction
183  * @tc.desc: Test function ExecuteAction
184  */
185 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_001, TestSize.Level1)
186 {
187     GTEST_LOG_(INFO) << "ExecuteAction_001 start";
188     EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
189     std::map<std::string, std::string> actionArguments;
190     EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
191         ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_FAILED);
192     GTEST_LOG_(INFO) << "ExecuteAction_001 end";
193 }
194 
195 /**
196  * @tc.number: ExecuteAction_002
197  * @tc.name: ExecuteAction
198  * @tc.desc: Test function ExecuteAction
199  */
200 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_002, TestSize.Level1)
201 {
202     GTEST_LOG_(INFO) << "ExecuteAction_002 start";
203     std::shared_ptr<AccessibleAbilityChannelClient> client =
204         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
205     ASSERT_TRUE(client);
206     std::map<std::string, std::string> actionArguments;
207     EXPECT_EQ(client->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
208         ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_SAMGR);
209     GTEST_LOG_(INFO) << "ExecuteAction_002 end";
210 }
211 
212 /**
213  * @tc.number: ExecuteAction_003
214  * @tc.name: ExecuteAction
215  * @tc.desc: Test function ExecuteAction
216  */
217 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_003, TestSize.Level1)
218 {
219     GTEST_LOG_(INFO) << "ExecuteAction_003 start";
220     EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
221     std::map<std::string, std::string> actionArguments;
222     EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
223         ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_TIME_OUT);
224     GTEST_LOG_(INFO) << "ExecuteAction_003 end";
225 }
226 
227 /**
228  * @tc.number: GetWindow_001
229  * @tc.name: GetWindow
230  * @tc.desc: Test function GetWindow
231  */
232 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_001, TestSize.Level1)
233 {
234     GTEST_LOG_(INFO) << "GetWindow_001 start";
235     std::shared_ptr<AccessibleAbilityChannelClient> client =
236         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
237     ASSERT_TRUE(client);
238     AccessibilityWindowInfo windowInfo;
239     EXPECT_EQ(client->GetWindow(0, windowInfo), RET_ERR_SAMGR);
240     GTEST_LOG_(INFO) << "GetWindow_001 end";
241 }
242 
243 /**
244  * @tc.number: GetWindow_002
245  * @tc.name: GetWindow
246  * @tc.desc: Test function GetWindow
247  */
248 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_002, TestSize.Level1)
249 {
250     GTEST_LOG_(INFO) << "GetWindow_002 start";
251     EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
252     AccessibilityWindowInfo windowInfo;
253     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
254     GTEST_LOG_(INFO) << "GetWindow_002 end";
255 }
256 
257 /**
258  * @tc.number: GetWindows_001
259  * @tc.name: GetWindows
260  * @tc.desc: Test function GetWindows
261  */
262 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_001, TestSize.Level1)
263 {
264     GTEST_LOG_(INFO) << "GetWindows_001 start";
265     std::shared_ptr<AccessibleAbilityChannelClient> client =
266         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
267     ASSERT_TRUE(client);
268     std::vector<AccessibilityWindowInfo> windowInfo {};
269     EXPECT_EQ(client->GetWindows(windowInfo), RET_ERR_SAMGR);
270     GTEST_LOG_(INFO) << "GetWindows_001 end";
271 }
272 
273 /**
274  * @tc.number: GetWindows_002
275  * @tc.name: GetWindows
276  * @tc.desc: Test function GetWindows
277  */
278 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_002, TestSize.Level1)
279 {
280     GTEST_LOG_(INFO) << "GetWindows_002 start";
281     EXPECT_CALL(*stub_, GetWindows(_, _)).Times(1).WillOnce(Return(RET_OK));
282     std::vector<AccessibilityWindowInfo> windowInfo {};
283     EXPECT_EQ(instance_->GetWindows(windowInfo), RET_OK);
284     GTEST_LOG_(INFO) << "GetWindows_002 end";
285 }
286 
287 /**
288  * @tc.number: GetWindows_003
289  * @tc.name: GetWindows
290  * @tc.desc: Test function GetWindows
291  */
292 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_003, TestSize.Level1)
293 {
294     GTEST_LOG_(INFO) << "GetWindows_003 start";
295     std::shared_ptr<AccessibleAbilityChannelClient> client =
296         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
297     ASSERT_TRUE(client);
298     std::vector<AccessibilityWindowInfo> windowInfo {};
299     EXPECT_EQ(client->GetWindows(0, windowInfo), RET_ERR_SAMGR);
300     GTEST_LOG_(INFO) << "GetWindows_003 end";
301 }
302 
303 /**
304  * @tc.number: GetWindows_004
305  * @tc.name: GetWindows
306  * @tc.desc: Test function GetWindows
307  */
308 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_004, TestSize.Level1)
309 {
310     GTEST_LOG_(INFO) << "GetWindows_004 start";
311     EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _, _)).Times(1).WillOnce(Return(RET_OK));
312     std::vector<AccessibilityWindowInfo> windowInfo {};
313     EXPECT_EQ(instance_->GetWindows(0, windowInfo), RET_OK);
314     GTEST_LOG_(INFO) << "GetWindows_004 end";
315 }
316 
317 /**
318  * @tc.number: SearchElementInfosByText_001
319  * @tc.name: SearchElementInfosByText
320  * @tc.desc: Test function SearchElementInfosByText
321  */
322 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_001, TestSize.Level1)
323 {
324     GTEST_LOG_(INFO) << "SearchElementInfosByText_001 start";
325     std::shared_ptr<AccessibleAbilityChannelClient> client =
326         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
327     ASSERT_TRUE(client);
328     std::vector<AccessibilityElementInfo> infos;
329     EXPECT_EQ(client->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_SAMGR);
330     GTEST_LOG_(INFO) << "SearchElementInfosByText_001 end";
331 }
332 
333 /**
334  * @tc.number: SearchElementInfosByText_002
335  * @tc.name: SearchElementInfosByText
336  * @tc.desc: Test function SearchElementInfosByText
337  */
338 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_002, TestSize.Level1)
339 {
340     GTEST_LOG_(INFO) << "SearchElementInfosByText_002 start";
341     EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
342     std::vector<AccessibilityElementInfo> infos;
343     EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_FAILED);
344     GTEST_LOG_(INFO) << "SearchElementInfosByText_002 end";
345 }
346 
347 /**
348  * @tc.number: SearchElementInfosByText_003
349  * @tc.name: SearchElementInfosByText
350  * @tc.desc: Test function SearchElementInfosByText
351  */
352 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_003, TestSize.Level1)
353 {
354     GTEST_LOG_(INFO) << "SearchElementInfosByText_003 start";
355     EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
356     std::vector<AccessibilityElementInfo> infos;
357     EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_TIME_OUT);
358     GTEST_LOG_(INFO) << "SearchElementInfosByText_003 end";
359 }
360 
361 /**
362  * @tc.number: FocusMoveSearch_001
363  * @tc.name: FocusMoveSearch
364  * @tc.desc: Test function FocusMoveSearch
365  */
366 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_001, TestSize.Level1)
367 {
368     GTEST_LOG_(INFO) << "FocusMoveSearch_001 start";
369     std::shared_ptr<AccessibleAbilityChannelClient> client =
370         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
371     ASSERT_TRUE(client);
372     AccessibilityElementInfo info {};
373     EXPECT_EQ(client->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
374         FocusMoveDirection::DOWN, info), RET_ERR_SAMGR);
375     GTEST_LOG_(INFO) << "FocusMoveSearch_001 end";
376 }
377 
378 /**
379  * @tc.number: FocusMoveSearch_002
380  * @tc.name: FocusMoveSearch
381  * @tc.desc: Test function FocusMoveSearch
382  */
383 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_002, TestSize.Level1)
384 {
385     GTEST_LOG_(INFO) << "FocusMoveSearch_002 start";
386     EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
387     AccessibilityElementInfo info {};
388     EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
389         FocusMoveDirection::DOWN, info), RET_ERR_FAILED);
390     GTEST_LOG_(INFO) << "FocusMoveSearch_002 end";
391 }
392 
393 /**
394  * @tc.number: FocusMoveSearch_003
395  * @tc.name: FocusMoveSearch
396  * @tc.desc: Test function FocusMoveSearch
397  */
398 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_003, TestSize.Level1)
399 {
400     GTEST_LOG_(INFO) << "FocusMoveSearch_003 start";
401     EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
402     AccessibilityElementInfo info {};
403     EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
404         FocusMoveDirection::DOWN, info), RET_ERR_TIME_OUT);
405     GTEST_LOG_(INFO) << "FocusMoveSearch_003 end";
406 }
407 
408 /**
409  * @tc.number: SetTargetBundleName_001
410  * @tc.name: SetTargetBundleName
411  * @tc.desc: Test function SetTargetBundleName
412  */
413 HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_001, TestSize.Level1)
414 {
415     GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
416     std::shared_ptr<AccessibleAbilityChannelClient> client =
417         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
418     ASSERT_TRUE(client);
419     std::vector<std::string> targetBundleNames;
420     EXPECT_EQ(client->SetTargetBundleName(targetBundleNames), RET_ERR_SAMGR);
421     GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
422 }
423 
424 /**
425  * @tc.number: SetTargetBundleName_002
426  * @tc.name: SetTargetBundleName
427  * @tc.desc: Test function SetTargetBundleName
428  */
429 HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_002, TestSize.Level1)
430 {
431     GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
432     EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
433     std::vector<std::string> targetBundleNames;
434     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
435     GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
436 }
437 
438 /**
439  * @tc.number: SearchElementInfosByAccessibilityId_001
440  * @tc.name: SearchElementInfosByAccessibilityId
441  * @tc.desc: Test function SearchElementInfosByAccessibilityId
442  */
443 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_001, TestSize.Level1)
444 {
445     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 start";
446     EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
447     std::vector<AccessibilityElementInfo> infos;
448     EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
449         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_FAILED);
450     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 end";
451 }
452 
453 /**
454  * @tc.number: SearchElementInfosByAccessibilityId_002
455  * @tc.name: SearchElementInfosByAccessibilityId
456  * @tc.desc: Test function SearchElementInfosByAccessibilityId
457  */
458 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_002, TestSize.Level1)
459 {
460     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_002 start";
461     std::shared_ptr<AccessibleAbilityChannelClient> client =
462         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
463     ASSERT_TRUE(client);
464     std::vector<AccessibilityElementInfo> infos;
465     EXPECT_EQ(client->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
466         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_SAMGR);
467     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_002 end";
468 }
469 
470 /**
471  * @tc.number: SearchElementInfosByAccessibilityId_003
472  * @tc.name: SearchElementInfosByAccessibilityId
473  * @tc.desc: Test function SearchElementInfosByAccessibilityId
474  */
475 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_003, TestSize.Level1)
476 {
477     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 start";
478     EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
479     std::vector<AccessibilityElementInfo> infos;
480     EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
481         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_TIME_OUT);
482     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 end";
483 }
484 
485 /**
486  * @tc.number: SearchElementInfosBySpecificProperty_001
487  * @tc.name: SearchElementInfosBySpecificProperty
488  * @tc.desc: Test function SearchElementInfosBySpecificProperty
489  */
490 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_001, TestSize.Level1)
491 {
492     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_001 start";
493     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _)).Times(1);
494     std::vector<AccessibilityElementInfo> infos;
495     std::vector<AccessibilityElementInfo> treeInfos;
496     SpecificPropertyParam param;
497     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
498         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_ERR_TIME_OUT);
499     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_001 end";
500 }
501 
502 /**
503  * @tc.number: SearchElementInfosBySpecificProperty_002
504  * @tc.name: SearchElementInfosBySpecificProperty
505  * @tc.desc: Test function SearchElementInfosBySpecificProperty
506  */
507 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_002, TestSize.Level1)
508 {
509     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_002 start";
510     std::shared_ptr<AccessibleAbilityChannelClient> client =
511         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
512     ASSERT_TRUE(client);
513     std::vector<AccessibilityElementInfo> infos;
514     std::vector<AccessibilityElementInfo> treeInfos;
515     SpecificPropertyParam param;
516     EXPECT_EQ(client->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
517         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_ERR_SAMGR);
518     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_002 end";
519 }
520 
521 /**
522  * @tc.number: SearchElementInfosBySpecificProperty_003
523  * @tc.name: SearchElementInfosBySpecificProperty
524  * @tc.desc: Test function SearchElementInfosBySpecificProperty
525  */
526 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_003, TestSize.Level1)
527 {
528     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_003 start";
529     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _)).Times(1);
530     std::vector<AccessibilityElementInfo> infos;
531     std::vector<AccessibilityElementInfo> treeInfos;
532     SpecificPropertyParam param;
533     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
534         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_ERR_TIME_OUT);
535     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_003 end";
536 }
537 
538 /**
539  * @tc.number: SearchElementInfosBySpecificProperty_004
540  * @tc.name: SearchElementInfosBySpecificProperty
541  * @tc.desc: Test function SearchElementInfosBySpecificProperty with elementInfosResult not empty
542  */
543 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_004, TestSize.Level1)
544 {
545     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_004 start";
546     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _))
547         .Times(1)
548         .WillOnce(Invoke([](const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param,
__anon87e744e80202(const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) 549             const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) {
550             std::list<AccessibilityElementInfo> infos;
551             std::list<AccessibilityElementInfo> treeInfos;
552             AccessibilityElementInfo info;
553             info.SetAccessibilityId(1);
554             infos.push_back(info);
555             callback->SetSearchElementInfoBySpecificPropertyResult(infos, treeInfos, requestId);
556         }));
557 
558     std::vector<AccessibilityElementInfo> infos;
559     std::vector<AccessibilityElementInfo> treeInfos;
560     SpecificPropertyParam param;
561     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
562         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_OK);
563     EXPECT_FALSE(infos.empty());
564     EXPECT_TRUE(treeInfos.empty());
565     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_004 end";
566 }
567 
568 /**
569  * @tc.number: SearchElementInfosBySpecificProperty_005
570  * @tc.name: SearchElementInfosBySpecificProperty
571  * @tc.desc: Test function SearchElementInfosBySpecificProperty with treeInfosResult not empty
572  */
573 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_005, TestSize.Level1)
574 {
575     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_005 start";
576     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _))
577         .Times(1)
578         .WillOnce(Invoke([](const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param,
__anon87e744e80302(const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) 579             const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) {
580             std::list<AccessibilityElementInfo> infos;
581             std::list<AccessibilityElementInfo> treeInfos;
582             AccessibilityElementInfo info;
583             info.SetAccessibilityId(1);
584             treeInfos.push_back(info);
585             callback->SetSearchElementInfoBySpecificPropertyResult(infos, treeInfos, requestId);
586         }));
587 
588     std::vector<AccessibilityElementInfo> infos;
589     std::vector<AccessibilityElementInfo> treeInfos;
590     SpecificPropertyParam param;
591     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
592         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_OK);
593     EXPECT_TRUE(infos.empty());
594     EXPECT_FALSE(treeInfos.empty());
595     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_005 end";
596 }
597 
598 /**
599  * @tc.number: SearchElementInfosBySpecificProperty_006
600  * @tc.name: SearchElementInfosBySpecificProperty
601  * @tc.desc: Test function SearchElementInfosBySpecificProperty with both results empty
602  */
603 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_006, TestSize.Level1)
604 {
605     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_006 start";
606     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _))
607         .Times(1)
608         .WillOnce(Invoke([](const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param,
__anon87e744e80402(const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) 609             const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) {
610             std::list<AccessibilityElementInfo> infos;
611             std::list<AccessibilityElementInfo> treeInfos;
612             callback->SetSearchElementInfoBySpecificPropertyResult(infos, treeInfos, requestId);
613         }));
614 
615     std::vector<AccessibilityElementInfo> infos;
616     std::vector<AccessibilityElementInfo> treeInfos;
617     SpecificPropertyParam param;
618     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
619         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_OK);
620     EXPECT_TRUE(infos.empty());
621     EXPECT_TRUE(treeInfos.empty());
622     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_006 end";
623 }
624 
625 /**
626  * @tc.number: SearchElementInfosBySpecificProperty_007
627  * @tc.name: SearchElementInfosBySpecificProperty
628  * @tc.desc: Test function SearchElementInfosBySpecificProperty with invalid elementInfo
629  */
630 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosBySpecificProperty_007, TestSize.Level1)
631 {
632     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_007 start";
633     EXPECT_CALL(*stub_, SearchElementInfoBySpecificProperty(_, _, _, _))
634         .Times(1)
635         .WillOnce(Invoke([](const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param,
__anon87e744e80502(const ElementBasicInfo &elementBasicInfo, const SpecificPropertyParam& param, const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) 636             const int32_t requestId, const sptr<IAccessibilityElementOperatorCallback> &callback) {
637             std::list<AccessibilityElementInfo> infos;
638             std::list<AccessibilityElementInfo> treeInfos;
639             AccessibilityElementInfo info;
640             info.SetAccessibilityId(AccessibilityElementInfo::UNDEFINED_ACCESSIBILITY_ID);
641             infos.push_back(info);
642             callback->SetSearchElementInfoBySpecificPropertyResult(infos, treeInfos, requestId);
643         }));
644 
645     std::vector<AccessibilityElementInfo> infos;
646     std::vector<AccessibilityElementInfo> treeInfos;
647     SpecificPropertyParam param;
648     EXPECT_EQ(instance_->SearchElementInfosBySpecificProperty(ACCESSIBILITY_WINDOW_ID,
649         ELEMENT_ID, param, infos, treeInfos, TREE_ID), RET_ERR_INVALID_ELEMENT_INFO_FROM_ACE);
650     GTEST_LOG_(INFO) << "SearchElementInfosBySpecificProperty_007 end";
651 }
652 } // namespace Accessibility
653 } // namespace OHOS