• 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 #include <gtest/gtest.h>
17 
18 #include "b_error/b_error.h"
19 #include "b_incremental_backup_session.h"
20 #include "b_incremental_restore_session.h"
21 #include "b_incremental_session_restore_async.h"
22 #include "service_proxy_mock.h"
23 #include "service_client.h"
24 
25 namespace OHOS::FileManagement::Backup {
26 using namespace std;
27 using namespace testing;
28 
29 class IncrementalSessionTest : public testing::Test {
30 public:
31     static void SetUpTestCase(void);
32     static void TearDownTestCase();
SetUp()33     void SetUp() override {};
TearDown()34     void TearDown() override {};
35 public:
36     static inline sptr<ServiceProxyMock> proxy = nullptr;
37     static inline shared_ptr<BIncrementalBackupSession> backupSession = nullptr;
38     static inline shared_ptr<BIncrementalRestoreSession> restoreSession = nullptr;
39     static inline shared_ptr<BIncrementalSessionRestoreAsync> restoreAsyncSession = nullptr;
40 };
41 
SetUpTestCase()42 void IncrementalSessionTest::SetUpTestCase()
43 {
44     proxy = sptr<ServiceProxyMock>(new ServiceProxyMock(nullptr));
45     backupSession = make_shared<BIncrementalBackupSession>();
46     restoreSession = make_shared<BIncrementalRestoreSession>();
47     BIncrementalSessionRestoreAsync::Callbacks callbacks;
48     restoreAsyncSession = make_shared<BIncrementalSessionRestoreAsync>(callbacks);
49     ServiceClient::serviceProxy_ = proxy;
50 }
51 
TearDownTestCase()52 void IncrementalSessionTest::TearDownTestCase()
53 {
54     backupSession = nullptr;
55     restoreSession = nullptr;
56     restoreAsyncSession = nullptr;
57     ServiceClient::serviceProxy_ = nullptr;
58     proxy = nullptr;
59 }
60 
61 /**
62  * @tc.number: SUB_b_incremental_session_test_0100
63  * @tc.name: SUB_b_incremental_session_test_0100
64  * @tc.desc: 测试 InitIncrementalBackupSession 接口
65  * @tc.size: MEDIUM
66  * @tc.type: FUNC
67  * @tc.level Level 1
68  * @tc.require: issuesI9KPRL
69  */
70 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0100, testing::ext::TestSize.Level1)
71 {
72     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0100";
73     try {
74         ServiceClient::serviceProxy_ = nullptr;
75         BIncrementalBackupSession::Callbacks callbacks;
76         EXPECT_TRUE(backupSession != nullptr);
77         auto err = backupSession->Init(callbacks);
78         EXPECT_EQ(err, nullptr);
79 
80         EXPECT_CALL(*proxy, InitIncrementalBackupSession(_)).WillOnce(Return(-1)).WillOnce(Return(0));
81         ServiceClient::serviceProxy_ = proxy;
82         err = backupSession->Init(callbacks);
83         EXPECT_EQ(err, nullptr);
84         err = backupSession->Init(callbacks);
85         EXPECT_NE(err, nullptr);
86     } catch (...) {
87         EXPECT_TRUE(false);
88         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
89     }
90     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0100";
91 }
92 
BackupSeviceDied()93 void BackupSeviceDied() {}
94 /**
95  * @tc.number: SUB_b_incremental_session_test_0200
96  * @tc.name: SUB_b_incremental_session_test_0200
97  * @tc.desc: 测试 RegisterBackupServiceDied 接口
98  * @tc.size: MEDIUM
99  * @tc.type: FUNC
100  * @tc.level Level 1
101  * @tc.require: issuesI9KPRL
102  */
103 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0200, testing::ext::TestSize.Level1)
104 {
105     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0200";
106     try {
107         ServiceClient::serviceProxy_ = nullptr;
108         EXPECT_TRUE(backupSession != nullptr);
109         backupSession->RegisterBackupServiceDied(nullptr);
110 
111         ServiceClient::serviceProxy_ = proxy;
112         backupSession->RegisterBackupServiceDied(nullptr);
113 
114         EXPECT_CALL(*proxy, AsObject()).WillOnce(Return(nullptr));
115         backupSession->RegisterBackupServiceDied(BackupSeviceDied);
116     } catch (...) {
117         EXPECT_TRUE(true);
118         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
119     }
120     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0200";
121 }
122 
123 /**
124  * @tc.number: SUB_b_incremental_session_test_0300
125  * @tc.name: SUB_b_incremental_session_test_0300
126  * @tc.desc: 测试 AppendBundles 接口
127  * @tc.size: MEDIUM
128  * @tc.type: FUNC
129  * @tc.level Level 1
130  * @tc.require: issuesI9KPRL
131  */
132 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0300, testing::ext::TestSize.Level1)
133 {
134     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0300";
135     try {
136         ServiceClient::serviceProxy_ = nullptr;
137         vector<BIncrementalData> bundlesToBackup;
138         EXPECT_TRUE(backupSession != nullptr);
139         auto err = backupSession->AppendBundles(bundlesToBackup);
140         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
141 
142         EXPECT_CALL(*proxy, AppendBundlesIncrementalBackupSession(_)).WillOnce(Return(0));
143         ServiceClient::serviceProxy_ = proxy;
144         err = backupSession->AppendBundles(bundlesToBackup);
145         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
146     } catch (...) {
147         EXPECT_TRUE(true);
148         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
149     }
150     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0300";
151 }
152 
153 /**
154  * @tc.number: SUB_b_incremental_session_test_0400
155  * @tc.name: SUB_b_incremental_session_test_0400
156  * @tc.desc: 测试 Release 接口
157  * @tc.size: MEDIUM
158  * @tc.type: FUNC
159  * @tc.level Level 1
160  * @tc.require: issuesI9KPRL
161  */
162 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0400, testing::ext::TestSize.Level1)
163 {
164     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0400";
165     try {
166         ServiceClient::serviceProxy_ = nullptr;
167         EXPECT_TRUE(backupSession != nullptr);
168         auto err = backupSession->Release();
169         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
170 
171         EXPECT_CALL(*proxy, Release()).WillOnce(Return(0));
172         ServiceClient::serviceProxy_ = proxy;
173         err = backupSession->Release();
174         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
175     } catch (...) {
176         EXPECT_TRUE(false);
177         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
178     }
179     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0400";
180 }
181 
182 /**
183  * @tc.number: SUB_b_incremental_session_test_0500
184  * @tc.name: SUB_b_incremental_session_test_0500
185  * @tc.desc: 测试 Init 接口
186  * @tc.size: MEDIUM
187  * @tc.type: FUNC
188  * @tc.level Level 1
189  * @tc.require: issuesI9KPRL
190  */
191 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0500, testing::ext::TestSize.Level1)
192 {
193     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0500";
194     try {
195         ServiceClient::serviceProxy_ = nullptr;
196         BIncrementalRestoreSession::Callbacks callbacks;
197         EXPECT_TRUE(restoreSession != nullptr);
198         auto err = restoreSession->Init(callbacks);
199         EXPECT_EQ(err, nullptr);
200 
201         EXPECT_CALL(*proxy, InitRestoreSession(_)).WillOnce(Return(-1)).WillOnce(Return(0));
202         ServiceClient::serviceProxy_ = proxy;
203         err = restoreSession->Init(callbacks);
204         EXPECT_EQ(err, nullptr);
205         err = restoreSession->Init(callbacks);
206         EXPECT_NE(err, nullptr);
207     } catch (...) {
208         EXPECT_TRUE(false);
209         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
210     }
211     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0500";
212 }
213 
RestoreSeviceDied()214 void RestoreSeviceDied() {}
215 /**
216  * @tc.number: SUB_b_incremental_session_test_0600
217  * @tc.name: SUB_b_incremental_session_test_0600
218  * @tc.desc: 测试 RegisterBackupServiceDied 接口
219  * @tc.size: MEDIUM
220  * @tc.type: FUNC
221  * @tc.level Level 1
222  * @tc.require: issuesI9KPRL
223  */
224 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0600, testing::ext::TestSize.Level1)
225 {
226     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0600";
227     try {
228         ServiceClient::serviceProxy_ = nullptr;
229         EXPECT_TRUE(restoreSession != nullptr);
230         restoreSession->RegisterBackupServiceDied(nullptr);
231 
232         ServiceClient::serviceProxy_ = proxy;
233         restoreSession->RegisterBackupServiceDied(nullptr);
234 
235         EXPECT_CALL(*proxy, AsObject()).WillOnce(Return(nullptr));
236         restoreSession->RegisterBackupServiceDied(RestoreSeviceDied);
237     } catch (...) {
238         EXPECT_TRUE(true);
239         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
240     }
241     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0600";
242 }
243 
244 /**
245  * @tc.number: SUB_b_incremental_session_test_0700
246  * @tc.name: SUB_b_incremental_session_test_0700
247  * @tc.desc: 测试 AppendBundles 接口
248  * @tc.size: MEDIUM
249  * @tc.type: FUNC
250  * @tc.level Level 1
251  * @tc.require: issuesI9KPRL
252  */
253 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0700, testing::ext::TestSize.Level1)
254 {
255     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0700";
256     try {
257         ServiceClient::serviceProxy_ = nullptr;
258         UniqueFd remoteCap1;
259         vector<BundleName> bundlesToRestore;
260         EXPECT_TRUE(restoreSession != nullptr);
261         auto err = restoreSession->AppendBundles(move(remoteCap1), bundlesToRestore);
262         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
263 
264         EXPECT_CALL(*proxy, AppendBundlesRestoreSessionData(_, _, _, _)).WillOnce(Return(0));
265         UniqueFd remoteCap2;
266         ServiceClient::serviceProxy_ = proxy;
267         err = restoreSession->AppendBundles(move(remoteCap2), bundlesToRestore);
268         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
269     } catch (...) {
270         EXPECT_TRUE(true);
271         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
272     }
273     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0700";
274 }
275 
276 /**
277  * @tc.number: SUB_b_incremental_session_test_0800
278  * @tc.name: SUB_b_incremental_session_test_0800
279  * @tc.desc: 测试 Release 接口
280  * @tc.size: MEDIUM
281  * @tc.type: FUNC
282  * @tc.level Level 1
283  * @tc.require: issuesI9KPRL
284  */
285 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0800, testing::ext::TestSize.Level1)
286 {
287     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0800";
288     try {
289         ServiceClient::serviceProxy_ = nullptr;
290         EXPECT_TRUE(restoreSession != nullptr);
291         auto err = restoreSession->Release();
292         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
293 
294         EXPECT_CALL(*proxy, Release()).WillOnce(Return(0));
295         ServiceClient::serviceProxy_ = proxy;
296         err = restoreSession->Release();
297         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
298     } catch (...) {
299         EXPECT_TRUE(false);
300         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
301     }
302     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0800";
303 }
304 
305 /**
306  * @tc.number: SUB_b_incremental_session_test_0900
307  * @tc.name: SUB_b_incremental_session_test_0900
308  * @tc.desc: 测试 PublishFile 接口
309  * @tc.size: MEDIUM
310  * @tc.type: FUNC
311  * @tc.level Level 1
312  * @tc.require: issuesI9KPRL
313  */
314 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_0900, testing::ext::TestSize.Level1)
315 {
316     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_0900";
317     try {
318         ServiceClient::serviceProxy_ = nullptr;
319         BFileInfo fileInfo;
320         EXPECT_TRUE(restoreSession != nullptr);
321         auto err = restoreSession->PublishFile(fileInfo);
322         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
323 
324         EXPECT_CALL(*proxy, PublishIncrementalFile(_)).WillOnce(Return(0));
325         ServiceClient::serviceProxy_ = proxy;
326         err = restoreSession->PublishFile(fileInfo);
327         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
328     } catch (...) {
329         EXPECT_TRUE(true);
330         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
331     }
332     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_0900";
333 }
334 
335 
336 /**
337  * @tc.number: SUB_b_incremental_session_test_1000
338  * @tc.name: SUB_b_incremental_session_test_1000
339  * @tc.desc: 测试 GetFileHandle 接口
340  * @tc.size: MEDIUM
341  * @tc.type: FUNC
342  * @tc.level Level 1
343  * @tc.require: issuesI9KPRL
344  */
345 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1000, testing::ext::TestSize.Level1)
346 {
347     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1000";
348     try {
349         ServiceClient::serviceProxy_ = nullptr;
350         string bundleName;
351         string fileName;
352         EXPECT_TRUE(restoreSession != nullptr);
353         auto err = restoreSession->GetFileHandle(bundleName, fileName);
354         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
355 
356         EXPECT_CALL(*proxy, GetIncrementalFileHandle(_, _)).WillOnce(Return(0));
357         ServiceClient::serviceProxy_ = proxy;
358         err = restoreSession->GetFileHandle(bundleName, fileName);
359         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
360     } catch (...) {
361         EXPECT_TRUE(true);
362         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
363     }
364     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1000";
365 }
366 
367 /**
368  * @tc.number: SUB_b_incremental_session_test_1100
369  * @tc.name: SUB_b_incremental_session_test_1100
370  * @tc.desc: 测试 AppendBundles 接口
371  * @tc.size: MEDIUM
372  * @tc.type: FUNC
373  * @tc.level Level 1
374  * @tc.require: issuesI9KPRL
375  */
376 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1100, testing::ext::TestSize.Level1)
377 {
378     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1100";
379     try {
380         ServiceClient::serviceProxy_ = nullptr;
381         UniqueFd remoteCap;
382         vector<BundleName> bundlesToRestore;
383         vector<std::string> detailInfos;
384         EXPECT_TRUE(restoreSession != nullptr);
385         auto err = restoreSession->AppendBundles(move(remoteCap), bundlesToRestore, detailInfos);
386         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
387 
388         EXPECT_CALL(*proxy, AppendBundlesRestoreSessionDataByDetail(_, _, _, _, _)).WillOnce(Return(0));
389         ServiceClient::serviceProxy_ = proxy;
390         err = restoreSession->AppendBundles(move(remoteCap), bundlesToRestore, detailInfos);
391         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
392     } catch (...) {
393         EXPECT_TRUE(true);
394         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
395     }
396     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1100";
397 }
398 
399 /**
400  * @tc.number: SUB_b_incremental_session_test_1200
401  * @tc.name: SUB_b_incremental_session_test_1200
402  * @tc.desc: 测试 Init 接口
403  * @tc.size: MEDIUM
404  * @tc.type: FUNC
405  * @tc.level Level 1
406  * @tc.require: issuesI9KPRL
407  */
408 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1200, testing::ext::TestSize.Level1)
409 {
410     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1200";
411     try {
412         ServiceClient::serviceProxy_ = nullptr;
413         BIncrementalSessionRestoreAsync::Callbacks callbacks;
414         EXPECT_TRUE(restoreAsyncSession != nullptr);
415         auto err = restoreAsyncSession->Init(callbacks);
416         EXPECT_EQ(err, nullptr);
417 
418         EXPECT_CALL(*proxy, InitRestoreSession(_)).WillOnce(Return(-1)).WillOnce(Return(0));
419         ServiceClient::serviceProxy_ = proxy;
420         err = restoreAsyncSession->Init(callbacks);
421         EXPECT_EQ(err, nullptr);
422         err = restoreAsyncSession->Init(callbacks);
423         EXPECT_NE(err, nullptr);
424     } catch (...) {
425         EXPECT_TRUE(false);
426         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
427     }
428     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1200";
429 }
430 
RestoreAsyncSeviceDied()431 void RestoreAsyncSeviceDied() {}
432 /**
433  * @tc.number: SUB_b_incremental_session_test_1300
434  * @tc.name: SUB_b_incremental_session_test_1300
435  * @tc.desc: 测试 RegisterBackupServiceDied 接口
436  * @tc.size: MEDIUM
437  * @tc.type: FUNC
438  * @tc.level Level 1
439  * @tc.require: issuesI9KPRL
440  */
441 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1300, testing::ext::TestSize.Level1)
442 {
443     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1300";
444     try {
445         ServiceClient::serviceProxy_ = nullptr;
446         EXPECT_TRUE(restoreAsyncSession != nullptr);
447         restoreAsyncSession->RegisterBackupServiceDied(nullptr);
448 
449         ServiceClient::serviceProxy_ = proxy;
450         restoreAsyncSession->RegisterBackupServiceDied(nullptr);
451 
452         EXPECT_CALL(*proxy, AsObject()).WillOnce(Return(nullptr));
453         restoreAsyncSession->RegisterBackupServiceDied(RestoreAsyncSeviceDied);
454     } catch (...) {
455         EXPECT_TRUE(true);
456         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
457     }
458     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1300";
459 }
460 
461 /**
462  * @tc.number: SUB_b_incremental_session_test_1400
463  * @tc.name: SUB_b_incremental_session_test_1400
464  * @tc.desc: 测试 AppendBundles 接口
465  * @tc.size: MEDIUM
466  * @tc.type: FUNC
467  * @tc.level Level 1
468  * @tc.require: issuesI9KPRL
469  */
470 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1400, testing::ext::TestSize.Level1)
471 {
472     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1400";
473     try {
474         ServiceClient::serviceProxy_ = nullptr;
475         UniqueFd remoteCap1;
476         vector<BundleName> bundlesToRestore;
477         EXPECT_TRUE(restoreAsyncSession != nullptr);
478         auto err = restoreAsyncSession->AppendBundles(move(remoteCap1), bundlesToRestore);
479         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
480 
481         EXPECT_CALL(*proxy, AppendBundlesRestoreSessionData(_, _, _, _)).WillOnce(Return(0));
482         UniqueFd remoteCap2;
483         ServiceClient::serviceProxy_ = proxy;
484         err = restoreAsyncSession->AppendBundles(move(remoteCap2), bundlesToRestore);
485         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
486     } catch (...) {
487         EXPECT_TRUE(true);
488         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
489     }
490     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1400";
491 }
492 
493 /**
494  * @tc.number: SUB_b_incremental_session_test_1500
495  * @tc.name: SUB_b_incremental_session_test_1500
496  * @tc.desc: 测试 PublishFile 接口
497  * @tc.size: MEDIUM
498  * @tc.type: FUNC
499  * @tc.level Level 1
500  * @tc.require: issuesI9KPRL
501  */
502 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1500, testing::ext::TestSize.Level1)
503 {
504     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1500";
505     try {
506         ServiceClient::serviceProxy_ = nullptr;
507         BFileInfo fileInfo;
508         EXPECT_TRUE(restoreAsyncSession != nullptr);
509         auto err = restoreAsyncSession->PublishFile(fileInfo);
510         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
511 
512         EXPECT_CALL(*proxy, PublishIncrementalFile(_)).WillOnce(Return(0));
513         ServiceClient::serviceProxy_ = proxy;
514         err = restoreAsyncSession->PublishFile(fileInfo);
515         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
516     } catch (...) {
517         EXPECT_TRUE(true);
518         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
519     }
520     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1500";
521 }
522 
523 
524 /**
525  * @tc.number: SUB_b_incremental_session_test_1600
526  * @tc.name: SUB_b_incremental_session_test_1600
527  * @tc.desc: 测试 GetFileHandle 接口
528  * @tc.size: MEDIUM
529  * @tc.type: FUNC
530  * @tc.level Level 1
531  * @tc.require: issuesI9KPRL
532  */
533 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1600, testing::ext::TestSize.Level1)
534 {
535     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1600";
536     try {
537         ServiceClient::serviceProxy_ = nullptr;
538         string bundleName;
539         string fileName;
540         EXPECT_TRUE(restoreAsyncSession != nullptr);
541         auto err = restoreAsyncSession->GetFileHandle(bundleName, fileName);
542         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
543 
544         EXPECT_CALL(*proxy, GetIncrementalFileHandle(_, _)).WillOnce(Return(0));
545         ServiceClient::serviceProxy_ = proxy;
546         err = restoreAsyncSession->GetFileHandle(bundleName, fileName);
547         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
548     } catch (...) {
549         EXPECT_TRUE(true);
550         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
551     }
552     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1600";
553 }
554 
555 /**
556  * @tc.number: SUB_b_incremental_session_test_1700
557  * @tc.name: SUB_b_incremental_session_test_1700
558  * @tc.desc: 测试 AppendBundles 接口
559  * @tc.size: MEDIUM
560  * @tc.type: FUNC
561  * @tc.level Level 1
562  * @tc.require: issuesI9KPRL
563  */
564 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1700, testing::ext::TestSize.Level1)
565 {
566     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1700";
567     try {
568         ServiceClient::serviceProxy_ = nullptr;
569         UniqueFd remoteCap;
570         vector<BundleName> bundlesToRestore;
571         vector<std::string> detailInfos;
572         EXPECT_TRUE(restoreAsyncSession != nullptr);
573         auto err = restoreAsyncSession->AppendBundles(move(remoteCap), bundlesToRestore, detailInfos);
574         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
575 
576         EXPECT_CALL(*proxy, AppendBundlesRestoreSessionDataByDetail(_, _, _, _, _)).WillOnce(Return(0));
577         ServiceClient::serviceProxy_ = proxy;
578         err = restoreAsyncSession->AppendBundles(move(remoteCap), bundlesToRestore, detailInfos);
579         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
580     } catch (...) {
581         EXPECT_TRUE(true);
582         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
583     }
584     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1700";
585 }
586 
587 /**
588  * @tc.number: SUB_b_incremental_session_test_1800
589  * @tc.name: SUB_b_incremental_session_test_1800
590  * @tc.desc: 测试 Release 接口
591  * @tc.size: MEDIUM
592  * @tc.type: FUNC
593  * @tc.level Level 1
594  * @tc.require: issuesI9KPRL
595  */
596 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1800, testing::ext::TestSize.Level1)
597 {
598     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1800";
599     try {
600         ServiceClient::serviceProxy_ = nullptr;
601         EXPECT_TRUE(restoreAsyncSession != nullptr);
602         auto err = restoreAsyncSession->Release();
603         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
604 
605         EXPECT_CALL(*proxy, Release()).WillOnce(Return(0));
606         ServiceClient::serviceProxy_ = proxy;
607         err = restoreAsyncSession->Release();
608         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
609     } catch (...) {
610         EXPECT_TRUE(false);
611         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
612     }
613     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1800";
614 }
615 
616 /**
617  * @tc.number: SUB_b_incremental_session_test_1900
618  * @tc.name: SUB_b_incremental_session_test_1900
619  * @tc.desc: 测试 AppendBundles 接口
620  * @tc.size: MEDIUM
621  * @tc.type: FUNC
622  * @tc.level Level 1
623  * @tc.require: issuesI9KPRL
624  */
625 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_1900, testing::ext::TestSize.Level1)
626 {
627     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_1900";
628     try {
629         ServiceClient::serviceProxy_ = nullptr;
630         vector<BIncrementalData> bundlesToBackup;
631         vector<std::string> infos;
632         EXPECT_TRUE(backupSession != nullptr);
633         auto err = backupSession->AppendBundles(bundlesToBackup, infos);
634         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
635 
636         EXPECT_CALL(*proxy, AppendBundlesIncrementalBackupSessionWithBundleInfos(_, _)).WillOnce(Return(0));
637         ServiceClient::serviceProxy_ = proxy;
638         err = backupSession->AppendBundles(bundlesToBackup, infos);
639         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
640     } catch (...) {
641         EXPECT_TRUE(true);
642         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
643     }
644     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_1900";
645 }
646 
647 /**
648  * @tc.number: SUB_b_incremental_session_test_2000
649  * @tc.name: SUB_b_incremental_session_test_2000
650  * @tc.desc: 测试 PublishSAFile 接口
651  * @tc.size: MEDIUM
652  * @tc.type: FUNC
653  * @tc.level Level 1
654  * @tc.require: issuesI9KPRL
655  */
656 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2000, testing::ext::TestSize.Level1)
657 {
658     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2000";
659     try {
660         ServiceClient::serviceProxy_ = nullptr;
661         BFileInfo fileInfo;
662         UniqueFd fd;
663         EXPECT_TRUE(restoreSession != nullptr);
664         auto err = restoreSession->PublishSAFile(fileInfo, move(fd));
665         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
666 
667         EXPECT_CALL(*proxy, PublishSAIncrementalFile(_, _)).WillOnce(Return(0));
668         ServiceClient::serviceProxy_ = proxy;
669         err = restoreSession->PublishSAFile(fileInfo, move(fd));
670         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
671     } catch (...) {
672         EXPECT_TRUE(true);
673         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
674     }
675     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2000";
676 }
677 
678 /**
679  * @tc.number: SUB_b_incremental_session_test_2100
680  * @tc.name: SUB_b_incremental_session_test_2100
681  * @tc.desc: 测试 Cancel 接口
682  * @tc.size: MEDIUM
683  * @tc.type: FUNC
684  * @tc.level Level 1
685  * @tc.require: issuesI9KPRL
686  */
687 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2100, testing::ext::TestSize.Level1)
688 {
689     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2100";
690     try {
691         ServiceClient::serviceProxy_ = nullptr;
692         std::string bundleName;
693         EXPECT_TRUE(backupSession != nullptr);
694         auto err = backupSession->Cancel(bundleName);
695         EXPECT_EQ(err, BError(BError::BackupErrorCode::E_CANCEL_UNSTARTED_TASK).GetCode());
696 
697         EXPECT_CALL(*proxy, CancelForResult(_, _)).WillOnce(DoAll(SetArgReferee<1>(0), Return(0)));
698         ServiceClient::serviceProxy_ = proxy;
699         err = backupSession->Cancel(bundleName);
700         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
701     } catch (...) {
702         EXPECT_TRUE(false);
703         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by Cancel.";
704     }
705     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2100";
706 }
707 
708 /**
709  * @tc.number: SUB_b_incremental_session_test_2200
710  * @tc.name: SUB_b_incremental_session_test_2200
711  * @tc.desc: 测试 Cancel 接口
712  * @tc.size: MEDIUM
713  * @tc.type: FUNC
714  * @tc.level Level 1
715  * @tc.require: issuesI9KPRL
716  */
717 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2200, testing::ext::TestSize.Level1)
718 {
719     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2200";
720     try {
721         ServiceClient::serviceProxy_ = nullptr;
722         std::string bundleName;
723         EXPECT_TRUE(restoreSession != nullptr);
724         auto err = restoreSession->Cancel(bundleName);
725         EXPECT_EQ(err, BError(BError::BackupErrorCode::E_CANCEL_UNSTARTED_TASK).GetCode());
726 
727         EXPECT_CALL(*proxy, CancelForResult(_, _)).WillOnce(DoAll(SetArgReferee<1>(0), Return(0)));
728         ServiceClient::serviceProxy_ = proxy;
729         err = restoreSession->Cancel(bundleName);
730         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
731     } catch (...) {
732         EXPECT_TRUE(false);
733         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by Cancel.";
734     }
735     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2200";
736 }
737 
738 /**
739  * @tc.number: SUB_b_incremental_session_test_2300
740  * @tc.name: SUB_b_incremental_session_test_2300
741  * @tc.desc: 测试 Cancel 接口
742  * @tc.size: MEDIUM
743  * @tc.type: FUNC
744  * @tc.level Level 1
745  * @tc.require: issuesI9KPRL
746  */
747 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2300, testing::ext::TestSize.Level1)
748 {
749     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2300";
750     try {
751         ServiceClient::serviceProxy_ = nullptr;
752         std::string bundleName;
753         EXPECT_TRUE(restoreAsyncSession != nullptr);
754         auto err = restoreAsyncSession->Cancel(bundleName);
755         EXPECT_EQ(err, BError(BError::BackupErrorCode::E_CANCEL_UNSTARTED_TASK).GetCode());
756 
757         EXPECT_CALL(*proxy, CancelForResult(_, _)).WillOnce(DoAll(SetArgReferee<1>(0), Return(0)));
758         ServiceClient::serviceProxy_ = proxy;
759         err = restoreAsyncSession->Cancel(bundleName);
760         EXPECT_EQ(err, BError(BError::Codes::OK).GetCode());
761     } catch (...) {
762         EXPECT_TRUE(false);
763         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by Cancel.";
764     }
765     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2300";
766 }
767 
768 /**
769  * @tc.number: SUB_b_incremental_session_test_2400
770  * @tc.name: SUB_b_incremental_session_test_2400
771  * @tc.desc: 测试 InitIncrementalBackupSession 接口
772  * @tc.size: MEDIUM
773  * @tc.type: FUNC
774  * @tc.level Level 1
775  * @tc.require: issuesI9KPRL
776  */
777 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2400, testing::ext::TestSize.Level1)
778 {
779     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2400";
780     try {
781         std::string errMsg;
782         ErrCode errCode;
783         ServiceClient::serviceProxy_ = nullptr;
784         BIncrementalBackupSession::Callbacks callbacks;
785         EXPECT_TRUE(backupSession != nullptr);
786         auto err = backupSession->Init(callbacks, errMsg, errCode);
787         EXPECT_EQ(err, nullptr);
788 
789         EXPECT_CALL(*proxy, InitIncrementalBackupSessionWithErrMsg(_, _, _))
790                     .WillOnce(DoAll(SetArgReferee<1>(-1), Return(0)))
791                     .WillOnce(DoAll(SetArgReferee<1>(0), Return(0)));
792         ServiceClient::serviceProxy_ = proxy;
793         err = backupSession->Init(callbacks, errMsg, errCode);
794         EXPECT_EQ(err, nullptr);
795         err = backupSession->Init(callbacks, errMsg, errCode);
796         EXPECT_NE(err, nullptr);
797     } catch (...) {
798         EXPECT_TRUE(false);
799         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
800     }
801     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2400";
802 }
803 
804 /**
805  * @tc.number: SUB_b_incremental_session_test_2500
806  * @tc.name: SUB_b_incremental_session_test_2500
807  * @tc.desc: 测试 Init 接口
808  * @tc.size: MEDIUM
809  * @tc.type: FUNC
810  * @tc.level Level 1
811  * @tc.require: issuesI9KPRL
812  */
813 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2500, testing::ext::TestSize.Level1)
814 {
815     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2500";
816     try {
817         std::string errMsg;
818         ErrCode errCode;
819         ServiceClient::serviceProxy_ = nullptr;
820         BIncrementalRestoreSession::Callbacks callbacks;
821         EXPECT_TRUE(restoreSession != nullptr);
822         auto err = restoreSession->Init(callbacks, errMsg, errCode);
823         EXPECT_EQ(err, nullptr);
824 
825         EXPECT_CALL(*proxy, InitRestoreSessionWithErrMsg(_, _, _))
826                     .WillOnce(DoAll(SetArgReferee<1>(-1), Return(0)))
827                     .WillOnce(DoAll(SetArgReferee<1>(0), Return(0)));
828         ServiceClient::serviceProxy_ = proxy;
829         err = restoreSession->Init(callbacks, errMsg, errCode);
830         EXPECT_EQ(err, nullptr);
831         err = restoreSession->Init(callbacks, errMsg, errCode);
832         EXPECT_NE(err, nullptr);
833     } catch (...) {
834         EXPECT_TRUE(false);
835         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by RemoveExtConn.";
836     }
837     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2500";
838 }
839 
840 /**
841  * @tc.number: SUB_b_incremental_session_test_2600
842  * @tc.name: SUB_b_incremental_session_test_2600
843  * @tc.desc: 测试 GetLocalCapabilities 接口
844  * @tc.size: MEDIUM
845  * @tc.type: FUNC
846  * @tc.level Level 1
847  * @tc.require: issuesI9KPRL
848  */
849 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2600, testing::ext::TestSize.Level1)
850 {
851     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2600";
852     try {
853         ServiceClient::serviceProxy_ = nullptr;
854         EXPECT_TRUE(backupSession != nullptr);
855         auto err = backupSession->GetLocalCapabilities();
856         EXPECT_EQ(err.Get(), -EPERM);
857 
858         ServiceClient::serviceProxy_ = proxy;
859         EXPECT_CALL(*proxy, GetLocalCapabilitiesForBundleInfos(_)).WillOnce(Return(-1));
860         err = backupSession->GetLocalCapabilities();
861         EXPECT_EQ(err.Get(), -EPERM);
862 
863         EXPECT_CALL(*proxy, GetLocalCapabilitiesForBundleInfos(_))
864             .WillOnce(DoAll(testing::SetArgReferee<0>(0), Return(0)));
865         err = backupSession->GetLocalCapabilities();
866         EXPECT_EQ(err.Get(), 0);
867     } catch (...) {
868         EXPECT_TRUE(false);
869         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by GetLocalCapabilities.";
870     }
871     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2600";
872 }
873 
874 /**
875  * @tc.number: SUB_b_incremental_session_test_2700
876  * @tc.name: SUB_b_incremental_session_test_2700
877  * @tc.desc: 测试 GetLocalCapabilities 接口
878  * @tc.size: MEDIUM
879  * @tc.type: FUNC
880  * @tc.level Level 1
881  * @tc.require: issuesI9KPRL
882  */
883 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2700, testing::ext::TestSize.Level1)
884 {
885     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2700";
886     try {
887         ServiceClient::serviceProxy_ = nullptr;
888         EXPECT_TRUE(restoreSession != nullptr);
889         auto err = restoreSession->GetLocalCapabilities();
890         EXPECT_EQ(err.Get(), -EPERM);
891 
892         ServiceClient::serviceProxy_ = proxy;
893         EXPECT_CALL(*proxy, GetLocalCapabilitiesForBundleInfos(_)).WillOnce(Return(-1));
894         err = restoreSession->GetLocalCapabilities();
895         EXPECT_EQ(err.Get(), -EPERM);
896 
897         EXPECT_CALL(*proxy, GetLocalCapabilitiesForBundleInfos(_))
898             .WillOnce(DoAll(testing::SetArgReferee<0>(0), Return(0)));
899         err = restoreSession->GetLocalCapabilities();
900         EXPECT_EQ(err.Get(), 0);
901     } catch (...) {
902         EXPECT_TRUE(false);
903         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by GetLocalCapabilities.";
904     }
905     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2700";
906 }
907 
908 /**
909  * @tc.number: SUB_b_incremental_session_test_2800
910  * @tc.name: SUB_b_incremental_session_test_2800
911  * @tc.desc: 测试 GetBackupDataSize 接口
912  * @tc.size: MEDIUM
913  * @tc.type: FUNC
914  * @tc.level Level 1
915  * @tc.require: issuesI9KPRL
916  */
917 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2800, testing::ext::TestSize.Level1)
918 {
919     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2800";
920     try {
921         bool isPreciseScan = false;
922         vector<BIncrementalData> bundleNameList;
923         ServiceClient::serviceProxy_ = nullptr;
924         ASSERT_TRUE(backupSession != nullptr);
925         auto err = backupSession->GetBackupDataSize(isPreciseScan, bundleNameList);
926         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
927 
928         ServiceClient::serviceProxy_ = proxy;
929         EXPECT_CALL(*proxy, GetBackupDataSize(_, _)).WillOnce(Return(BError(BError::Codes::SDK_BROKEN_IPC).GetCode()));
930         err = backupSession->GetBackupDataSize(isPreciseScan, bundleNameList);
931         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
932 
933         EXPECT_CALL(*proxy, GetBackupDataSize(_, _)).WillOnce(Return(BError(BError::Codes::OK).GetCode()));
934         err = backupSession->GetBackupDataSize(isPreciseScan, bundleNameList);
935         EXPECT_EQ(err, ERR_OK);
936     } catch (...) {
937         EXPECT_TRUE(false);
938         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by GetBackupDataSize.";
939     }
940     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2800";
941 }
942 
943 /**
944  * @tc.number: SUB_b_incremental_session_test_2900
945  * @tc.name: SUB_b_incremental_session_test_2900
946  * @tc.desc: 测试 CleanBundleTempDir 接口
947  * @tc.size: MEDIUM
948  * @tc.type: FUNC
949  * @tc.level Level 1
950  * @tc.require: IC7RHQ
951  */
952 HWTEST_F(IncrementalSessionTest, SUB_b_incremental_session_test_2900, testing::ext::TestSize.Level1)
953 {
954     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_b_incremental_session_test_2900";
955     try {
956         std::string bundleName;
957         ServiceClient::serviceProxy_ = nullptr;
958         ASSERT_TRUE(backupSession != nullptr);
959         auto err = backupSession->CleanBundleTempDir(bundleName);
960         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
961 
962         ServiceClient::serviceProxy_ = proxy;
963         EXPECT_CALL(*proxy, CleanBundleTempDir(_)).WillOnce(Return(BError(BError::Codes::SDK_BROKEN_IPC).GetCode()));
964         err = backupSession->CleanBundleTempDir(bundleName);
965         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
966 
967         EXPECT_CALL(*proxy, CleanBundleTempDir(_)).WillOnce(Return(BError(BError::Codes::OK).GetCode()));
968         err = backupSession->CleanBundleTempDir(bundleName);
969         EXPECT_EQ(err, ERR_OK);
970     } catch (...) {
971         EXPECT_TRUE(false);
972         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by CleanBundleTempDir.";
973     }
974     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_b_incremental_session_test_2900";
975 }
976 
977 /**
978  * @tc.number: SUB_BIncrementalBackupSession_GetCompatibilityInfo_0000
979  * @tc.name: SUB_BIncrementalBackupSession_GetCompatibilityInfo_0000
980  * @tc.desc: 测试 GetCompatibilityInfo 接口
981  * @tc.size: MEDIUM
982  * @tc.type: FUNC
983  * @tc.level Level 1
984  * @tc.require: NA
985  */
986 HWTEST_F(IncrementalSessionTest, SUB_BIncrementalBackupSession_GetCompatibilityInfo_0000, testing::ext::TestSize.Level1)
987 {
988     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_BIncrementalBackupSession_GetCompatibilityInfo_0000";
989     try {
990         std::string bundleName = "com.example.app";
991         std::string extInfo = "";
992         std::string compatInfo = "";
993 
994         ServiceClient::serviceProxy_ = nullptr;
995         ASSERT_TRUE(backupSession != nullptr);
996         auto err = backupSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
997         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
998 
999         ServiceClient::serviceProxy_ = proxy;
1000         EXPECT_CALL(*proxy, GetCompatibilityInfo(_, _, _))
1001             .WillOnce(Return(BError(BError::Codes::SDK_INVAL_ARG).GetCode()));
1002         err = backupSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
1003         EXPECT_EQ(err, BError(BError::Codes::SDK_INVAL_ARG).GetCode());
1004 
1005         EXPECT_CALL(*proxy, GetCompatibilityInfo(_, _, _)).WillOnce(Return(BError(BError::Codes::OK).GetCode()));
1006         err = backupSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
1007         EXPECT_EQ(err, ERROR_OK);
1008     } catch (...) {
1009         EXPECT_TRUE(false);
1010         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by GetCompatibilityInfo.";
1011     }
1012     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_BIncrementalBackupSession_GetCompatibilityInfo_0000";
1013 }
1014 
1015 /**
1016  * @tc.number: SUB_BIncrementalStoreSession_GetCompatibilityInfo_0000
1017  * @tc.name: SUB_BIncrementalStoreSession_GetCompatibilityInfo_0000
1018  * @tc.desc: 测试 GetCompatibilityInfo 接口
1019  * @tc.size: MEDIUM
1020  * @tc.type: FUNC
1021  * @tc.level Level 1
1022  * @tc.require: NA
1023  */
1024 HWTEST_F(IncrementalSessionTest, SUB_BIncrementalStoreSession_GetCompatibilityInfo_0000, testing::ext::TestSize.Level1)
1025 {
1026     GTEST_LOG_(INFO) << "IncrementalSessionTest-begin SUB_BIncrementalStoreSession_GetCompatibilityInfo_0000";
1027     try {
1028         std::string bundleName = "com.example.app";
1029         std::string extInfo = "";
1030         std::string compatInfo = "";
1031 
1032         ServiceClient::serviceProxy_ = nullptr;
1033         ASSERT_TRUE(restoreSession != nullptr);
1034         auto err = restoreSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
1035         EXPECT_EQ(err, BError(BError::Codes::SDK_BROKEN_IPC).GetCode());
1036 
1037         ServiceClient::serviceProxy_ = proxy;
1038         EXPECT_CALL(*proxy, GetCompatibilityInfo(_, _, _))
1039             .WillOnce(Return(BError(BError::Codes::SDK_INVAL_ARG).GetCode()));
1040         err = restoreSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
1041         EXPECT_EQ(err, BError(BError::Codes::SDK_INVAL_ARG).GetCode());
1042 
1043         EXPECT_CALL(*proxy, GetCompatibilityInfo(_, _, _)).WillOnce(Return(BError(BError::Codes::OK).GetCode()));
1044         err = restoreSession->GetCompatibilityInfo(bundleName, extInfo, compatInfo);
1045         EXPECT_EQ(err, ERROR_OK);
1046     } catch (...) {
1047         EXPECT_TRUE(false);
1048         GTEST_LOG_(INFO) << "IncrementalSessionTest-an exception occurred by GetCompatibilityInfo.";
1049     }
1050     GTEST_LOG_(INFO) << "IncrementalSessionTest-end SUB_BIncrementalStoreSession_GetCompatibilityInfo_0000";
1051 }
1052 } // namespace OHOS::FileManagement::Backup