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 
95     if (!instance_) {
96         GTEST_LOG_(INFO) << "Cann't get AccessibleAbilityChannelClient instance_";
97         return;
98     }
99 
100     instance_->SetOnKeyPressEventResult(true, SEQUENCE);
101     EXPECT_NE(instance_.get(), nullptr);
102     GTEST_LOG_(INFO) << "SetOnKeyPressEventResult_001 end";
103 }
104 
105 /**
106  * @tc.number: FindFocusedElementInfo_001
107  * @tc.name: FindFocusedElementInfo
108  * @tc.desc: Test function FindFocusedElementInfo
109  */
110 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_001, TestSize.Level1)
111 {
112     GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 start";
113     EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
114     AccessibilityElementInfo info {};
115     EXPECT_EQ(instance_->FindFocusedElementInfo(ACCESSIBILITY_WINDOW_ID,
116         ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_FAILED);
117     GTEST_LOG_(INFO) << "FindFocusedElementInfo_001 end";
118 }
119 
120 /**
121  * @tc.number: FindFocusedElementInfo_002
122  * @tc.name: FindFocusedElementInfo
123  * @tc.desc: Test function FindFocusedElementInfo
124  */
125 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_002, TestSize.Level1)
126 {
127     GTEST_LOG_(INFO) << "FindFocusedElementInfo_002 start";
128     std::shared_ptr<AccessibleAbilityChannelClient> client =
129         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
130     ASSERT_TRUE(client);
131     AccessibilityElementInfo info {};
132     EXPECT_EQ(client->FindFocusedElementInfo(
133         ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_SAMGR);
134     GTEST_LOG_(INFO) << "FindFocusedElementInfo_002 end";
135 }
136 
137 /**
138  * @tc.number: FindFocusedElementInfo_003
139  * @tc.name: FindFocusedElementInfo
140  * @tc.desc: Test function FindFocusedElementInfo
141  */
142 HWTEST_F(AccessibleAbilityChannelClientTest, FindFocusedElementInfo_003, TestSize.Level1)
143 {
144     GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 start";
145     EXPECT_CALL(*stub_, FindFocusedElementInfo(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
146     AccessibilityElementInfo info {};
147     EXPECT_EQ(instance_->FindFocusedElementInfo(
148         ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, FOCUS_TYPE_INPUT, info), RET_ERR_TIME_OUT);
149     GTEST_LOG_(INFO) << "FindFocusedElementInfo_003 end";
150 }
151 
152 /**
153  * @tc.number: SendSimulateGesture_001
154  * @tc.name: SendSimulateGesture
155  * @tc.desc: Test function SendSimulateGesture
156  */
157 HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_001, TestSize.Level1)
158 {
159     GTEST_LOG_(INFO) << "SendSimulateGesture_001 start";
160     EXPECT_CALL(*stub_, SendSimulateGesture(_)).Times(1).WillOnce(Return(RET_OK));
161     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
162     EXPECT_EQ(instance_->SendSimulateGesture(gesturePath), RET_OK);
163     GTEST_LOG_(INFO) << "SendSimulateGesture_001 end";
164 }
165 
166 /**
167  * @tc.number: SendSimulateGesture_002
168  * @tc.name: SendSimulateGesture
169  * @tc.desc: Test function SendSimulateGesture
170  */
171 HWTEST_F(AccessibleAbilityChannelClientTest, SendSimulateGesture_002, TestSize.Level1)
172 {
173     GTEST_LOG_(INFO) << "SendSimulateGesture_002 start";
174     std::shared_ptr<AccessibleAbilityChannelClient> client =
175         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
176     ASSERT_TRUE(client);
177     std::shared_ptr<AccessibilityGestureInjectPath> gesturePath = std::make_shared<AccessibilityGestureInjectPath>();
178     EXPECT_EQ(client->SendSimulateGesture(gesturePath), RET_ERR_SAMGR);
179     GTEST_LOG_(INFO) << "SendSimulateGesture_002 end";
180 }
181 
182 /**
183  * @tc.number: ExecuteAction_001
184  * @tc.name: ExecuteAction
185  * @tc.desc: Test function ExecuteAction
186  */
187 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_001, TestSize.Level1)
188 {
189     GTEST_LOG_(INFO) << "ExecuteAction_001 start";
190     EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
191     std::map<std::string, std::string> actionArguments;
192     EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
193         ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_FAILED);
194     GTEST_LOG_(INFO) << "ExecuteAction_001 end";
195 }
196 
197 /**
198  * @tc.number: ExecuteAction_002
199  * @tc.name: ExecuteAction
200  * @tc.desc: Test function ExecuteAction
201  */
202 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_002, TestSize.Level1)
203 {
204     GTEST_LOG_(INFO) << "ExecuteAction_002 start";
205     std::shared_ptr<AccessibleAbilityChannelClient> client =
206         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
207     ASSERT_TRUE(client);
208     std::map<std::string, std::string> actionArguments;
209     EXPECT_EQ(client->ExecuteAction(ACCESSIBILITY_WINDOW_ID,
210         ELEMENT_ID, ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_SAMGR);
211     GTEST_LOG_(INFO) << "ExecuteAction_002 end";
212 }
213 
214 /**
215  * @tc.number: ExecuteAction_003
216  * @tc.name: ExecuteAction
217  * @tc.desc: Test function ExecuteAction
218  */
219 HWTEST_F(AccessibleAbilityChannelClientTest, ExecuteAction_003, TestSize.Level1)
220 {
221     GTEST_LOG_(INFO) << "ExecuteAction_003 start";
222     EXPECT_CALL(*stub_, ExecuteAction(_, _, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
223     std::map<std::string, std::string> actionArguments;
224     EXPECT_EQ(instance_->ExecuteAction(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
225         ActionType::ACCESSIBILITY_ACTION_SELECT, actionArguments), RET_ERR_TIME_OUT);
226     GTEST_LOG_(INFO) << "ExecuteAction_003 end";
227 }
228 
229 /**
230  * @tc.number: GetWindow_001
231  * @tc.name: GetWindow
232  * @tc.desc: Test function GetWindow
233  */
234 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_001, TestSize.Level1)
235 {
236     GTEST_LOG_(INFO) << "GetWindow_001 start";
237     std::shared_ptr<AccessibleAbilityChannelClient> client =
238         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
239     ASSERT_TRUE(client);
240     AccessibilityWindowInfo windowInfo;
241     EXPECT_EQ(client->GetWindow(0, windowInfo), RET_ERR_SAMGR);
242     GTEST_LOG_(INFO) << "GetWindow_001 end";
243 }
244 
245 /**
246  * @tc.number: GetWindow_002
247  * @tc.name: GetWindow
248  * @tc.desc: Test function GetWindow
249  */
250 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindow_002, TestSize.Level1)
251 {
252     GTEST_LOG_(INFO) << "GetWindow_002 start";
253     EXPECT_CALL(*stub_, GetWindow(_, _)).Times(1).WillOnce(Return(RET_OK));
254     AccessibilityWindowInfo windowInfo;
255     EXPECT_EQ(instance_->GetWindow(0, windowInfo), RET_OK);
256     GTEST_LOG_(INFO) << "GetWindow_002 end";
257 }
258 
259 /**
260  * @tc.number: GetWindows_001
261  * @tc.name: GetWindows
262  * @tc.desc: Test function GetWindows
263  */
264 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_001, TestSize.Level1)
265 {
266     GTEST_LOG_(INFO) << "GetWindows_001 start";
267     std::shared_ptr<AccessibleAbilityChannelClient> client =
268         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
269     ASSERT_TRUE(client);
270     std::vector<AccessibilityWindowInfo> windowInfo {};
271     EXPECT_EQ(client->GetWindows(windowInfo), RET_ERR_SAMGR);
272     GTEST_LOG_(INFO) << "GetWindows_001 end";
273 }
274 
275 /**
276  * @tc.number: GetWindows_002
277  * @tc.name: GetWindows
278  * @tc.desc: Test function GetWindows
279  */
280 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_002, TestSize.Level1)
281 {
282     GTEST_LOG_(INFO) << "GetWindows_002 start";
283     EXPECT_CALL(*stub_, GetWindows(_)).Times(1).WillOnce(Return(RET_OK));
284     std::vector<AccessibilityWindowInfo> windowInfo {};
285     EXPECT_EQ(instance_->GetWindows(windowInfo), RET_OK);
286     GTEST_LOG_(INFO) << "GetWindows_002 end";
287 }
288 
289 /**
290  * @tc.number: GetWindows_003
291  * @tc.name: GetWindows
292  * @tc.desc: Test function GetWindows
293  */
294 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_003, TestSize.Level1)
295 {
296     GTEST_LOG_(INFO) << "GetWindows_003 start";
297     std::shared_ptr<AccessibleAbilityChannelClient> client =
298         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
299     ASSERT_TRUE(client);
300     std::vector<AccessibilityWindowInfo> windowInfo {};
301     EXPECT_EQ(client->GetWindows(0, windowInfo), RET_ERR_SAMGR);
302     GTEST_LOG_(INFO) << "GetWindows_003 end";
303 }
304 
305 /**
306  * @tc.number: GetWindows_004
307  * @tc.name: GetWindows
308  * @tc.desc: Test function GetWindows
309  */
310 HWTEST_F(AccessibleAbilityChannelClientTest, GetWindows_004, TestSize.Level1)
311 {
312     GTEST_LOG_(INFO) << "GetWindows_004 start";
313     EXPECT_CALL(*stub_, GetWindowsByDisplayId(_, _)).Times(1).WillOnce(Return(RET_OK));
314     std::vector<AccessibilityWindowInfo> windowInfo {};
315     EXPECT_EQ(instance_->GetWindows(0, windowInfo), RET_OK);
316     GTEST_LOG_(INFO) << "GetWindows_004 end";
317 }
318 
319 /**
320  * @tc.number: SearchElementInfosByText_001
321  * @tc.name: SearchElementInfosByText
322  * @tc.desc: Test function SearchElementInfosByText
323  */
324 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_001, TestSize.Level1)
325 {
326     GTEST_LOG_(INFO) << "SearchElementInfosByText_001 start";
327     std::shared_ptr<AccessibleAbilityChannelClient> client =
328         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
329     ASSERT_TRUE(client);
330     std::vector<AccessibilityElementInfo> infos;
331     EXPECT_EQ(client->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_SAMGR);
332     GTEST_LOG_(INFO) << "SearchElementInfosByText_001 end";
333 }
334 
335 /**
336  * @tc.number: SearchElementInfosByText_002
337  * @tc.name: SearchElementInfosByText
338  * @tc.desc: Test function SearchElementInfosByText
339  */
340 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_002, TestSize.Level1)
341 {
342     GTEST_LOG_(INFO) << "SearchElementInfosByText_002 start";
343     EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
344     std::vector<AccessibilityElementInfo> infos;
345     EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_FAILED);
346     GTEST_LOG_(INFO) << "SearchElementInfosByText_002 end";
347 }
348 
349 /**
350  * @tc.number: SearchElementInfosByText_003
351  * @tc.name: SearchElementInfosByText
352  * @tc.desc: Test function SearchElementInfosByText
353  */
354 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByText_003, TestSize.Level1)
355 {
356     GTEST_LOG_(INFO) << "SearchElementInfosByText_003 start";
357     EXPECT_CALL(*stub_, SearchElementInfosByText(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
358     std::vector<AccessibilityElementInfo> infos;
359     EXPECT_EQ(instance_->SearchElementInfosByText(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID, TEST, infos), RET_ERR_TIME_OUT);
360     GTEST_LOG_(INFO) << "SearchElementInfosByText_003 end";
361 }
362 
363 /**
364  * @tc.number: FocusMoveSearch_001
365  * @tc.name: FocusMoveSearch
366  * @tc.desc: Test function FocusMoveSearch
367  */
368 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_001, TestSize.Level1)
369 {
370     GTEST_LOG_(INFO) << "FocusMoveSearch_001 start";
371     std::shared_ptr<AccessibleAbilityChannelClient> client =
372         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
373     ASSERT_TRUE(client);
374     AccessibilityElementInfo info {};
375     EXPECT_EQ(client->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
376         FocusMoveDirection::DOWN, info), RET_ERR_SAMGR);
377     GTEST_LOG_(INFO) << "FocusMoveSearch_001 end";
378 }
379 
380 /**
381  * @tc.number: FocusMoveSearch_002
382  * @tc.name: FocusMoveSearch
383  * @tc.desc: Test function FocusMoveSearch
384  */
385 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_002, TestSize.Level1)
386 {
387     GTEST_LOG_(INFO) << "FocusMoveSearch_002 start";
388     EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
389     AccessibilityElementInfo info {};
390     EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
391         FocusMoveDirection::DOWN, info), RET_ERR_FAILED);
392     GTEST_LOG_(INFO) << "FocusMoveSearch_002 end";
393 }
394 
395 /**
396  * @tc.number: FocusMoveSearch_003
397  * @tc.name: FocusMoveSearch
398  * @tc.desc: Test function FocusMoveSearch
399  */
400 HWTEST_F(AccessibleAbilityChannelClientTest, FocusMoveSearch_003, TestSize.Level1)
401 {
402     GTEST_LOG_(INFO) << "FocusMoveSearch_003 start";
403     EXPECT_CALL(*stub_, FocusMoveSearch(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
404     AccessibilityElementInfo info {};
405     EXPECT_EQ(instance_->FocusMoveSearch(ACCESSIBILITY_WINDOW_ID, ELEMENT_ID,
406         FocusMoveDirection::DOWN, info), RET_ERR_TIME_OUT);
407     GTEST_LOG_(INFO) << "FocusMoveSearch_003 end";
408 }
409 
410 /**
411  * @tc.number: SetTargetBundleName_001
412  * @tc.name: SetTargetBundleName
413  * @tc.desc: Test function SetTargetBundleName
414  */
415 HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_001, TestSize.Level1)
416 {
417     GTEST_LOG_(INFO) << "SetTargetBundleName_001 start";
418     std::shared_ptr<AccessibleAbilityChannelClient> client =
419         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
420     ASSERT_TRUE(client);
421     std::vector<std::string> targetBundleNames;
422     EXPECT_EQ(client->SetTargetBundleName(targetBundleNames), RET_ERR_SAMGR);
423     GTEST_LOG_(INFO) << "SetTargetBundleName_001 end";
424 }
425 
426 /**
427  * @tc.number: SetTargetBundleName_002
428  * @tc.name: SetTargetBundleName
429  * @tc.desc: Test function SetTargetBundleName
430  */
431 HWTEST_F(AccessibleAbilityChannelClientTest, SetTargetBundleName_002, TestSize.Level1)
432 {
433     GTEST_LOG_(INFO) << "SetTargetBundleName_002 start";
434     EXPECT_CALL(*stub_, SetTargetBundleName(_)).Times(1).WillOnce(Return(RET_OK));
435     std::vector<std::string> targetBundleNames;
436     EXPECT_EQ(instance_->SetTargetBundleName(targetBundleNames), RET_OK);
437     GTEST_LOG_(INFO) << "SetTargetBundleName_002 end";
438 }
439 
440 /**
441  * @tc.number: SearchElementInfosByAccessibilityId_001
442  * @tc.name: SearchElementInfosByAccessibilityId
443  * @tc.desc: Test function SearchElementInfosByAccessibilityId
444  */
445 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_001, TestSize.Level1)
446 {
447     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 start";
448     EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(RET_ERR_FAILED));
449     std::vector<AccessibilityElementInfo> infos;
450     EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
451         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_FAILED);
452     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_001 end";
453 }
454 
455 /**
456  * @tc.number: SearchElementInfosByAccessibilityId_002
457  * @tc.name: SearchElementInfosByAccessibilityId
458  * @tc.desc: Test function SearchElementInfosByAccessibilityId
459  */
460 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_002, TestSize.Level1)
461 {
462     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_002 start";
463     std::shared_ptr<AccessibleAbilityChannelClient> client =
464         std::make_shared<AccessibleAbilityChannelClient>(CHANNEL_ID, nullptr);
465     ASSERT_TRUE(client);
466     std::vector<AccessibilityElementInfo> infos;
467     EXPECT_EQ(client->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
468         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_SAMGR);
469     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_002 end";
470 }
471 
472 /**
473  * @tc.number: SearchElementInfosByAccessibilityId_003
474  * @tc.name: SearchElementInfosByAccessibilityId
475  * @tc.desc: Test function SearchElementInfosByAccessibilityId
476  */
477 HWTEST_F(AccessibleAbilityChannelClientTest, SearchElementInfosByAccessibilityId_003, TestSize.Level1)
478 {
479     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 start";
480     EXPECT_CALL(*stub_, SearchElementInfoByAccessibilityId(_, _, _, _, _)).Times(1).WillOnce(Return(RET_OK));
481     std::vector<AccessibilityElementInfo> infos;
482     EXPECT_EQ(instance_->SearchElementInfosByAccessibilityId(ACCESSIBILITY_WINDOW_ID,
483         ELEMENT_ID, MODE, infos, TREE_ID), RET_ERR_TIME_OUT);
484     GTEST_LOG_(INFO) << "SearchElementInfosByAccessibilityId_003 end";
485 }
486 } // namespace Accessibility
487 } // namespace OHOS