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 #ifndef MOCK_CLOUD_FILE_KIT_H
17 #define MOCK_CLOUD_FILE_KIT_H
18
19 #include <gtest/gtest.h>
20 #include <gmock/gmock.h>
21 #include <memory>
22
23 #include "cloud_file_kit.h"
24 #include "dfs_error.h"
25
26 namespace OHOS::FileManagement::CloudFile {
27
28 class ICloudFileKit {
29 public:
30 virtual CloudFileKit *GetInstance() = 0;
31 virtual int32_t GetAppConfigParams(const int32_t userId,
32 const std::string &bundleName, std::map<std::string, std::string> ¶m) = 0;
33 virtual ~ICloudFileKit() = default;
34 static inline std::shared_ptr<ICloudFileKit> proxy_{nullptr};
35 };
36
37 class MockCloudFileKit : public ICloudFileKit {
38 public:
39 MOCK_METHOD0(GetInstance, CloudFileKit *());
40 MOCK_METHOD3(GetAppConfigParams, int32_t(const int32_t userId,
41 const std::string &bundleName, std::map<std::string, std::string> ¶m));
42 };
43
GetInstance()44 CloudFileKit *CloudFileKit::GetInstance()
45 {
46 if (ICloudFileKit::proxy_ != nullptr) {
47 return ICloudFileKit::proxy_->GetInstance();
48 }
49 return nullptr;
50 }
51
GetAppConfigParams(const int32_t userId,const std::string & bundleName,std::map<std::string,std::string> & param)52 int32_t CloudFileKit::GetAppConfigParams(const int32_t userId,
53 const std::string &bundleName,
54 std::map<std::string, std::string> ¶m)
55 {
56 if (ICloudFileKit::proxy_ != nullptr) {
57 return ICloudFileKit::proxy_->GetAppConfigParams(userId, bundleName, param);
58 }
59 return E_OK;
60 }
61 } // OHOS::FileManagement::CloudFile
62 #endif // MOCK_CLOUD_FILE_KIT_H