• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2025 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 #define LOG_TAG "UdmfServiceStubTest"
17 #include "udmf_service_stub.h"
18 #include "udmf_service_impl.h"
19 #include "udmf_types_util.h"
20 #include "gtest/gtest.h"
21 
22 using namespace OHOS::DistributedData;
23 namespace OHOS::UDMF {
24 using namespace testing::ext;
25 class UdmfServiceStubTest : public testing::Test {
26 public:
SetUpTestCase(void)27     static void SetUpTestCase(void) {}
TearDownTestCase(void)28     static void TearDownTestCase(void) {}
SetUp()29     void SetUp() {}
TearDown()30     void TearDown() {}
31 };
32 
33 /**
34 * @tc.name: OnRemoteRequest001
35 * @tc.desc: Abnormal test of OnRemoteRequest, code is invalid
36 * @tc.type: FUNC
37 * @tc.require:
38 */
39 HWTEST_F(UdmfServiceStubTest, OnRemoteRequest001, TestSize.Level1)
40 {
41     uint32_t code = 17; // invalid code
42     MessageParcel data;
43     MessageParcel reply;
44     UdmfServiceImpl udmfServiceImpl;
45     int ret = udmfServiceImpl.OnRemoteRequest(code, data, reply);
46     EXPECT_EQ(ret, -1);
47 }
48 
49 /**
50 * @tc.name: OnSetData001
51 * @tc.desc: Abnormal test of OnSetData, data is invalid
52 * @tc.type: FUNC
53 * @tc.require:
54 */
55 HWTEST_F(UdmfServiceStubTest, OnSetData001, TestSize.Level1)
56 {
57     MessageParcel data;
58     MessageParcel reply;
59     UdmfServiceImpl udmfServiceImpl;
60     int ret = udmfServiceImpl.OnSetData(data, reply);
61     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
62 }
63 
64 /**
65 * @tc.name: OnGetData001
66 * @tc.desc: Abnormal test of OnGetData, data is invalid
67 * @tc.type: FUNC
68 * @tc.require:
69 */
70 HWTEST_F(UdmfServiceStubTest, OnGetData001, TestSize.Level1)
71 {
72     MessageParcel data;
73     MessageParcel reply;
74     UdmfServiceImpl udmfServiceImpl;
75     int ret = udmfServiceImpl.OnGetData(data, reply);
76     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
77 }
78 
79 /**
80 * @tc.name: OnGetBatchData001
81 * @tc.desc: Abnormal test of OnGetBatchData, data is invalid
82 * @tc.type: FUNC
83 * @tc.require:
84 */
85 HWTEST_F(UdmfServiceStubTest, OnGetBatchData001, TestSize.Level1)
86 {
87     MessageParcel data;
88     MessageParcel reply;
89     UdmfServiceImpl udmfServiceImpl;
90     int ret = udmfServiceImpl.OnGetBatchData(data, reply);
91     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
92 }
93 
94 /**
95 * @tc.name: OnUpdateData001
96 * @tc.desc: Abnormal test of OnUpdateData, data is invalid
97 * @tc.type: FUNC
98 * @tc.require:
99 */
100 HWTEST_F(UdmfServiceStubTest, OnUpdateData001, TestSize.Level1)
101 {
102     MessageParcel data;
103     MessageParcel reply;
104     UdmfServiceImpl udmfServiceImpl;
105     int ret = udmfServiceImpl.OnUpdateData(data, reply);
106     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
107 }
108 
109 /**
110 * @tc.name: OnDeleteData001
111 * @tc.desc: Abnormal test of OnDeleteData, data is invalid
112 * @tc.type: FUNC
113 * @tc.require:
114 */
115 HWTEST_F(UdmfServiceStubTest, OnDeleteData001, TestSize.Level1)
116 {
117     MessageParcel data;
118     MessageParcel reply;
119     UdmfServiceImpl udmfServiceImpl;
120     int ret = udmfServiceImpl.OnDeleteData(data, reply);
121     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
122 }
123 
124 /**
125 * @tc.name: OnGetSummary001
126 * @tc.desc: Abnormal test of OnGetSummary, data is invalid
127 * @tc.type: FUNC
128 * @tc.require:
129 */
130 HWTEST_F(UdmfServiceStubTest, OnGetSummary001, TestSize.Level1)
131 {
132     MessageParcel data;
133     MessageParcel reply;
134     UdmfServiceImpl udmfServiceImpl;
135     int ret = udmfServiceImpl.OnGetSummary(data, reply);
136     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
137 }
138 
139 /**
140 * @tc.name: OnAddPrivilege001
141 * @tc.desc: Abnormal test of OnAddPrivilege, data is invalid
142 * @tc.type: FUNC
143 * @tc.require:
144 */
145 HWTEST_F(UdmfServiceStubTest, OnAddPrivilege001, TestSize.Level1)
146 {
147     MessageParcel data;
148     MessageParcel reply;
149     UdmfServiceImpl udmfServiceImpl;
150     int ret = udmfServiceImpl.OnAddPrivilege(data, reply);
151     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
152 }
153 
154 /**
155 * @tc.name: OnIsRemoteData001
156 * @tc.desc: Abnormal test of OnIsRemoteData, data is invalid
157 * @tc.type: FUNC
158 * @tc.require:
159 */
160 HWTEST_F(UdmfServiceStubTest, OnIsRemoteData001, TestSize.Level1)
161 {
162     MessageParcel data;
163     MessageParcel reply;
164     UdmfServiceImpl udmfServiceImpl;
165     int ret = udmfServiceImpl.OnIsRemoteData(data, reply);
166     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
167 }
168 
169 /**
170 * @tc.name: OnSetAppShareOption001
171 * @tc.desc: Abnormal test of OnSetAppShareOption, data is invalid
172 * @tc.type: FUNC
173 * @tc.require:
174 */
175 HWTEST_F(UdmfServiceStubTest, OnSetAppShareOption001, TestSize.Level1)
176 {
177     MessageParcel data;
178     MessageParcel reply;
179     UdmfServiceImpl udmfServiceImpl;
180     int ret = udmfServiceImpl.OnSetAppShareOption(data, reply);
181     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
182 }
183 
184 /**
185 * @tc.name: OnGetAppShareOption001
186 * @tc.desc: Abnormal test of OnGetAppShareOption, data is invalid
187 * @tc.type: FUNC
188 * @tc.require:
189 */
190 HWTEST_F(UdmfServiceStubTest, OnGetAppShareOption001, TestSize.Level1)
191 {
192     MessageParcel data;
193     MessageParcel reply;
194     UdmfServiceImpl udmfServiceImpl;
195     int ret = udmfServiceImpl.OnGetAppShareOption(data, reply);
196     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
197 }
198 
199 /**
200 * @tc.name: OnRemoveAppShareOption001
201 * @tc.desc: Abnormal test of OnRemoveAppShareOption, data is invalid
202 * @tc.type: FUNC
203 * @tc.require:
204 */
205 HWTEST_F(UdmfServiceStubTest, OnRemoveAppShareOption001, TestSize.Level1)
206 {
207     MessageParcel data;
208     MessageParcel reply;
209     UdmfServiceImpl udmfServiceImpl;
210     int ret = udmfServiceImpl.OnRemoveAppShareOption(data, reply);
211     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
212 }
213 
214 /**
215 * @tc.name:OnObtainAsynProcess001
216 * @tc.desc: Abnormal test of OnObtainAsynProcess, data is invalid
217 * @tc.type: FUNC
218 * @tc.require:
219 */
220 HWTEST_F(UdmfServiceStubTest, OnObtainAsynProcess001, TestSize.Level1)
221 {
222     MessageParcel data;
223     MessageParcel reply;
224     UdmfServiceImpl udmfServiceImpl;
225     int ret = udmfServiceImpl.OnObtainAsynProcess(data, reply);
226     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
227 }
228 
229 /**
230 * @tc.name:OnClearAsynProcessByKey001
231 * @tc.desc: Abnormal test of OnClearAsynProcessByKey, data is invalid
232 * @tc.type: FUNC
233 * @tc.require:
234 */
235 HWTEST_F(UdmfServiceStubTest, OnClearAsynProcessByKey001, TestSize.Level1)
236 {
237     MessageParcel data;
238     MessageParcel reply;
239     UdmfServiceImpl udmfServiceImpl;
240     int ret = udmfServiceImpl.OnClearAsynProcessByKey(data, reply);
241     EXPECT_EQ(ret, E_READ_PARCEL_ERROR);
242 }
243 }; // namespace UDMF