1 /* 2 * Copyright (c) 2023 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 OHOS_CLOUD_SYNC_SA_DATA_HANDER_METHOD_MOCK_H 17 #define OHOS_CLOUD_SYNC_SA_DATA_HANDER_METHOD_MOCK_H 18 19 #include "data_handler.h" 20 21 #include <gmock/gmock.h> 22 #include <gtest/gtest.h> 23 24 namespace OHOS::FileManagement::CloudSync::Test { 25 using namespace testing; 26 using namespace testing::ext; 27 using namespace std; 28 class DataHandlerMethodMock final : public DataHandler { 29 public: DataHandlerMethodMock(int32_t userId,const std::string & bundleName,const std::string & table)30 DataHandlerMethodMock(int32_t userId, const std::string &bundleName, const std::string &table) 31 : DataHandler(userId, bundleName, table) 32 { 33 } 34 MOCK_METHOD1(GetFetchCondition, void(FetchCondition &cond)); 35 MOCK_METHOD2(OnFetchRecords, int32_t(std::shared_ptr<std::vector<DriveKit::DKRecord>> &, OnFetchParams &)); 36 MOCK_METHOD1(GetRetryRecords, int32_t(std::vector<DriveKit::DKRecordId> &records)); 37 MOCK_METHOD2(GetCheckRecords, 38 int32_t(std::vector<DriveKit::DKRecordId> &checkRecords, 39 const std::shared_ptr<std::vector<DriveKit::DKRecord>> &records)); 40 MOCK_METHOD1(GetAssetsToDownload, int32_t(std::vector<DriveKit::DKDownloadAsset> &outAssetsToDownload)); 41 42 MOCK_METHOD2(GetDownloadAsset, 43 int32_t(std::string cloudId, std::vector<DriveKit::DKDownloadAsset> &outAssetsToDownload)); 44 /* upload */ 45 MOCK_METHOD1(GetCreatedRecords, int32_t(std::vector<DriveKit::DKRecord> &records)); 46 MOCK_METHOD1(GetDeletedRecords, int32_t(std::vector<DriveKit::DKRecord> &records)); 47 MOCK_METHOD1(GetMetaModifiedRecords, int32_t(std::vector<DriveKit::DKRecord> &records)); 48 MOCK_METHOD1(GetFileModifiedRecords, int32_t(std::vector<DriveKit::DKRecord> &records)); 49 50 /* upload callback */ 51 MOCK_METHOD1(OnCreateRecords, int32_t(const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult> &map)); 52 MOCK_METHOD1(OnDeleteRecords, int32_t(const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult> &map)); 53 MOCK_METHOD1(OnModifyMdirtyRecords, 54 int32_t(const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult> &map)); 55 MOCK_METHOD1(OnModifyFdirtyRecords, 56 int32_t(const std::map<DriveKit::DKRecordId, DriveKit::DKRecordOperResult> &map)); 57 MOCK_METHOD1(OnDownloadSuccess, int32_t(const DriveKit::DKDownloadAsset &asset)); 58 MOCK_METHOD1(OnDownloadThumb, 59 int32_t(const std::map<DriveKit::DKDownloadAsset, DriveKit::DKDownloadResult> &resultMap)); 60 MOCK_METHOD1(OnDownloadThumb, int32_t(const DriveKit::DKDownloadAsset &asset)); 61 /*clean*/ 62 MOCK_METHOD1(Clean, int32_t(const int action)); 63 64 /* cursor */ 65 MOCK_METHOD1(GetNextCursor, void(DriveKit::DKQueryCursor &cursor)); 66 MOCK_METHOD1(SetTempStartCursor, void(const DriveKit::DKQueryCursor &cursor)); 67 MOCK_METHOD1(GetTempStartCursor, void(DriveKit::DKQueryCursor &cursor)); 68 MOCK_METHOD2(SetTempNextCursor, void(const DriveKit::DKQueryCursor &cursor, bool isFinish)); 69 MOCK_METHOD0(GetBatchNo, int32_t()); 70 MOCK_METHOD0(IsPullRecords, bool()); 71 MOCK_METHOD0(ClearCursor, void()); 72 MOCK_METHOD1(FinishPull, void(const int32_t barchNo)); 73 MOCK_METHOD1(SetRecordSize, void(const int32_t recordSize)); 74 MOCK_METHOD0(GetRecordSize, int32_t()); 75 MOCK_METHOD0(GetCheckFlag, bool()); 76 MOCK_METHOD0(SetChecking, void()); 77 }; 78 } // namespace OHOS::FileManagement::CloudSync::Test 79 #endif 80