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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_UNITTEST_ROSEN_MOCK_ROSEN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_UNITTEST_ROSEN_MOCK_ROSEN_H 18 19 #include "gmock/gmock.h" 20 #include "base/resource/asset_manager.h" 21 22 namespace OHOS::Ace { 23 class MockAsset final : public Asset { 24 public: 25 ~MockAsset() override = default; 26 27 MOCK_METHOD(size_t, GetSize, (), (const, override)); 28 MOCK_METHOD(uint8_t*, GetData, (), (const, override)); 29 }; 30 31 class MockAssetProvider final : public AssetProvider { 32 public: 33 ~MockAssetProvider() override = default; 34 35 MOCK_METHOD(std::string, GetAssetPath, (const std::string& /* assetName */, bool /* isAddHapPath */), 36 (override)); 37 MOCK_METHOD(bool, IsValid, (), (const, override)); 38 MOCK_METHOD(void, GetAssetList, (const std::string& path, std::vector<std::string>& assetList), (override)); 39 MOCK_METHOD(bool, GetFileInfo, (const std::string& /* fileName */, MediaFileInfo& /* fileInfo */), 40 (const, override)); 41 MOCK_METHOD(RefPtr<Asset>, GetAsset, (const std::string& assetName)); 42 }; 43 44 class MockAssetManager final : public AssetManager { 45 public: 46 ~MockAssetManager() override = default; 47 48 MOCK_METHOD(void, PushFront, (RefPtr<AssetProvider> provider), (override)); 49 MOCK_METHOD(void, PushBack, (RefPtr<AssetProvider> provider), (override)); 50 MOCK_METHOD(RefPtr<Asset>, GetAsset, (const std::string& assetName), (override)); 51 MOCK_METHOD(std::vector<RefPtr<Asset>>, GetAssetFromI18n, (const std::string& assetName), (override)); 52 MOCK_METHOD(std::string, GetAssetPath, (const std::string& /* assetName */, bool /* isAddHapPath */), 53 (override)); 54 MOCK_METHOD(void, SetLibPath, (const std::string& appLibPathKey, const std::vector<std::string>& packagePath), 55 (override)); 56 MOCK_METHOD(std::string, GetAppLibPathKey, (), (const, override)); 57 MOCK_METHOD(std::vector<std::string>, GetLibPath, (), (const, override)); 58 MOCK_METHOD(void, GetAssetList, (const std::string& path, std::vector<std::string>& assetList), 59 (const, override)); 60 MOCK_METHOD(bool, GetFileInfo, (const std::string& /* fileName */, MediaFileInfo& /* fileInfo */), 61 (const, override)); 62 }; 63 } 64 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_TEST_UNITTEST_ROSEN_MOCK_ROSEN_H 65 66