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_PERCENT_TDD_TEST_H 17 #define OHOS_ACELITE_PERCENT_TDD_TEST_H 18 19 #include "acelite_config.h" 20 #include "component.h" 21 #ifdef TDD_ASSERTIONS 22 #include <climits> 23 #include <gtest/gtest.h> 24 #endif 25 #include "test_common.h" 26 #include "wrapper/js.h" 27 28 namespace OHOS { 29 namespace ACELite { 30 #ifdef TDD_ASSERTIONS 31 using namespace std; 32 using namespace testing::ext; 33 class PercentTddTest : public testing::Test { 34 #else 35 class PercentTddTest { 36 #endif 37 public: 38 PercentTddTest() = default; 39 ~PercentTddTest() = default; 40 void SetUp(); 41 void TearDown(); 42 void PercentParse001(); 43 void PercentParse002(); 44 void PercentParse003(); 45 void PercentParse004(); 46 void PercentParse005(); 47 void PercentParse006(); 48 void PercentParse007(); 49 void PercentParse008(); 50 void PercentParse009(); 51 void PercentParse010(); 52 void PercentParse011(); 53 void PercentSupport001(); 54 void PercentSupport002(); 55 void PercentSupport003(); 56 void PercentSupport004(); 57 void RunTests(); 58 void PrepareOptions(JSValue &option, JSValue &staticStyle) const; 59 // following functions are used to setup the specific style items in percent format 60 void SetStyleWithValue(JSValue target, const char *key, const char *value) const; 61 void ConfigStylesWithRect(JSValue staticStyle, const char *widthValue, const char *heightValue) const; 62 void ConfigStylesWithPosition(JSValue staticStyle, const char *topValue, const char *leftValue) const; 63 void ConfigStylesWithMargin(JSValue staticStyle, const char *marginValue) const; 64 void ConfigStylesWithMargins(JSValue staticStyle, 65 const char *marginTopValue, 66 const char *marginLeftValue, 67 const char *marginRightValue, 68 const char *marginBottomValue) const; 69 void VerifyDimension(JSValue element, uint16_t keyID, int16_t targetPX) const; 70 void DumpJSObjectJson(JSValue value) const; 71 Component *BuildViewTree(JSValue component, int16_t parentWidth, int16_t parentHeight) const; 72 73 static const char * const ATTR_STATIC_STYLE_NAME; 74 static const char * const STYLE_WIDTH_NAME; 75 static const char * const STYLE_HEIGHT_NAME; 76 static const char * const STYLE_TOP_NAME; 77 static const char * const STYLE_LEFT_NAME; 78 static const char * const STYLE_MARGINTOP_NAME; 79 static const char * const STYLE_MARGINLEFT_NAME; 80 static const char * const STYLE_MARGINRIGHT_NAME; 81 static const char * const STYLE_MARGINBOTTOM_NAME; 82 static const char * const FUNC_CREATE_ELEMENT; 83 static const uint8_t ARG_LENGTH_1 = 1; 84 static const uint8_t ARG_LENGTH_2 = 2; 85 static const uint8_t ARG_LENGTH_3 = 3; 86 }; 87 } // namespace ACELite 88 } // namespace OHOS 89 #endif // OHOS_ACELITE_PERCENT_TDD_TEST_H 90