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 "cloud_sync_manager_core.h"
17
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20 #include <sys/types.h>
21 #include <sys/xattr.h>
22
23 #include "cloud_sync_manager.h"
24 #include "dfs_error.h"
25 #include "uri.h"
26 #include "utils_log.h"
27
28 namespace OHOS::FileManagement::CloudDisk::Test {
29 using namespace testing;
30 using namespace testing::ext;
31 using namespace std;
32 using namespace OHOS::FileManagement::CloudSync;
33
34 class CloudSyncManagerCoreTest : public testing::Test {
35 public:
36 static void SetUpTestCase(void);
37 static void TearDownTestCase(void);
38 void SetUp();
39 void TearDown();
40 };
41
SetUpTestCase(void)42 void CloudSyncManagerCoreTest::SetUpTestCase(void)
43 {
44 GTEST_LOG_(INFO) << "SetUpTestCase";
45 }
46
TearDownTestCase(void)47 void CloudSyncManagerCoreTest::TearDownTestCase(void)
48 {
49 GTEST_LOG_(INFO) << "TearDownTestCase";
50 }
51
SetUp(void)52 void CloudSyncManagerCoreTest::SetUp(void)
53 {
54 GTEST_LOG_(INFO) << "SetUp";
55 }
56
TearDown(void)57 void CloudSyncManagerCoreTest::TearDown(void)
58 {
59 GTEST_LOG_(INFO) << "TearDown";
60 }
61
62 /**
63 * @tc.name: DoChangeAppCloudSwitch
64 * @tc.desc: Verify the CloudSyncManagerCore::DoChangeAppCloudSwitch function
65 * @tc.type: FUNC
66 */
67 HWTEST_F(CloudSyncManagerCoreTest, DoChangeAppCloudSwitchTest1, TestSize.Level1)
68 {
69 std::string accoutId = "100";
70 std::string bundleName = "com.example.test";
71 bool status = true;
72 auto data = CloudSyncManagerCore::DoChangeAppCloudSwitch(accoutId, bundleName, status);
73 EXPECT_TRUE(data.IsSuccess());
74 }
75
76 /**
77 * @tc.name: DoChangeAppCloudSwitch
78 * @tc.desc: Verify the CloudSyncManagerCore::DoChangeAppCloudSwitch function
79 * @tc.type: FUNC
80 */
81 HWTEST_F(CloudSyncManagerCoreTest, DoChangeAppCloudSwitchTest2, TestSize.Level1)
82 {
83 std::string accoutId = "100";
84 std::string bundleName = "com.example.test";
85 bool status = false;
86 auto data = CloudSyncManagerCore::DoChangeAppCloudSwitch(accoutId, bundleName, status);
87 EXPECT_TRUE(data.IsSuccess());
88 }
89
90 /**
91 * @tc.name: DoNotifyEventChange
92 * @tc.desc: Verify the CloudSyncManagerCore::DoNotifyEventChange function
93 * @tc.type: FUNC
94 */
95 HWTEST_F(CloudSyncManagerCoreTest, DoNotifyEventChangeTest1, TestSize.Level1)
96 {
97 int32_t userId = 100;
98 std::string eventId = "testId";
99 std::string extraData = "testData";
100 auto data = CloudSyncManagerCore::DoNotifyEventChange(userId, eventId, extraData);
101 EXPECT_FALSE(data.IsSuccess());
102 }
103
104 /**
105 * @tc.name: DoNotifyDataChange
106 * @tc.desc: Verify the CloudSyncManagerCore::DoNotifyDataChange function
107 * @tc.type: FUNC
108 */
109 HWTEST_F(CloudSyncManagerCoreTest, DoNotifyDataChangeTest1, TestSize.Level1)
110 {
111 std::string accoutId = "100";
112 std::string bundleName = "com.example.test";
113 auto data = CloudSyncManagerCore::DoNotifyDataChange(accoutId, bundleName);
114 EXPECT_TRUE(data.IsSuccess());
115 }
116
117 /**
118 * @tc.name: DoDisableCloud
119 * @tc.desc: Verify the CloudSyncManagerCore::DoDisableCloud function
120 * @tc.type: FUNC
121 */
122 HWTEST_F(CloudSyncManagerCoreTest, DoDisableCloudTest1, TestSize.Level1)
123 {
124 std::string accoutId = "100";
125 auto data = CloudSyncManagerCore::DoDisableCloud(accoutId);
126 EXPECT_FALSE(data.IsSuccess());
127 }
128
129 /**
130 * @tc.name: DoEnableCloud
131 * @tc.desc: Verify the CloudSyncManagerCore::DoEnableCloud function
132 * @tc.type: FUNC
133 */
134 HWTEST_F(CloudSyncManagerCoreTest, DoEnableCloudTest1, TestSize.Level1)
135 {
136 std::string accoutId = "100";
137 SwitchDataObj switchData;
138 auto data = CloudSyncManagerCore::DoEnableCloud(accoutId, switchData);
139 EXPECT_FALSE(data.IsSuccess());
140 }
141
142 /**
143 * @tc.name: DoClean
144 * @tc.desc: Verify the CloudSyncManagerCore::DoClean function
145 * @tc.type: FUNC
146 */
147 HWTEST_F(CloudSyncManagerCoreTest, DoCleanTest1, TestSize.Level1)
148 {
149 std::string accoutId = "100";
150 CleanOptions cleanOptions {};
151 auto data = CloudSyncManagerCore::DoClean(accoutId, cleanOptions);
152 EXPECT_FALSE(data.IsSuccess());
153 }
154 } // namespace OHOS::FileManagement::CloudDisk::Test