• 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 <memory>
17 #include <gtest/gtest.h>
18 #include "accessibility_element_operator_callback_impl.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Accessibility {
25 namespace {
26     constexpr int32_t SEQUENCE_NUM = 1;
27 } // namespace
28 
29 class AccessibilityElementOperatorCallbackImplTest : public ::testing::Test {
30 public:
AccessibilityElementOperatorCallbackImplTest()31     AccessibilityElementOperatorCallbackImplTest()
32     {}
~AccessibilityElementOperatorCallbackImplTest()33     ~AccessibilityElementOperatorCallbackImplTest()
34     {}
35 
36     std::shared_ptr<AccessibilityElementOperatorCallbackImpl> instance_ = nullptr;
37 
SetUpTestCase()38     static void SetUpTestCase()
39     {
40         GTEST_LOG_(INFO) << "AccessibilityElementOperatorCallbackImplTest Start";
41     }
TearDownTestCase()42     static void TearDownTestCase()
43     {
44         GTEST_LOG_(INFO) << "AccessibilityElementOperatorCallbackImplTest End";
45     }
SetUp()46     void SetUp()
47     {
48         GTEST_LOG_(INFO) << "AccessibilityElementOperatorCallbackImplTest SetUp()";
49         instance_ = std::make_shared<AccessibilityElementOperatorCallbackImpl>();
50     };
TearDown()51     void TearDown()
52     {
53         GTEST_LOG_(INFO) << "AccessibilityElementOperatorCallbackImplTest TearDown()";
54         instance_ = nullptr;
55     }
56 };
57 
58 /**
59  * @tc.number: SetSearchElementInfoByAccessibilityIdResult_001
60  * @tc.name: SetSearchElementInfoByAccessibilityIdResult
61  * @tc.desc: Test function SetSearchElementInfoByAccessibilityIdResult
62  */
63 HWTEST_F(
64     AccessibilityElementOperatorCallbackImplTest, SetSearchElementInfoByAccessibilityIdResult_001, TestSize.Level1)
65 {
66     GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_001 start";
67 
68     if (!instance_) {
69         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
70         return;
71     }
72 
73     std::vector<AccessibilityElementInfo> infos;
74     AccessibilityElementInfo info {};
75     infos.push_back(info);
76     instance_->SetSearchElementInfoByAccessibilityIdResult(infos, SEQUENCE_NUM);
77     EXPECT_NE(instance_.get(), nullptr);
78     GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_001 end";
79 }
80 
81 /**
82  * @tc.number: SetSearchDefaultFocusByWindowIdResult_001
83  * @tc.name: SetSearchDefaultFocusByWindowIdResult
84  * @tc.desc: Test function SetSearchDefaultFocusByWindowIdResult
85  */
86 HWTEST_F(
87     AccessibilityElementOperatorCallbackImplTest, SetSearchDefaultFocusByWindowIdResult_001, TestSize.Level1)
88 {
89     GTEST_LOG_(INFO) << "SetSearchDefaultFocusByWindowIdResult_001 start";
90 
91     if (!instance_) {
92         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
93         return;
94     }
95 
96     std::vector<AccessibilityElementInfo> infos;
97     AccessibilityElementInfo info {};
98     infos.push_back(info);
99     instance_->SetSearchDefaultFocusByWindowIdResult(infos, SEQUENCE_NUM);
100     EXPECT_NE(instance_.get(), nullptr);
101     GTEST_LOG_(INFO) << "SetSearchDefaultFocusByWindowIdResult_001 end";
102 }
103 
104 /**
105  * @tc.number: SetSearchElementInfoByTextResult_001
106  * @tc.name: SetSearchElementInfoByTextResult
107  * @tc.desc: Test function SetSearchElementInfoByTextResult
108  */
109 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetSearchElementInfoByTextResult_001, TestSize.Level1)
110 {
111     GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 start";
112     if (!instance_) {
113         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
114         return;
115     }
116 
117     std::vector<AccessibilityElementInfo> infos;
118     AccessibilityElementInfo info {};
119     infos.push_back(info);
120     instance_->SetSearchElementInfoByTextResult(infos, SEQUENCE_NUM);
121     EXPECT_NE(instance_.get(), nullptr);
122     GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 end";
123 }
124 
125 /**
126  * @tc.number: SetFindFocusedElementInfoResult_001
127  * @tc.name: SetFindFocusedElementInfoResult
128  * @tc.desc: Test function SetFindFocusedElementInfoResult
129  */
130 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetFindFocusedElementInfoResult_001, TestSize.Level1)
131 {
132     GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 start";
133     if (!instance_) {
134         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
135         return;
136     }
137 
138     std::vector<AccessibilityElementInfo> infos;
139     AccessibilityElementInfo info {};
140     infos.push_back(info);
141     instance_->SetFindFocusedElementInfoResult(info, SEQUENCE_NUM);
142     EXPECT_NE(instance_.get(), nullptr);
143     GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 end";
144 }
145 
146 /**
147  * @tc.number: SetFocusMoveSearchResult_001
148  * @tc.name: SetFocusMoveSearchResult
149  * @tc.desc: Test function SetFocusMoveSearchResult
150  */
151 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetFocusMoveSearchResult_001, TestSize.Level1)
152 {
153     GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 start";
154     if (!instance_) {
155         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
156         return;
157     }
158 
159     std::vector<AccessibilityElementInfo> infos;
160     AccessibilityElementInfo info {};
161     infos.push_back(info);
162     instance_->SetFocusMoveSearchResult(info, SEQUENCE_NUM);
163     EXPECT_NE(instance_.get(), nullptr);
164     GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 end";
165 }
166 
167 /**
168  * @tc.number: SetExecuteActionResult_001
169  * @tc.name: SetExecuteActionResult
170  * @tc.desc: Test function SetExecuteActionResult
171  */
172 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetExecuteActionResult_001, TestSize.Level1)
173 {
174     GTEST_LOG_(INFO) << "SetExecuteActionResult_001 start";
175     if (!instance_) {
176         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
177         return;
178     }
179 
180     std::vector<AccessibilityElementInfo> infos;
181     AccessibilityElementInfo info {};
182     infos.push_back(info);
183     instance_->SetExecuteActionResult(true, SEQUENCE_NUM);
184     EXPECT_NE(instance_.get(), nullptr);
185     GTEST_LOG_(INFO) << "SetExecuteActionResult_001 end";
186 }
187 } // namespace Accessibility
188 } // namespace OHOS