1 /*
2  * Copyright (c) 2020-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 #include "ui_test_group.h"
17 
18 #include "graphic_config.h"
19 #include "test_animator/ui_test_animator.h"
20 #include "test_anti_aliasing/ui_test_anti_aliasing.h"
21 #include "test_arc_label/ui_test_arc_label.h"
22 #include "test_border_margin_padding/ui_test_border_margin_padding.h"
23 #include "test_button/ui_test_button.h"
24 #include "test_canvas/ui_test_canvas.h"
25 #include "test_chart/ui_test_chart_pillar.h"
26 #include "test_chart/ui_test_chart_polyline.h"
27 #include "test_clip/ui_test_clip.h"
28 #ifdef ENABLE_WINDOW
29 #include "test_dialog/ui_test_dialog.h"
30 #endif
31 #include "test_draw_line/ui_test_draw_line.h"
32 #include "test_draw_rect/ui_test_draw_rect.h"
33 #include "test_edit_text/ui_test_edit_text.h"
34 #include "test_event_injector/ui_test_event_injector.h"
35 #if ENABLE_FOCUS_MANAGER
36 #include "test_focus_manager/ui_test_focus_manager.h"
37 #endif
38 #include "test_font/ui_test_font.h"
39 #include "test_image/ui_test_image.h"
40 #include "test_image_animator/ui_test_image_animator.h"
41 #include "test_input_event/ui_test_input_event.h"
42 #include "test_label/ui_test_label.h"
43 #include "test_layout/ui_test_advanced_layout.h"
44 #include "test_layout/ui_test_basic_layout.h"
45 #include "test_opacity/ui_test_opacity.h"
46 #include "test_picker/ui_test_ui_picker.h"
47 #include "test_progress_bar/ui_test_box_progress.h"
48 #include "test_progress_bar/ui_test_circle_progress.h"
49 #include "test_qrcode/ui_test_qrcode.h"
50 #include "test_render/ui_test_render.h"
51 #if ENABLE_ROTATE_INPUT
52 #include "test_rotate_input/ui_test_rotate_input.h"
53 #endif
54 #ifdef VERSION_STANDARD
55 #include "test_screenshot/ui_test_screenshot.h"
56 #endif
57 #include "test_digital_clock/ui_test_digital_clock.h"
58 #include "test_scroll_bar/ui_test_scroll_bar.h"
59 #include "test_slider/ui_test_slider.h"
60 #include "test_texture_mapper/ui_test_texture_mapper.h"
61 #include "test_transform/ui_test_transform.h"
62 #include "test_ui_analog_clock/ui_test_analog_clock.h"
63 #include "test_ui_dump_dom_tree/ui_test_dump_dom.h"
64 #include "test_ui_list/ui_test_ui_list.h"
65 #include "test_ui_list_view/ui_test_list_layout.h"
66 #include "test_ui_scroll_view/ui_test_ui_scroll_view.h"
67 #include "test_ui_swipe_view/ui_test_ui_swipe_view.h"
68 #include "test_view_bitmap/ui_test_view_bitmap.h"
69 #include "test_view_bounds/ui_test_view_bounds.h"
70 #include "test_view_group/ui_test_view_group.h"
71 #include "test_view_percent/ui_test_view_percent.h"
72 #include "test_view_zindex/ui_test_view_zindex.h"
73 #include "test_view_scale_rotate/ui_test_view_scale_rotate.h"
74 #if ENABLE_VECTOR_FONT
75 #include "test_vector_font/ui_test_vector_font.h"
76 #endif
77 #ifndef VERSION_LITE
78 #include "test_video/ui_test_video.h"
79 #endif
80 #include "test_spannable_string/ui_test_spannable_string.h"
81 
82 namespace OHOS {
83 List<TestCaseInfo> UITestGroup::testCaseList_;
84 
AddTestCase(TestCaseInfo testCaseInfo)85 void UITestGroup::AddTestCase(TestCaseInfo testCaseInfo)
86 {
87     testCaseList_.PushBack(testCaseInfo);
88 }
89 
SetUpTestCase()90 void UITestGroup::SetUpTestCase()
91 {
92     testCaseList_.PushBack(TestCaseInfo { "SpannableString", new UITestSpannableString() });
93     testCaseList_.PushBack(TestCaseInfo { "View zIndex", new UITestViewZIndex() });
94     testCaseList_.PushBack(TestCaseInfo { "EditText", new UITestEditText() });
95     testCaseList_.PushBack(TestCaseInfo { "Clip", new UITestClip() });
96 #if defined(ENABLE_ROTATE_INPUT) && ENABLE_ROTATE_INPUT
97     testCaseList_.PushBack(TestCaseInfo { "Rotate_Input", new UITestRotateInput() });
98 #endif
99     testCaseList_.PushBack(TestCaseInfo { "View_Scale_Rotate", new UITestViewScaleRotate() });
100 #if defined(ENABLE_VECTOR_FONT) && ENABLE_VECTOR_FONT
101     if (UIFont::GetInstance()->IsVectorFont()) {
102         testCaseList_.PushBack(TestCaseInfo { "Vector_Font", new UITestVectorFont() });
103     }
104 #endif
105     testCaseList_.PushBack(TestCaseInfo { "Input_Event", new UITestInputEvent() });
106     testCaseList_.PushBack(TestCaseInfo { "Button", new UITestBUTTON() });
107     testCaseList_.PushBack(TestCaseInfo { "UILabel", new UITestLabel() });
108     testCaseList_.PushBack(TestCaseInfo { "Image", new UITestImage() });
109     testCaseList_.PushBack(TestCaseInfo { "Basic_Layout", new UITestBasicLayout() });
110     testCaseList_.PushBack(TestCaseInfo { "Advanced_Layout", new UITestAdvancedLayout() });
111     testCaseList_.PushBack(TestCaseInfo { "ListLayout", new UITestListLayout() });
112     testCaseList_.PushBack(TestCaseInfo { "UIScrollView", new UITestUIScrollView() });
113     testCaseList_.PushBack(TestCaseInfo { "Box_Progress", new UITestBoxProgress() });
114     testCaseList_.PushBack(TestCaseInfo { "Circle_Progress", new UITestCircleProgress() });
115     testCaseList_.PushBack(TestCaseInfo { "Slider", new UITestSlider() });
116     testCaseList_.PushBack(TestCaseInfo { "Animator", new UITestAnimator() });
117     testCaseList_.PushBack(TestCaseInfo { "Canvas", new UITestCanvas() });
118     testCaseList_.PushBack(TestCaseInfo { "Draw_Rect", new UITestDrawRect() });
119     testCaseList_.PushBack(TestCaseInfo { "Draw_Line", new UITestDrawLine() });
120     testCaseList_.PushBack(TestCaseInfo { UI_TEST_RENDER_ID, new UITestRender() });
121     testCaseList_.PushBack(TestCaseInfo { "Anti_Aliasing", new UITestAntiAliasing() });
122     testCaseList_.PushBack(TestCaseInfo { "UIList", new UITestUIList() });
123     testCaseList_.PushBack(TestCaseInfo { "UISwipeView", new UITestUISwipeView() });
124     testCaseList_.PushBack(TestCaseInfo { "Image_Animator", new UITestImageAnimator() });
125     testCaseList_.PushBack(TestCaseInfo { "UIPicker", new UITestUIPicker() });
126     testCaseList_.PushBack(TestCaseInfo { "Font", new UITestFont() });
127     testCaseList_.PushBack(TestCaseInfo { "Arc_Label", new UITestArcLabel() });
128     SetUpTestCase001();
129 }
130 
SetUpTestCase001()131 void UITestGroup::SetUpTestCase001()
132 {
133 #if defined(ENABLE_DEBUG) && ENABLE_DEBUG
134     testCaseList_.PushBack(TestCaseInfo { "Event_Injector", new UITestEventInjector() });
135     testCaseList_.PushBack(TestCaseInfo { "Dump_Dom", new UITestDumpDomTree() });
136     testCaseList_.PushBack(TestCaseInfo { "View Bounds", new UITestViewBounds() });
137 #ifdef VERSION_STANDARD
138     testCaseList_.PushBack(TestCaseInfo { "Screenshot", new UITestScreenshot() });
139 #endif
140 #endif // ENABLE_DEBUG
141     testCaseList_.PushBack(TestCaseInfo { "View_Percent", new UITestViewPercent() });
142     testCaseList_.PushBack(TestCaseInfo { "Texture_Mapper", new UITestTextureMapper() });
143     testCaseList_.PushBack(TestCaseInfo { "Chart_Polyline", new UITestChartPolyline() });
144     testCaseList_.PushBack(TestCaseInfo { "Chart_Pillar", new UITestChartPillar() });
145 #if defined(ENABLE_WINDOW) && ENABLE_WINDOW
146     testCaseList_.PushBack(TestCaseInfo { "Dialog", new UITestDialog() });
147 #endif
148     testCaseList_.PushBack(TestCaseInfo { "Analog_Clock", new UITestAnalogClock() });
149     testCaseList_.PushBack(TestCaseInfo { "Digital_Clock", new UITestDigitalClock() });
150     testCaseList_.PushBack(TestCaseInfo { "Transform", new UITestTransform() });
151     testCaseList_.PushBack(TestCaseInfo { "Opacity", new UITestOpacity() });
152     testCaseList_.PushBack(TestCaseInfo { "UIQrcode", new UITestQrcode() });
153     testCaseList_.PushBack(TestCaseInfo { "UIViewGroup", new UITestViewGroup() });
154     testCaseList_.PushBack(TestCaseInfo { "View Bitmap", new UITestViewBitmap() });
155 #ifndef VERSION_LITE
156 #if defined(ENABLE_VIDEO_COMPONENT) && ENABLE_VIDEO_COMPONENT
157     testCaseList_.PushBack(TestCaseInfo { "Video", new UITestVideo() });
158 #endif
159 #endif
160 #if defined(ENABLE_FOCUS_MANAGER) && ENABLE_FOCUS_MANAGER
161     testCaseList_.PushBack(TestCaseInfo { "FocusManager", new UITestFocusManager() });
162 #endif
163     testCaseList_.PushBack(TestCaseInfo { "Border_Margin_Padding", new UITestBorderMarginPadding() });
164     testCaseList_.PushBack(TestCaseInfo { "ScrollBar", new UITestScrollBar() });
165 }
166 
GetTestCase()167 List<TestCaseInfo> &UITestGroup::GetTestCase()
168 {
169     return testCaseList_;
170 }
171 
GetTestCase(const char * id)172 UITest *UITestGroup::GetTestCase(const char *id)
173 {
174     if (id == nullptr) {
175         return nullptr;
176     }
177     ListNode<TestCaseInfo> *node = testCaseList_.Begin();
178     while (node != testCaseList_.End()) {
179         if (!strcmp(id, node->data_.sliceId)) {
180             return node->data_.testObj;
181         }
182         node = node->next_;
183     }
184     return nullptr;
185 }
TearDownTestCase()186 void UITestGroup::TearDownTestCase()
187 {
188     ListNode<TestCaseInfo> *node = testCaseList_.Begin();
189     while (node != testCaseList_.End()) {
190         delete node->data_.testObj;
191         node->data_.testObj = nullptr;
192         node = node->next_;
193     }
194     testCaseList_.Clear();
195 }
196 } // namespace OHOS
197