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