/* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_DM_DATASHARE_HELPER_MOCK_H #define OHOS_DM_DATASHARE_HELPER_MOCK_H #include #include "datashare_helper.h" namespace OHOS { namespace DistributedHardware { using OHOS::AAFwk::IDataAbilityObserver; using OHOS::DataShare::BatchUpdateResult; using OHOS::DataShare::Data; using OHOS::DataShare::DatashareBusinessError; using OHOS::DataShare::DataShareHelper; using OHOS::DataShare::DataSharePredicates; using OHOS::DataShare::DataShareResultSet; using OHOS::DataShare::DataShareValuesBucket; using OHOS::DataShare::OperationStatement; using OHOS::DataShare::ExecResultSet; using OHOS::DataShare::OperationResult; using OHOS::DataShare::PublishedDataChangeNode; using OHOS::DataShare::RdbChangeNode; using OHOS::DataShare::Template; using OHOS::DataShare::TemplateId; using OHOS::DataShare::UpdateOperations; using namespace OHOS::DataShare; class DataShareHelperMock : public DataShareHelper { public: static std::shared_ptr GetOrCreateInstance(); static void ReleaseInstance(); MOCK_METHOD(bool, Release, ()); MOCK_METHOD(std::vector, GetFileTypes, (Uri &, const std::string &)); MOCK_METHOD(int, OpenFile, (Uri &, const std::string &)); MOCK_METHOD(int, OpenFileWithErrCode, (Uri &, const std::string &, int32_t &)); MOCK_METHOD(int, OpenRawFile, (Uri &, const std::string &)); MOCK_METHOD(int, Insert, (Uri &, const DataShareValuesBucket &)); MOCK_METHOD(int, InsertExt, (Uri &, const DataShareValuesBucket &, std::string &)); MOCK_METHOD(int, Update, (Uri &, const DataSharePredicates &, const DataShareValuesBucket &)); MOCK_METHOD(int, BatchUpdate, (const UpdateOperations &, std::vector &)); MOCK_METHOD(int, Delete, (Uri &, const DataSharePredicates &)); MOCK_METHOD(std::shared_ptr, Query, (Uri &, const DataSharePredicates &, std::vector &, DatashareBusinessError *)); MOCK_METHOD(std::string, GetType, (Uri &)); MOCK_METHOD(int, BatchInsert, (Uri &, const std::vector &)); MOCK_METHOD(int, ExecuteBatch, (const std::vector &, ExecResultSet &)); MOCK_METHOD(int, RegisterObserver, (const Uri &, const sptr &)); MOCK_METHOD(int, UnregisterObserver, (const Uri &, const sptr &)); MOCK_METHOD(void, NotifyChange, (const Uri &)); MOCK_METHOD(int, RegisterObserverExtProvider, (const Uri &uri, const std::shared_ptr dataObserver, bool isDescendants), (override)); MOCK_METHOD(int, UnregisterObserverExtProvider, (const Uri &uri, const std::shared_ptr dataObserver), (override)); MOCK_METHOD(void, NotifyChangeExtProvider, (const DataShareObserver::ChangeInfo &changeInfo), (override)); MOCK_METHOD(Uri, NormalizeUri, (Uri &)); MOCK_METHOD(Uri, DenormalizeUri, (Uri &)); MOCK_METHOD(int, AddQueryTemplate, (const std::string &, int64_t, Template &)); MOCK_METHOD(int, DelQueryTemplate, (const std::string &, int64_t)); MOCK_METHOD(std::vector, Publish, (const Data &, const std::string &)); MOCK_METHOD(Data, GetPublishedData, (const std::string &, int &)); MOCK_METHOD(std::vector, SubscribeRdbData, (const std::vector &, const TemplateId &, const std::function &)); MOCK_METHOD(std::vector, UnsubscribeRdbData, (const std::vector &, const TemplateId &)); MOCK_METHOD(std::vector, EnableRdbSubs, (const std::vector &, const TemplateId &)); MOCK_METHOD(std::vector, DisableRdbSubs, (const std::vector &, const TemplateId &)); MOCK_METHOD(std::vector, SubscribePublishedData, (const std::vector &, int64_t, const std::function &)); MOCK_METHOD(std::vector, UnsubscribePublishedData, (const std::vector &, int64_t)); MOCK_METHOD(std::vector, EnablePubSubs, (const std::vector &, int64_t)); MOCK_METHOD(std::vector, DisablePubSubs, (const std::vector &, int64_t)); private: DataShareHelperMock() = default; ~DataShareHelperMock() override = default; static std::shared_ptr instance_; }; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_DATASHARE_HELPER_MOCK_H