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
81 namespace OHOS {
82 List<TestCaseInfo> UITestGroup::testCaseList_;
83
AddTestCase(TestCaseInfo testCaseInfo)84 void UITestGroup::AddTestCase(TestCaseInfo testCaseInfo)
85 {
86 testCaseList_.PushBack(testCaseInfo);
87 }
88
SetUpTestCase()89 void UITestGroup::SetUpTestCase()
90 {
91 testCaseList_.PushBack(TestCaseInfo{"View zIndex", new UITestViewZIndex()});
92 testCaseList_.PushBack(TestCaseInfo{"EditText", new UITestEditText()});
93 testCaseList_.PushBack(TestCaseInfo{"Clip", new UITestClip()});
94 #if ENABLE_ROTATE_INPUT
95 testCaseList_.PushBack(TestCaseInfo{"Rotate_Input", new UITestRotateInput()});
96 #endif
97 testCaseList_.PushBack(TestCaseInfo{"View_Scale_Rotate", new UITestViewScaleRotate()});
98 #if ENABLE_VECTOR_FONT
99 if (UIFont::GetInstance()->IsVectorFont()) {
100 testCaseList_.PushBack(TestCaseInfo{"Vector_Font", new UITestVectorFont()});
101 }
102 #endif
103 testCaseList_.PushBack(TestCaseInfo{"Input_Event", new UITestInputEvent()});
104 testCaseList_.PushBack(TestCaseInfo{"Button", new UITestBUTTON()});
105 testCaseList_.PushBack(TestCaseInfo{"UILabel", new UITestLabel()});
106 testCaseList_.PushBack(TestCaseInfo{"Image", new UITestImage()});
107 testCaseList_.PushBack(TestCaseInfo{"Basic_Layout", new UITestBasicLayout()});
108 testCaseList_.PushBack(TestCaseInfo{"Advanced_Layout", new UITestAdvancedLayout()});
109 testCaseList_.PushBack(TestCaseInfo{"ListLayout", new UITestListLayout()});
110 testCaseList_.PushBack(TestCaseInfo{"UIScrollView", new UITestUIScrollView()});
111 testCaseList_.PushBack(TestCaseInfo{"Box_Progress", new UITestBoxProgress()});
112 testCaseList_.PushBack(TestCaseInfo{"Circle_Progress", new UITestCircleProgress()});
113 testCaseList_.PushBack(TestCaseInfo{"Slider", new UITestSlider()});
114 testCaseList_.PushBack(TestCaseInfo{"Animator", new UITestAnimator()});
115 testCaseList_.PushBack(TestCaseInfo{"Canvas", new UITestCanvas()});
116 testCaseList_.PushBack(TestCaseInfo{"Draw_Rect", new UITestDrawRect()});
117 testCaseList_.PushBack(TestCaseInfo{"Draw_Line", new UITestDrawLine()});
118 testCaseList_.PushBack(TestCaseInfo{UI_TEST_RENDER_ID, new UITestRender()});
119 testCaseList_.PushBack(TestCaseInfo{"Anti_Aliasing", new UITestAntiAliasing()});
120 testCaseList_.PushBack(TestCaseInfo{"UIList", new UITestUIList()});
121 testCaseList_.PushBack(TestCaseInfo{"UISwipeView", new UITestUISwipeView()});
122 testCaseList_.PushBack(TestCaseInfo{"Image_Animator", new UITestImageAnimator()});
123 testCaseList_.PushBack(TestCaseInfo{"UIPicker", new UITestUIPicker()});
124 testCaseList_.PushBack(TestCaseInfo{"Font", new UITestFont()});
125 testCaseList_.PushBack(TestCaseInfo{"Arc_Label", new UITestArcLabel()});
126 #if ENABLE_DEBUG
127 testCaseList_.PushBack(TestCaseInfo{"Event_Injector", new UITestEventInjector()});
128 testCaseList_.PushBack(TestCaseInfo{"Dump_Dom", new UITestDumpDomTree()});
129 testCaseList_.PushBack(TestCaseInfo{"View Bounds", new UITestViewBounds()});
130 #ifdef VERSION_STANDARD
131 testCaseList_.PushBack(TestCaseInfo{"Screenshot", new UITestScreenshot()});
132 #endif
133 #endif // ENABLE_DEBUG
134 testCaseList_.PushBack(TestCaseInfo{"View_Percent", new UITestViewPercent()});
135 testCaseList_.PushBack(TestCaseInfo{"Texture_Mapper", new UITestTextureMapper()});
136 testCaseList_.PushBack(TestCaseInfo{"Chart_Polyline", new UITestChartPolyline()});
137 testCaseList_.PushBack(TestCaseInfo{"Chart_Pillar", new UITestChartPillar()});
138 #if ENABLE_WINDOW
139 testCaseList_.PushBack(TestCaseInfo{"Dialog", new UITestDialog()});
140 #endif
141 testCaseList_.PushBack(TestCaseInfo{"Analog_Clock", new UITestAnalogClock()});
142 testCaseList_.PushBack(TestCaseInfo{"Digital_Clock", new UITestDigitalClock()});
143 testCaseList_.PushBack(TestCaseInfo{"Transform", new UITestTransform()});
144 testCaseList_.PushBack(TestCaseInfo{"Opacity", new UITestOpacity()});
145 testCaseList_.PushBack(TestCaseInfo{"UIQrcode", new UITestQrcode()});
146 testCaseList_.PushBack(TestCaseInfo{"UIViewGroup", new UITestViewGroup()});
147 testCaseList_.PushBack(TestCaseInfo{"View Bitmap", new UITestViewBitmap()});
148 #ifndef VERSION_LITE
149 #if ENABLE_VIDEO_COMPONENT
150 testCaseList_.PushBack(TestCaseInfo{"Video", new UITestVideo()});
151 #endif
152 #endif
153 #if ENABLE_FOCUS_MANAGER
154 testCaseList_.PushBack(TestCaseInfo{"FocusManager", new UITestFocusManager()});
155 #endif
156 testCaseList_.PushBack(TestCaseInfo{"Border_Margin_Padding", new UITestBorderMarginPadding()});
157 testCaseList_.PushBack(TestCaseInfo{"ScrollBar", new UITestScrollBar()});
158 }
159
GetTestCase()160 List<TestCaseInfo>& UITestGroup::GetTestCase()
161 {
162 return testCaseList_;
163 }
164
GetTestCase(const char * id)165 UITest* UITestGroup::GetTestCase(const char* id)
166 {
167 if (id == nullptr) {
168 return nullptr;
169 }
170 ListNode<TestCaseInfo>* node = testCaseList_.Begin();
171 while (node != testCaseList_.End()) {
172 if (!strcmp(id, node->data_.sliceId)) {
173 return node->data_.testObj;
174 }
175 node = node->next_;
176 }
177 return nullptr;
178 }
TearDownTestCase()179 void UITestGroup::TearDownTestCase()
180 {
181 ListNode<TestCaseInfo>* node = testCaseList_.Begin();
182 while (node != testCaseList_.End()) {
183 delete node->data_.testObj;
184 node->data_.testObj = nullptr;
185 node = node->next_;
186 }
187 testCaseList_.Clear();
188 }
189 } // namespace OHOS
190