1 /* 2 * Copyright (c) 2022 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_COMPONENTS_NG_TEST_MOCK_RESOURCE_MOCK_RESOURCE_ADAPTER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_RESOURCE_MOCK_RESOURCE_ADAPTER_H 18 19 #include "gmock/gmock.h" 20 21 #include "core/components/theme/resource_adapter.h" 22 23 namespace OHOS::Ace { 24 class MockResourceAdapter : public ResourceAdapter { 25 DECLARE_ACE_TYPE(MockResourceAdapter, ResourceAdapter); 26 27 public: 28 MockResourceAdapter() = default; 29 ~MockResourceAdapter() override = default; 30 MOCK_METHOD0(Create, RefPtr<ResourceAdapter>()); 31 MOCK_METHOD1(Init, void(const ResourceInfo& resourceInfo)); 32 MOCK_METHOD2(UpdateConfig, void(const ResourceConfiguration& config, bool themeFlag)); 33 MOCK_METHOD1(GetTheme, RefPtr<ThemeStyle>(int32_t themeId)); 34 MOCK_METHOD1(GetColor, Color(uint32_t resId)); 35 MOCK_METHOD1(GetDimension, Dimension(uint32_t resId)); 36 MOCK_METHOD1(GetString, std::string(uint32_t resId)); 37 MOCK_METHOD1(GetDouble, double(uint32_t resId)); 38 MOCK_METHOD1(GetInt, int32_t(uint32_t resId)); 39 MOCK_METHOD2(GetPluralString, std::string(uint32_t resId, int quantity)); 40 MOCK_METHOD1(GetMediaPath, std::string(uint32_t resId)); 41 MOCK_METHOD1(GetRawfile, std::string(const std::string& fileName)); 42 MOCK_METHOD3(GetRawFileData, bool(const std::string& rawFile, size_t& len, std::unique_ptr<uint8_t[]>& dest)); 43 MOCK_METHOD3(GetMediaData, bool(uint32_t resId, size_t& len, std::unique_ptr<uint8_t[]>& dest)); 44 MOCK_METHOD3(GetMediaData, bool(const std::string& resName, size_t& len, std::unique_ptr<uint8_t[]>& dest)); 45 MOCK_METHOD2(UpdateResourceManager, void(const std::string& bundleName, const std::string& moduleName)); 46 MOCK_CONST_METHOD1(GetBoolean, bool(uint32_t resId)); 47 MOCK_CONST_METHOD1(GetIntArray, std::vector<uint32_t>(uint32_t resId)); 48 MOCK_CONST_METHOD2(GetResource, bool(uint32_t resId, std::ostream& dest)); 49 MOCK_CONST_METHOD2(GetResource, bool(const std::string& resId, std::ostream& dest)); 50 MOCK_CONST_METHOD3(GetIdByName, bool(const std::string& resName, const std::string& resType, uint32_t& resId)); 51 MOCK_CONST_METHOD1(GetStringArray, std::vector<std::string>(uint32_t resId)); 52 }; 53 } // namespace OHOS::Ace 54 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_TEST_MOCK_RESOURCE_MOCK_RESOURCE_ADAPTER_H 55