1 /* 2 * Copyright (c) 2021 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 OHOS_ACELITE_TEST_CONSTANTS_H 17 #define OHOS_ACELITE_TEST_CONSTANTS_H 18 19 #ifdef TDD_ASSERTIONS 20 #include <climits> 21 #include <gtest/gtest.h> 22 #else 23 #include <typeinfo.h> 24 #endif 25 26 #include "component_factory.h" 27 #include "js_app_environment.h" 28 #include "root_component_mock.h" 29 #include "root_view.h" 30 #include "stylemgr/app_style_item.h" 31 #include "stylemgr/app_style_manager.h" 32 #include "test_common.h" 33 34 namespace OHOS { 35 namespace ACELite { 36 #ifdef TDD_ASSERTIONS 37 using namespace std; 38 using namespace testing::ext; 39 class BaseTest : public testing::Test { 40 #else 41 class BaseTest { 42 #endif 43 public: 44 BaseTest(); ~BaseTest()45 virtual ~BaseTest() {} 46 void SetUp(); 47 void TearDown(); 48 49 protected: 50 jerry_value_t globObj_; 51 jerry_value_t attrsObj_; 52 jerry_value_t styleObj_; 53 uint16_t componentNameId_; 54 55 Component *GetRenderedComponent(uint16_t componentKeyId) const; 56 void ReleaseComponent(Component *&component) const; 57 ColorType GetRGBColor(int32_t colorIntValue) const; 58 void UpdateNumAttributeOrStyleValue(Component *component, 59 const char *attributeName, 60 const int32_t newNumValue, 61 bool isToSetAttribute) const; 62 void UpdateCharAttributeOrStyleValue(Component *component, 63 const char *attributeName, 64 const char *newCharValue, 65 bool isToSetAttribute) const; 66 uint16_t SetCompnentNameId(const char *componentName); 67 68 private: 69 RootComponentMock rootComponentMock_; 70 }; 71 } // namespace ACELite 72 } // namespace OHOS 73 #endif // OHOS_ACELITE_TEST_CONSTANTS_H 74