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