• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2022 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 UI_TEST_CANVAS_H
17 #define UI_TEST_CANVAS_H
18 
19 #include "components/ui_canvas.h"
20 #include "components/ui_label_button.h"
21 #include "components/ui_scroll_view.h"
22 #include "layout/grid_layout.h"
23 #include "ui_test.h"
24 namespace OHOS {
25 class UITestCanvas : public UITest {
26 public:
UITestCanvas()27     UITestCanvas()
28     {}
~UITestCanvas()29     ~UITestCanvas() override
30     {}
31     void SetUp() override;
32     void TearDown() override;
33     const UIView* GetTestView() override;
34     void UIKitCanvasTestDrawLine001();
35     void UIKitCanvasTestDrawLine002();
36     void UIKitCanvasTestDrawCurve001();
37     void UIKitCanvasTestDrawCurve002();
38     void UIKitCanvasTestDrawRect001();
39     void UIKitCanvasTestDrawRect002();
40     void UIKitCanvasTestDrawRect003();
41     void UIKitCanvasTestDrawCircle001();
42     void UIKitCanvasTestDrawCircle002();
43     void UIKitCanvasTestDrawCircle003();
44     void UIKitCanvasTestDrawArc001();
45     void UIKitCanvasTestDrawImage001();
46     void UIKitCanvasTestDrawImage002();
47     void UIKitCanvasTestDrawLabel001();
48     void UIKitCanvasTestDrawSector001();
49     void UIKitCanvasTestClear001();
50     void UIKitCanvasTestDrawPath001();
51     void UIKitCanvasTestDrawPath002();
52     void UIKitCanvasTestDrawPath003();
53     void UIKitCanvasTestDrawPath004();
54     void UIKitCanvasTestDrawPath005();
55     void UIKitCanvasTestDrawPath006();
56     void UIKitCanvasTestDrawPath007();
57     void UIKitCanvasTestDrawPath008();
58     void UIKitCanvasTestDrawPath009();
59     void UIKitCanvasTestDrawPath010();
60     void UIKitCanvasTestDrawPath011();
61     void UIKitCanvasTestDrawPath012();
62     void UIKitCanvasTestDrawPath013();
63     void UIKitCanvasTestDrawPath014();
64     void UIKitCanvasTestDrawPath015();
65     void UIKitCanvasTestDrawPath016();
66     void UIKitCanvasTestDrawPath017();
67     void UIKitCanvasTestDrawPath018();
68     void UIKitCanvasTestDrawPath019();
69     void UIKitCanvasTestDrawPath020();
70     void UIKitCanvasTestDrawPath021();
71     void UIKitCanvasTestDrawPath022();
72     void UIKitCanvasTestDrawPath023();
73     void UIKitCanvasTestDrawPath024();
74     void UIKitCanvasTestDrawPath025();
75     void UIKitCanvasTestDrawPath026();
76     void UIKitCanvasTestDrawPath027();
77     void UIKitCanvasTestDrawPath028();
78     void UIKitCanvasTestDrawPath029();
79     void UIKitCanvasTestDrawPath030();
80     void UIKitCanvasTestDrawPath031();
81     void UIKitCanvasTestDrawPath032();
82     void UIKitCanvasTestDrawPath033();
83     void UIKitCanvasTestDrawPath034();
84     void RM008UIKitCanvasTest001();
85     void RM008UIKitCanvasTest002();
86     void RM008UIKitCanvasTest003();
87     void RM008UIKitCanvasTest004();
88     void RM008UIKitCanvasTest005();
89     void RM008UIKitCanvasTest006();
90     void RM008UIKitCanvasTest007();
91     void RM008UIKitCanvasShadowTest008();
92     void RM009LineCapDrawPath();
93     void RM009LineJoinDrawPath();
94     void RM009LineDashDrawPath();
95     void RM009StrokeAndClearRectDrawPath();
96     void RM011StrokeText001();
97     void RM011CanvasScale001();
98     void RM011CanvasRotate001();
99     void RM012globalAlpha001();
100     void RM012GlobalCompositeOperationSourceOver();
101     void RM012GlobalCompositeOperationSourceAtop();
102     void RM012GlobalCompositeOperationSourceIn();
103     void RM012GlobalCompositeOperationSourceOut();
104     void RM012GlobalCompositeOperationDestinationOver();
105     void RM012GlobalCompositeOperationDestinationAtop();
106     void RM012GlobalCompositeOperationDestinationIn();
107     void RM012GlobalCompositeOperationDestinationOut();
108     void RM012GlobalCompositeOperationLIGHTER();
109     void RM012GlobalCompositeOperationCopy();
110     void RM012GlobalCompositeOperationXOR();
111     void RM012SaveOrRestore002();
112 private:
113     void CreateTitleLabel(const char* title);
114     UICanvas* CreateCanvas();
115 
116     UIScrollView* container_ = nullptr;
117 
118     const int16_t GAP = 10;
119     const int16_t TITLE_HEIGHT = 29;
120     const uint16_t CANVAS_WIDTH = 454;
121     const uint16_t CANVAS_HEIGHT = 200;
122     const int16_t START1_X = 10;
123     const int16_t START1_Y = 10;
124     const int16_t START2_X = 80;
125     const int16_t START2_Y = 10;
126     const int16_t LINE1_X = 40;
127     const int16_t LINE1_Y = 100;
128     const int16_t LINE2_X = 100;
129     const int16_t LINE2_Y = 120;
130     const int16_t CENTER_X = 150;
131     const int16_t CENTER_Y = 150;
132     const int16_t RADIUS = 50;
133     const int16_t START_ANGLE = 30;
134     const int16_t END_ANGLE = 250;
135     const int16_t RECT_X = 250;
136     const int16_t RECT_Y = 50;
137     const int16_t RECT_WIDTH = 100;
138     const int16_t RECT_HEIGHT = 50;
139     const int16_t LINE3_X = 5;
140     const int16_t LINE3_Y = 35;
141     const int16_t LINE4_X = 50;
142     const int16_t LINE4_Y = 5;
143     const int16_t LINE6_X = 60;
144     const int16_t LINE6_Y = 15;
145     const int16_t LINE7_Y = 45;
146     const int16_t LINE8_X = 15;
147     const int16_t LINE8_Y = 45;
148     const int16_t LINE9_X = 230;
149     const int16_t LINE10_Y = 60;
150     const int16_t LINE11_X = 20;
151     const int16_t LINE11_Y = 80;
152     const int16_t LINE12_X = 150;
153     const int16_t LINE13_Y = 20;
154     const int16_t LINE14_X = 180;
155     const int16_t LINE14_Y = 160;
156     const int16_t LINE15_X = 310;
157     const int16_t LINE17_X = 80;
158     const int16_t LINE18_X = 240;
159     const int16_t LINE19_X = 40;
160     const int16_t LINE21_X = 260;
161     const int16_t LINE22_X = 60;
162     const int16_t LINE23_Y = 140;
163     const int16_t LINE24_X = 300;
164     const int16_t LINE25_X = 40;
165     const int16_t LINE25_Y = 40;
166     const int16_t LINE26_X = 120;
167     const int16_t LINE26_Y = 180;
168     const int16_t LINE27_X = 140;
169     const int16_t LINE27_Y = 130;
170     const int16_t LINE28_X = 200;
171     const int16_t LINE29_X = 220;
172     const int16_t LINE30_X = 280;
173     const int16_t LINE31_X = 330;
174     const int16_t LINE32_X = 270;
175     const int16_t LINE33_X = 215;
176     const int16_t LINE34_X = 250;
177     const int16_t TRANSLATE_X = 50;
178     const int16_t TRANSLATE_Y = 50;
179     const uint16_t STROKE3_WIDTH = 3;
180     const uint16_t ARC_RADIUS = 80;
181     const int16_t START1_ANGLE = 0;
182     const int16_t END1_ANGLE = 180;
183     const int16_t HEIGHT_GAP = 8;
184     const int16_t LINE_WIDTH5 = 5;
185     const int16_t LINE_WIDTH10 = 10;
186     const int16_t LINE_WIDTH30 = 30;
187     const int16_t START_X = 50;
188     const int16_t START_Y = 10;
189     const int16_t LINE_CURVE_Y = 50;
190     const int16_t LINE_RECT_Y50 = 50;
191     const int16_t LINE_RECT_X300 = 300;
192     const int16_t LINE_RECT_Y10 = 10;
193     const int16_t LINE_RECT_WIDTH50 = 50;
194     const int16_t LINE_RECT_HEIGHT50 = 50;
195     const int16_t OPARCITY_127 = 127;
196     const int16_t LINE_CURVE_X100 = 100;
197     const int16_t LINE_CURVE_X200 = 200;
198     const int16_t LINE_CURVE_X300 = 300;
199     const int16_t LINE_CURVE_Y100 = 100;
200     const int16_t LINE_CURVE_R30 = 30;
201     const int16_t ARC_X100 = 100;
202     const int16_t ARC_Y150 = 1500;
203     const int16_t ARC_R50 = 50;
204     const int16_t ARC_R100 = 100;
205     const int16_t ARC_ANGLE135 = 135;
206     const int16_t ARC_ANGLE270 = 270;
207     const int16_t ROTATE20 = 20;
208     const int16_t ROTATE_20 = -20;
209     const int16_t ROTATE45 = 45;
210     const int16_t IMAGE_START60 = 60;
211     const int16_t IMAGE_START100 = 100;
212     const int16_t IMAGE_START20 = 20;
213     const int16_t IMAGE_WIDTH100 = 100;
214     const int16_t IMAGE_HEIGHT100 = 100;
215     const int16_t FONT_SIZE30 = 30;
216     const int16_t FONT_SIZE15 = 15;
217     const int16_t FONT_LETTERSPACE = 10;
218     const int16_t FONT_LETTERSPACE2 = 2;
219     const int16_t LABEL_START50 = 50;
220     const int16_t LABEL_WIDTH100 = 100;
221     const int16_t END_ANGLE30 = 30;
222     const int16_t START_X350 = 350;
223     const int16_t START_Y150 = 150;
224     const float DASH10 = 10.0f;
225     const int16_t DASH_COUNT = 4;
226     const int16_t DASH_LINE_WIDTH2 = 2;
227     const int16_t MOVETO5 = 5;
228     const int16_t MOVETO20 = 20;
229     const int16_t MOVETO30 = 30;
230     const int16_t MOVETO60 = 60;
231     const int16_t LINET020 = 20;
232     const int16_t LINET050 = 50;
233     const int16_t LINET035 = 35;
234     const int16_t LINET080 = 80;
235     const int16_t LINET0200 = 200;
236     const int16_t LINET0120 = 120;
237     const int16_t LINET0180 = 180;
238     const int16_t LINE_DASH_OFFSET5 = 5;
239     const int16_t STROKEWIDTH2 = 2;
240     const int16_t STROKEWIDTH3 = 3;
241     const int16_t STROKEWIDTH8 = 8;
242     const int16_t RECT40 = 40;
243     const int16_t RECT50 = 50;
244     const int16_t RECT70 = 70;
245     const int16_t RECT80 = 80;
246     const int16_t RECT100 = 100;
247     const int16_t LINEARGRADIENT50 = 50;
248     const int16_t LINEARGRADIENT150 = 150;
249     const int16_t LINEARGRADIENT140 = 140;
250     const int16_t LINEARGRADIENT5 = 5;
251     const int16_t LINEARGRADIENT300 = 300;
252     const int16_t LINEARGRADIENT100 = 100;
253     const int16_t LINEARGRADIENT80 = 80;
254     const int16_t LINEARGRADIENT270 = 270;
255     const int16_t OFFSETX10 = 10;
256     const int16_t OFFSETX20 = 20;
257     const int16_t SHADOWBLUR15 = 15;
258     const int16_t SHADOWBLUR5 = 5;
259     const int16_t HEIGHT_Y20 = 20;
260     const int16_t HEIGHT_Y40 = 40;
261     const int16_t HEIGHT_Y60 = 60;
262     const int16_t HEIGHT_Y80 = 80;
263     const int16_t HEIGHT_Y100 = 100;
264     const int16_t HEIGHT_Y120 = 120;
265     const int16_t HEIGHT_Y140 = 140;
266     const int16_t HEIGHT_Y160 = 160;
267     const int16_t HEIGHT_Y180 = 180;
268     const int16_t HEIGHT_Y200 = 200;
269     const int16_t SCALE2 = 2;
270     const int16_t SCALE4 = 4;
271     const int16_t STROKE_WIDTH12 = 12;
272     const int16_t STROKE_WIDTH10 = 10;
273     const int16_t STROKE_WIDTH8 = 8;
274     const int16_t MITERLIMIT4 = 4;
275     const int16_t RADIAL_GRADIENT300 = 300;
276     const int16_t RADIAL_GRADIENT140 = 140;
277     const int16_t RADIAL_GRADIENT5 = 5;
278     const int16_t RADIAL_GRADIENT270 = 270;
279     const int16_t RADIAL_GRADIENT100 = 100;
280     const int16_t RADIAL_GRADIENT80 = 80;
281     const int16_t DRAWIMAGE_WIDTH = 50;
282     const int16_t DRAWIMAGE_HEIGHT = 50;
283     const float SCALE_X = 0.5f;
284     const float SCALE_Y = 0.5f;
285     const float ROTATE_ANGLE = 20;
286     const float SCALE1_X = 1;
287     const float SCALE1_Y = 1;
288     const float SCALE2_Y = 2;
289     const float SHEAR_X = 0.5f;
290     const float SHEAR_Y = 0.5f;
291     const float TRANSLATE1_X = 0;
292     const float TRANSLATE1_Y = 0;
293     const float SHEAR1_X = 0;
294     const float SHEAR1_Y = 0;
295     const float DASH5 = 5.0f;
296     const float DASH2 = 2.0f;
297     const float GLOBALALPHA5 = 0.5f;
298     const float GLOBALALPHA2 = 0.2f;
299     const float COLOR_STOP3 = 0.3f;
300     const float COLOR_STOP6 = 0.6f;
301 };
302 } // namespace OHOS
303 #endif // UI_TEST_CANVAS_H
304