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 #ifndef ACELITE_STYLEMGR_TDD_TEST_H 16 #define ACELITE_STYLEMGR_TDD_TEST_H 17 18 #ifdef TDD_ASSERTIONS 19 #include <climits> 20 #include <gtest/gtest.h> 21 #else 22 #include <typeinfo.h> 23 #endif 24 25 #include "acelite_config.h" 26 #include "component_factory.h" 27 #include "root_component_mock.h" 28 #include "test_common.h" 29 30 namespace OHOS { 31 namespace ACELite { 32 static char* g_currentTestCaseName = nullptr; 33 static uint8_t g_assertRecord = 0; 34 static AppStyleManager* g_testStyleMgr = nullptr; 35 #ifdef TDD_ASSERTIONS 36 using namespace std; 37 using namespace testing::ext; 38 class StyleMgrTddTest : public testing::Test { 39 #else 40 class StyleMgrTddTest { 41 #endif 42 public: 43 StyleMgrTddTest(); ~StyleMgrTddTest()44 ~StyleMgrTddTest() {} 45 void SetUp(); 46 void TearDown(); 47 void TestCaseB(const char* name) const; 48 void JudeTestCaseResult() const; 49 void ReleaseTestResources(const jerry_value_t* values, 50 uint8_t valueCount, 51 Component** components, 52 uint8_t componentCount) const; 53 JSValue PrepareStyleSheet(const char* selectors, 54 const char* selectorName, 55 const char* propName, 56 uint16_t propValue) const; 57 JSValue PrepareStyleSheetWithKeyValues(const char* selector, 58 JSValue selectorObj, 59 const char* selectorName, 60 const uint8_t itemCount, 61 char* keys[], 62 const uint16_t values[]) const; 63 JSValue PreparePesudoObjects(uint16_t value) const; 64 65 JSValue PrepareStyleOption(const char* styleType, const char* propName, uint16_t propValue) const; 66 JSValue PrepareAttrOption(const char* propName, const char* propValue) const; 67 void AddValueToAttrOption(jerry_value_t attrOption, const char* propName, const char* propValue) const; 68 void AddStrValueToOption(jerry_value_t option, const char* propName, const char* propValue) const; 69 70 void ACELiteStyleManagerInlineStyle001(); 71 void ACELiteStyleManagerInlineStyle002(); 72 void ACELiteStyleManagerInlineStyle003(); 73 void ACELiteStyleManagerInlineStyle004(); 74 void ACELiteStyleManagerInlineStyle005(); 75 void ACELiteStyleManagerIDSelector001(); 76 void ACELiteStyleManagerIDSelector002(); 77 void ACELiteStyleManagerIDSelector003(); 78 void ACELiteStyleManagerIDSelector004(); 79 void ACELiteStyleManagerIDSelector005(); 80 void ACELiteStyleManagerClassSelector001(); 81 void ACELiteStyleManagerClassSelector002(); 82 void ACELiteStyleManagerClassSelector003(); 83 void ACELiteStyleManagerCSSPesudo001(); 84 void RunTests(); 85 86 private: 87 RootComponentMock rootComponentMock_; 88 }; 89 } // namespace ACELite 90 } // namespace OHOS 91 #endif // ACELITE_STYLEMGR_TDD_TEST_H 92