• 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     GTEST_LOG_(INFO) << "SetSearchElementInfoByAccessibilityIdResult_001 end";
78 }
79 
80 /**
81  * @tc.number: SetSearchElementInfoByTextResult_001
82  * @tc.name: SetSearchElementInfoByTextResult
83  * @tc.desc: Test function SetSearchElementInfoByTextResult
84  */
85 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetSearchElementInfoByTextResult_001, TestSize.Level1)
86 {
87     GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 start";
88     if (!instance_) {
89         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
90         return;
91     }
92 
93     std::vector<AccessibilityElementInfo> infos;
94     AccessibilityElementInfo info {};
95     infos.push_back(info);
96     instance_->SetSearchElementInfoByTextResult(infos, SEQUENCE_NUM);
97     GTEST_LOG_(INFO) << "SetSearchElementInfoByTextResult_001 end";
98 }
99 
100 /**
101  * @tc.number: SetFindFocusedElementInfoResult_001
102  * @tc.name: SetFindFocusedElementInfoResult
103  * @tc.desc: Test function SetFindFocusedElementInfoResult
104  */
105 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetFindFocusedElementInfoResult_001, TestSize.Level1)
106 {
107     GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 start";
108     if (!instance_) {
109         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
110         return;
111     }
112 
113     std::vector<AccessibilityElementInfo> infos;
114     AccessibilityElementInfo info {};
115     infos.push_back(info);
116     instance_->SetFindFocusedElementInfoResult(info, SEQUENCE_NUM);
117     GTEST_LOG_(INFO) << "SetFindFocusedElementInfoResult_001 end";
118 }
119 
120 /**
121  * @tc.number: SetFocusMoveSearchResult_001
122  * @tc.name: SetFocusMoveSearchResult
123  * @tc.desc: Test function SetFocusMoveSearchResult
124  */
125 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetFocusMoveSearchResult_001, TestSize.Level1)
126 {
127     GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 start";
128     if (!instance_) {
129         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
130         return;
131     }
132 
133     std::vector<AccessibilityElementInfo> infos;
134     AccessibilityElementInfo info {};
135     infos.push_back(info);
136     instance_->SetFocusMoveSearchResult(info, SEQUENCE_NUM);
137     GTEST_LOG_(INFO) << "SetFocusMoveSearchResult_001 end";
138 }
139 
140 /**
141  * @tc.number: SetExecuteActionResult_001
142  * @tc.name: SetExecuteActionResult
143  * @tc.desc: Test function SetExecuteActionResult
144  */
145 HWTEST_F(AccessibilityElementOperatorCallbackImplTest, SetExecuteActionResult_001, TestSize.Level1)
146 {
147     GTEST_LOG_(INFO) << "SetExecuteActionResult_001 start";
148     if (!instance_) {
149         GTEST_LOG_(INFO) << "Cann't get AccessibilityElementOperatorCallbackImpl instance_";
150         return;
151     }
152 
153     std::vector<AccessibilityElementInfo> infos;
154     AccessibilityElementInfo info {};
155     infos.push_back(info);
156     instance_->SetExecuteActionResult(true, SEQUENCE_NUM);
157     GTEST_LOG_(INFO) << "SetExecuteActionResult_001 end";
158 }
159 } // namespace Accessibility
160 } // namespace OHOS