1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. All rights reserved. 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_CONVERTOR_MOCK_H 17 #define OHOS_CLOUD_SYNC_SA_DATA_CONVERTOR_MOCK_H 18 19 #include "abs_rdb_predicates.h" 20 #include "rdb_helper.h" 21 #include "result_set.h" 22 #include "value_object.h" 23 #include "values_bucket.h" 24 25 #include <gmock/gmock.h> 26 #include <gtest/gtest.h> 27 28 namespace OHOS::FileManagement::CloudSync::Test { 29 using namespace testing; 30 using namespace testing::ext; 31 using namespace std; 32 using namespace NativeRdb; 33 34 class DataConvertorMock final : public DataConvertor { 35 public: 36 DataConvertorMock() = default; 37 virtual ~DataConvertorMock() = default; 38 Convert(DriveKit::DKRecord & record,NativeRdb::ResultSet & resultSet)39 int32_t Convert(DriveKit::DKRecord &record, NativeRdb::ResultSet &resultSet) 40 { 41 return E_OK; 42 } Convert(DriveKit::DKRecord & record,NativeRdb::ValuesBucket & valueBucket)43 int32_t Convert(DriveKit::DKRecord &record, NativeRdb::ValuesBucket &valueBucket) 44 { 45 return E_OK; 46 } 47 48 MOCK_METHOD2(HandleErr, void(int32_t, NativeRdb::ResultSet &resultSet)); 49 MOCK_METHOD2(ResultSetToRecords, int32_t(const std::shared_ptr<NativeRdb::ResultSet> resultSet, 50 std::vector<DriveKit::DKRecord> &records)); 51 MOCK_METHOD2(RecordToValueBucket, int32_t(DriveKit::DKRecord &record, NativeRdb::ValuesBucket &valueBucket)); 52 MOCK_METHOD2(GetLongComp, int32_t(const DriveKit::DKRecordField &field, int64_t &val)); 53 MOCK_METHOD3(GetInt, int32_t(const std::string &key, int32_t &val, NativeRdb::ResultSet &resultSet)); 54 MOCK_METHOD3(GetLong, int32_t(const std::string &key, int64_t &val, NativeRdb::ResultSet &resultSet)); 55 MOCK_METHOD3(GetDouble, int32_t(const std::string &key, double &val, NativeRdb::ResultSet &resultSet)); 56 MOCK_METHOD3(GetString, int32_t(const std::string &key, std::string &val, NativeRdb::ResultSet &resultSet)); 57 MOCK_METHOD3(GetBool, int32_t(const std::string &key, bool &val, NativeRdb::ResultSet &resultSet)); 58 MOCK_METHOD4(HandleField, 59 int32_t(const DriveKit::DKRecordField &value, 60 NativeRdb::ValuesBucket &bucket, 61 const std::string &field, 62 DataType type)); 63 }; 64 65 } // namespace OHOS::FileManagement::CloudSync::Test 66 #endif