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_draw_rect.h"
17 #include "common/screen.h"
18 #include "components/ui_button.h"
19 #include "components/ui_label.h"
20 #include "components/ui_view_group.h"
21 
22 namespace OHOS {
SetUp()23 void UITestDrawRect::SetUp()
24 {
25     if (container_ == nullptr) {
26         container_ = new UIScrollView();
27         container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
28         container_->SetHorizontalScrollState(false);
29     }
30 }
31 
TearDown()32 void UITestDrawRect::TearDown()
33 {
34     DeleteChildren(container_);
35     container_ = nullptr;
36 }
37 
GetTestView()38 const UIView* UITestDrawRect::GetTestView()
39 {
40     UIKitDrawRectTestRectNoBorder001();
41     UIKitDrawRectTestRectNoBorder002();
42     UIKitDrawRectTestRectNoBorder003();
43     UIKitDrawRectTestRectNoBorder004();
44     UIKitDrawRectTestRectNoBorder005();
45     UIKitDrawRectTestRectNoBorder006();
46     UIKitDrawRectTestRectNoBorder007();
47     UIKitDrawRectTestRectNoBorder008();
48     UIKitDrawRectTestRectNoBorder009();
49     UIKitDrawRectTestRectNoBorder0010();
50     UIKitDrawRectTestRectBorderNoRadius001();
51     UIKitDrawRectTestRectBorderNoRadius002();
52     UIKitDrawRectTestRectBorderRadius001();
53     UIKitDrawRectTestRectBorderRadius002();
54     UIKitDrawRectTestRectBorderRadius003();
55     UIKitDrawRectTestRectBorderRadius004();
56     UIKitDrawRectTestRectBorderRadius005();
57     UIKitDrawRectTestRectBorderRadius006();
58     UIKitDrawRectTestRectBorderRadius007();
59     UIKitDrawRectTestRectBorderRadius008();
60     UIKitDrawRectTestRectBorderRadius009();
61     UIKitDrawRectTestRectBorderRadius010();
62     UIKitDrawRectTestRectBorderRadius011();
63 
64     UIKitDrawRectTestRect001();
65     UIKitDrawRectTestRectColor001();
66     UIKitDrawRectTestRectRadius001();
67     UIKitDrawRectTestRectRadius002();
68     UIKitDrawRectTestRectRadius003();
69     UIKitDrawRectTestRectRadius004();
70     UIKitDrawRectTestRectOpacity001();
71     UIKitDrawRectTestRectOpacity002();
72     UIKitDrawRectTestRectOpacity003();
73     UIKitDrawRectTestRectBorderColor001();
74     UIKitDrawRectTestRectBorderWidth001();
75     UIKitDrawRectTestRectBorderWidth002();
76     UIKitDrawRectTestRectBorderOpacity001();
77     UIKitDrawRectTestRectBorderOpacity002();
78     UIKitDrawRectTestRectBorderOpacity003();
79     UIKitDrawRectTestRectPadding001();
80     UIKitDrawRectTestRectPadding002();
81     UIKitDrawRectTestRectMargin001();
82     UIKitDrawRectTestRectMargin002();
83     UIKitDrawRectTestRectPaddingMargin001();
84     UIKitDrawRectTestRectPaddingMargin002();
85     UIKitDrawRectTestRectWidthAndHeight001();
86     UIKitDrawRectTestRectWidthAndHeight002();
87     UIKitDrawRectTestRectWidthAndHeight003();
88     return container_;
89 }
90 
CreateTestCaseGroup() const91 UIViewGroup* UITestDrawRect::CreateTestCaseGroup() const
92 {
93     UIViewGroup* group = new UIViewGroup();
94     group->Resize(Screen::GetInstance().GetWidth(), 180); // 180 : value
95     return group;
96 }
97 
CreateTitleLabel() const98 UILabel* UITestDrawRect::CreateTitleLabel() const
99 {
100     UILabel* label = new UILabel();
101     label->SetPosition(TEXT_DISTANCE_TO_LEFT_SIDE, TEXT_DISTANCE_TO_TOP_SIDE,
102         Screen::GetInstance().GetWidth() - VIEW_DISTANCE_TO_LEFT_SIDE, TITLE_LABEL_DEFAULT_HEIGHT);
103     label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
104     return label;
105 }
106 
CreateUIView() const107 UIView* UITestDrawRect::CreateUIView() const
108 {
109     UIView* view = new UIView();
110     view->SetStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
111     view->SetStyle(STYLE_BACKGROUND_OPA, 127); // 127 : background opacity
112     view->SetStyle(STYLE_BORDER_RADIUS, 5); // 5 : radius value
113     view->SetStyle(STYLE_BORDER_COLOR, Color::Gray().full);
114     view->SetStyle(STYLE_BORDER_OPA, 127); // 127 : border opacity
115     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : border width
116     view->SetStyle(STYLE_PADDING_LEFT, 0);
117     view->SetStyle(STYLE_PADDING_RIGHT, 0);
118     view->SetStyle(STYLE_PADDING_TOP, 0);
119     view->SetStyle(STYLE_PADDING_BOTTOM, 0);
120     view->SetStyle(STYLE_MARGIN_LEFT, 0);
121     view->SetStyle(STYLE_MARGIN_RIGHT, 0);
122     view->SetStyle(STYLE_MARGIN_TOP, 0);
123     view->SetStyle(STYLE_MARGIN_BOTTOM, 0);
124     return view;
125 }
126 
UIKitDrawRectTestRectNoBorder001()127 void UITestDrawRect::UIKitDrawRectTestRectNoBorder001()
128 {
129     if (container_ == nullptr) {
130         return;
131     }
132 
133     UIViewGroup* group = CreateTestCaseGroup();
134     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_001");
135     group->SetPosition(0, 0);
136 
137     UILabel* label = CreateTitleLabel();
138     label->SetText("矩形无border, radius=0");
139     group->Add(label);
140 
141     UIView* view = CreateUIView();
142     int16_t width = 120; // 120 : width
143     int16_t height = 50; // 50 : height
144     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
145     view->SetStyle(STYLE_BORDER_WIDTH, 0);
146     view->SetStyle(STYLE_BORDER_RADIUS, 0);
147     view->Resize(width, height);
148     group->Add(view);
149 
150     container_->Add(group);
151 }
152 
UIKitDrawRectTestRectNoBorder002()153 void UITestDrawRect::UIKitDrawRectTestRectNoBorder002()
154 {
155     if (container_ == nullptr) {
156         return;
157     }
158 
159     UIViewGroup* group = CreateTestCaseGroup();
160     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_002");
161     group->SetPosition(0, 0);
162 
163     UILabel* label = CreateTitleLabel();
164     label->SetText("矩形无border, radius>0, width > height, radius > height/2");
165     group->Add(label);
166 
167     UIView* view = CreateUIView();
168     int16_t width = 120; // 120 : width
169     int16_t height = 50; // 50 : height
170     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
171     view->SetStyle(STYLE_BORDER_WIDTH, 0);
172     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 + 10); // 2 : half height 10 : offset
173     view->Resize(width, height);
174     group->Add(view);
175 
176     container_->Add(group);
177     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_001", 10); // 10 : offset size
178 }
179 
UIKitDrawRectTestRectNoBorder003()180 void UITestDrawRect::UIKitDrawRectTestRectNoBorder003()
181 {
182     if (container_ == nullptr) {
183         return;
184     }
185 
186     UIViewGroup* group = CreateTestCaseGroup();
187     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_003");
188     group->SetPosition(0, 0);
189 
190     UILabel* label = CreateTitleLabel();
191     label->SetText("矩形无border, radius>0, width > height, radius = height/2 ");
192     group->Add(label);
193 
194     UIView* view = CreateUIView();
195     int16_t width = 120; // 120 : width size
196     int16_t height = 50; // 50 : height size
197     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
198     view->SetStyle(STYLE_BORDER_WIDTH, 0);
199     view->SetStyle(STYLE_BORDER_RADIUS, height / 2); // 2 : half height
200     view->Resize(width, height);
201     group->Add(view);
202 
203     container_->Add(group);
204     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_002", 10); // 10 : offset size
205 }
206 
UIKitDrawRectTestRectNoBorder004()207 void UITestDrawRect::UIKitDrawRectTestRectNoBorder004()
208 {
209     if (container_ == nullptr) {
210         return;
211     }
212 
213     UIViewGroup* group = CreateTestCaseGroup();
214     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_004");
215     group->SetPosition(0, 0);
216 
217     UILabel* label = CreateTitleLabel();
218     label->SetText("矩形无border, radius>0, width > height, radius < height/2 ");
219     group->Add(label);
220 
221     UIView* view = CreateUIView();
222     int16_t width = 120; // 120 : width size
223     int16_t height = 50; // 50 : height size
224     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
225     view->SetStyle(STYLE_BORDER_WIDTH, 0);
226     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 - 10); // 2 : half height 10 : offset
227     view->Resize(width, height);
228     group->Add(view);
229 
230     container_->Add(group);
231     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_003", 10); // 10 : offset size
232 }
233 
UIKitDrawRectTestRectNoBorder005()234 void UITestDrawRect::UIKitDrawRectTestRectNoBorder005()
235 {
236     if (container_ == nullptr) {
237         return;
238     }
239 
240     UIViewGroup* group = CreateTestCaseGroup();
241     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_005");
242     group->SetPosition(0, 0);
243 
244     UILabel* label = CreateTitleLabel();
245     label->SetText("矩形无border, radius>0, width = height, radius > height/2 ");
246     group->Add(label);
247 
248     UIView* view = CreateUIView();
249     int16_t width = 50; // 50 : width
250     int16_t height = width;
251     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
252     view->SetStyle(STYLE_BORDER_WIDTH, 0);
253     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 + 10); // 2 : half height 10 : offset
254     view->Resize(width, height);
255     group->Add(view);
256 
257     container_->Add(group);
258     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_004", 10); // 10 : offset size
259 }
260 
UIKitDrawRectTestRectNoBorder006()261 void UITestDrawRect::UIKitDrawRectTestRectNoBorder006()
262 {
263     if (container_ == nullptr) {
264         return;
265     }
266 
267     UIViewGroup* group = CreateTestCaseGroup();
268     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_006");
269     group->SetPosition(0, 0);
270 
271     UILabel* label = CreateTitleLabel();
272     label->SetText("矩形无border, radius>0, width = height, radius = height/2 ");
273     group->Add(label);
274 
275     UIView* view = CreateUIView();
276     int16_t width = 50; // 50 : width
277     int16_t height = width;
278     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
279     view->SetStyle(STYLE_BORDER_WIDTH, 0);
280     view->SetStyle(STYLE_BORDER_RADIUS, height / 2); // 2 : half
281     view->Resize(width, height);
282     group->Add(view);
283 
284     container_->Add(group);
285     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_005", 10); // 10 : offset size
286 }
287 
UIKitDrawRectTestRectNoBorder007()288 void UITestDrawRect::UIKitDrawRectTestRectNoBorder007()
289 {
290     if (container_ == nullptr) {
291         return;
292     }
293 
294     UIViewGroup* group = CreateTestCaseGroup();
295     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_007");
296     group->SetPosition(0, 0);
297 
298     UILabel* label = CreateTitleLabel();
299     label->SetText("矩形无border, radius>0, width = height, radius < height/2 ");
300     group->Add(label);
301 
302     UIView* view = CreateUIView();
303     int16_t width = 50; // 50 : width
304     int16_t height = width;
305     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
306     view->SetStyle(STYLE_BORDER_WIDTH, 0);
307     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 - 10); // 2 : half height 10 : offset
308     view->Resize(width, height);
309     group->Add(view);
310 
311     container_->Add(group);
312     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_006", 10); // 10 : offset size
313 }
314 
UIKitDrawRectTestRectNoBorder008()315 void UITestDrawRect::UIKitDrawRectTestRectNoBorder008()
316 {
317     if (container_ == nullptr) {
318         return;
319     }
320 
321     UIViewGroup* group = CreateTestCaseGroup();
322     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_008");
323     group->SetPosition(0, 0);
324 
325     UILabel* label = CreateTitleLabel();
326     label->SetText("矩形无border, radius>0, width < height, radius > width/2 ");
327     group->Add(label);
328 
329     UIView* view = CreateUIView();
330     int16_t width = 50; // 50 : width
331     int16_t height = 120; // 120 : height
332     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
333     view->SetStyle(STYLE_BORDER_WIDTH, 0);
334     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + 10); // 2 : half width 10 : offset
335     view->Resize(width, height);
336     group->Add(view);
337 
338     container_->Add(group);
339     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_007", 10); // 10 : offset size
340 }
341 
UIKitDrawRectTestRectNoBorder009()342 void UITestDrawRect::UIKitDrawRectTestRectNoBorder009()
343 {
344     if (container_ == nullptr) {
345         return;
346     }
347 
348     UIViewGroup* group = CreateTestCaseGroup();
349     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_009");
350     group->SetPosition(0, 0);
351 
352     UILabel* label = CreateTitleLabel();
353     label->SetText("矩形无border, radius>0, width < height, radius = width/2 ");
354     group->Add(label);
355 
356     UIView* view = CreateUIView();
357     int16_t width = 51; // 51 : width
358     int16_t height = 120; // 120 : height
359     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
360     view->SetStyle(STYLE_BORDER_WIDTH, 0);
361     view->SetStyle(STYLE_BORDER_RADIUS, width / 2); // 2 : half width
362     view->Resize(width, height);
363     group->Add(view);
364 
365     container_->Add(group);
366     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_008", 10); // 10 : offset size
367 }
368 
UIKitDrawRectTestRectNoBorder0010()369 void UITestDrawRect::UIKitDrawRectTestRectNoBorder0010()
370 {
371     if (container_ == nullptr) {
372         return;
373     }
374 
375     UIViewGroup* group = CreateTestCaseGroup();
376     group->SetViewId("UIKit_DrawRect_Test_RectNoBorder_0010");
377     group->SetPosition(0, 0);
378 
379     UILabel* label = CreateTitleLabel();
380     label->SetText("矩形无border, radius>0, width < height, radius < width/2 ");
381     group->Add(label);
382 
383     UIView* view = CreateUIView();
384     int16_t width = 50; // 50 : width
385     int16_t height = 120; // 120 : height
386     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
387     view->SetStyle(STYLE_BORDER_WIDTH, 0);
388     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 - 10); // 2 : half width 10 : offset
389     view->Resize(width, height);
390     group->Add(view);
391 
392     container_->Add(group);
393     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_009", 10); // 10 : offset size
394 }
395 
UIKitDrawRectTestRectBorderNoRadius001()396 void UITestDrawRect::UIKitDrawRectTestRectBorderNoRadius001()
397 {
398     if (container_ == nullptr) {
399         return;
400     }
401 
402     UIViewGroup* group = CreateTestCaseGroup();
403     group->SetViewId("UIKit_DrawRect_Test_RectBorderNoRadius_001");
404     group->SetPosition(0, 0);
405 
406     UILabel* label = CreateTitleLabel();
407     label->SetText("矩形有border, radius=0");
408     group->Add(label);
409 
410     UIView* view = CreateUIView();
411     int16_t width = 120; // 120 : width
412     int16_t height = 50; // 50 : height
413     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
414     view->SetStyle(STYLE_BORDER_WIDTH, 10); // 10 : value
415     view->SetStyle(STYLE_BORDER_RADIUS, 0);
416     view->Resize(width, height);
417     group->Add(view);
418 
419     container_->Add(group);
420     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectNoBorder_0010", 10); // 10 : offset size
421 }
422 
UIKitDrawRectTestRectBorderNoRadius002()423 void UITestDrawRect::UIKitDrawRectTestRectBorderNoRadius002()
424 {
425     if (container_ == nullptr) {
426         return;
427     }
428 
429     UIViewGroup* group = CreateTestCaseGroup();
430     group->SetViewId("UIKit_DrawRect_Test_RectBorderNoRadius_002");
431     group->SetPosition(0, 0);
432 
433     UILabel* label = CreateTitleLabel();
434     label->SetText("矩形有border = 1, radius=0");
435     group->Add(label);
436 
437     UIView* view = CreateUIView();
438     int16_t width = 120; // 120 : width
439     int16_t height = 50; // 50 : height
440     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
441     view->SetStyle(STYLE_BORDER_WIDTH, 1); // 1 : value
442     view->SetStyle(STYLE_BORDER_RADIUS, 0);
443     view->Resize(width, height);
444     group->Add(view);
445 
446     container_->Add(group);
447     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderNoRadius_001", 10); // 10 : offset size
448 }
449 
UIKitDrawRectTestRectBorderRadius001()450 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius001()
451 {
452     if (container_ == nullptr) {
453         return;
454     }
455 
456     UIViewGroup* group = CreateTestCaseGroup();
457     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_001");
458     group->SetPosition(0, 0);
459 
460     UILabel* label = CreateTitleLabel();
461     label->SetText("矩形有border, radius<border.width");
462     group->Add(label);
463 
464     UIView* view = CreateUIView();
465     int16_t width = 120; // 120 : width
466     int16_t height = 50; // 50 : height
467     int16_t borderWidth = 10; // 10 : borderWidth
468     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
469     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
470     view->SetStyle(STYLE_BORDER_RADIUS, borderWidth - 5); // 5 : math_num
471     view->Resize(width, height);
472     group->Add(view);
473 
474     container_->Add(group);
475     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderNoRadius_001", 10); // 10 : offset size
476 }
477 
UIKitDrawRectTestRectBorderRadius002()478 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius002()
479 {
480     if (container_ == nullptr) {
481         return;
482     }
483 
484     UIViewGroup* group = CreateTestCaseGroup();
485     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_002");
486     group->SetPosition(0, 0);
487 
488     UILabel* label = CreateTitleLabel();
489     label->SetText("border场景,radius>border.width,宽度 >高度,radius > 高度/2 + border.width");
490     group->Add(label);
491 
492     UIView* view = CreateUIView();
493     int16_t width = 120; // 120 : width
494     int16_t height = 50; // 50 : height
495     int16_t borderWidth = 10; // 10 : borderWidth
496     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
497     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
498     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 + borderWidth + 5); // 2 : half height 5 : offset
499     view->Resize(width, height);
500     group->Add(view);
501 
502     container_->Add(group);
503     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_001", 10); // 10 : offset size
504 }
505 
UIKitDrawRectTestRectBorderRadius003()506 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius003()
507 {
508     if (container_ == nullptr) {
509         return;
510     }
511 
512     UIViewGroup* group = CreateTestCaseGroup();
513     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_003");
514     group->SetPosition(0, 0);
515 
516     UILabel* label = CreateTitleLabel();
517     label->SetText("border场景,radius>border.width,宽度>高度,radius = 高度/2 + border.width");
518     group->Add(label);
519 
520     UIView* view = CreateUIView();
521     int16_t width = 120; // 120 : width
522     int16_t height = 50; // 50 : height
523     int16_t borderWidth = 10; // 10 : borderWidth
524     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
525     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
526     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 + borderWidth); // 2 : half height
527     view->Resize(width, height);
528     group->Add(view);
529 
530     container_->Add(group);
531     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_002", 10); // 10 : offset size
532 }
533 
UIKitDrawRectTestRectBorderRadius004()534 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius004()
535 {
536     if (container_ == nullptr) {
537         return;
538     }
539 
540     UIViewGroup* group = CreateTestCaseGroup();
541     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_004");
542     group->SetPosition(0, 0);
543 
544     UILabel* label = CreateTitleLabel();
545     label->SetText("border场景,radius>border.width,宽度>高度,radius < 高度/2 + border.width");
546     group->Add(label);
547 
548     UIView* view = CreateUIView();
549     int16_t width = 120; // 120 : width
550     int16_t height = 50; // 50 : height
551     int16_t borderWidth = 10; // 10 : borderWidth
552     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
553     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
554     view->SetStyle(STYLE_BORDER_RADIUS, height / 2 + borderWidth - 5); // 2 : half height 5 : offset
555     view->Resize(width, height);
556     group->Add(view);
557 
558     container_->Add(group);
559     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_003", 10); // 10 : offset size
560 }
561 
UIKitDrawRectTestRectBorderRadius005()562 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius005()
563 {
564     if (container_ == nullptr) {
565         return;
566     }
567 
568     UIViewGroup* group = CreateTestCaseGroup();
569     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_005");
570     group->SetPosition(0, 0);
571 
572     UILabel* label = CreateTitleLabel();
573     label->SetText("border场景,radius>border.width,宽度=高度,radius > 宽度/2 + border.width");
574     group->Add(label);
575 
576     UIView* view = CreateUIView();
577     int16_t width = 50; // 50 : width
578     int16_t height = 50; // 50 : height
579     int16_t borderWidth = 10; // 10 : borderWidth
580     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
581     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
582     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth + 5); // 2 : half width 5 : offset
583     view->Resize(width, height);
584     group->Add(view);
585 
586     container_->Add(group);
587     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_004", 10); // 10 : offset size
588 }
589 
UIKitDrawRectTestRectBorderRadius006()590 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius006()
591 {
592     if (container_ == nullptr) {
593         return;
594     }
595 
596     UIViewGroup* group = CreateTestCaseGroup();
597     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_006");
598     group->SetPosition(0, 0);
599 
600     UILabel* label = CreateTitleLabel();
601     label->SetText("border场景,radius>border.width,宽度=高度,radius = 宽度/2 + border.width");
602     group->Add(label);
603 
604     UIView* view = CreateUIView();
605     int16_t width = 50; // 50 : width
606     int16_t height = 50; // 50 : height
607     int16_t borderWidth = 10; // 10 : borderWidth
608     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
609     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
610     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth); // 2 : half width
611     view->Resize(width, height);
612     group->Add(view);
613 
614     container_->Add(group);
615     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_005", 10); // 10 : offset size
616 }
617 
UIKitDrawRectTestRectBorderRadius007()618 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius007()
619 {
620     if (container_ == nullptr) {
621         return;
622     }
623 
624     UIViewGroup* group = CreateTestCaseGroup();
625     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_007");
626     group->SetPosition(0, 0);
627 
628     UILabel* label = CreateTitleLabel();
629     label->SetText("border场景,radius>border.width,宽度=高度,radius < 宽度/2 + border.width");
630     group->Add(label);
631 
632     UIView* view = CreateUIView();
633     int16_t width = 50; // 50 : width
634     int16_t height = 50; // 50 : height
635     int16_t borderWidth = 10; // 10 : borderWidth
636     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
637     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
638     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth - 5); // 2 : half width 5 : offset
639     view->Resize(width, height);
640     group->Add(view);
641 
642     container_->Add(group);
643     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_006", 10); // 10 : offset size
644 }
645 
UIKitDrawRectTestRectBorderRadius008()646 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius008()
647 {
648     if (container_ == nullptr) {
649         return;
650     }
651 
652     UIViewGroup* group = CreateTestCaseGroup();
653     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_008");
654     group->SetPosition(0, 0);
655 
656     UILabel* label = CreateTitleLabel();
657     label->SetText("border场景,radius>border.width,宽度<高度,radius > 宽度/2 + border.width");
658     group->Add(label);
659 
660     UIView* view = CreateUIView();
661     int16_t width = 50; // 50 : width
662     int16_t height = 100; // 100 : height
663     int16_t borderWidth = 10; // 10 : borderWidth
664     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
665     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
666     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth + 5); // 2 : half width 5 : math_num
667     view->Resize(width, height);
668     group->Add(view);
669 
670     container_->Add(group);
671     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_007", 10); // 10 : value
672 }
673 
UIKitDrawRectTestRectBorderRadius009()674 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius009()
675 {
676     if (container_ == nullptr) {
677         return;
678     }
679 
680     UIViewGroup* group = CreateTestCaseGroup();
681     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_009");
682     group->SetPosition(0, 0);
683 
684     UILabel* label = CreateTitleLabel();
685     label->SetText("border场景,radius>border.width,宽度<高度,radius = 宽度/2 + border.width");
686     group->Add(label);
687 
688     UIView* view = CreateUIView();
689     int16_t width = 50; // 50 : width
690     int16_t height = 100; // 100 : height
691     int16_t borderWidth = 10; // 10 : value
692     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
693     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
694     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth); // 2 : math_num
695     view->Resize(width, height);
696     group->Add(view);
697 
698     container_->Add(group);
699     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_008", 10); // 10 : value
700 }
701 
UIKitDrawRectTestRectBorderRadius010()702 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius010()
703 {
704     if (container_ == nullptr) {
705         return;
706     }
707 
708     UIViewGroup* group = CreateTestCaseGroup();
709     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_010");
710     group->SetPosition(0, 0);
711 
712     UILabel* label = CreateTitleLabel();
713     label->SetText("border场景,radius>border.width,宽度<高度,radius < 宽度/2 + border.width");
714     group->Add(label);
715 
716     UIView* view = CreateUIView();
717     int16_t width = 50; // 50 : width
718     int16_t height = 100; // 100 : height
719     int16_t borderWidth = 10;   // 10 : borderWidth
720     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
721     view->SetStyle(STYLE_BORDER_WIDTH, borderWidth);
722     view->SetStyle(STYLE_BORDER_RADIUS, width / 2 + borderWidth - 5); // 2 : math_num 5 : math_num
723     view->Resize(width, height);
724     group->Add(view);
725 
726     container_->Add(group);
727     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_009", 10); // 10 : value
728 }
729 
UIKitDrawRectTestRectBorderRadius011()730 void UITestDrawRect::UIKitDrawRectTestRectBorderRadius011()
731 {
732     if (container_ == nullptr) {
733         return;
734     }
735 
736     UIViewGroup* group = CreateTestCaseGroup();
737     group->SetViewId("UIKit_DrawRect_Test_RectBorderRadius_011");
738     group->SetPosition(0, 0);
739 
740     UILabel* label = CreateTitleLabel();
741     label->SetText("矩形有border = 2, radius = 1");
742     group->Add(label);
743 
744     UIView* view = CreateUIView();
745     int16_t width = 120; // 120 : width
746     int16_t height = 50; // 50 : height
747     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
748     view->SetStyle(STYLE_BORDER_WIDTH, 2); // 2: borderWidth
749     view->SetStyle(STYLE_BORDER_RADIUS, 1); // 1 : math_num
750     view->Resize(width, height);
751     group->Add(view);
752 
753     container_->Add(group);
754     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_010", 10); // 10 : offset size
755 }
756 
UIKitDrawRectTestRect001()757 void UITestDrawRect::UIKitDrawRectTestRect001()
758 {
759     if (container_ == nullptr) {
760         return;
761     }
762 
763     UIViewGroup* group = CreateTestCaseGroup();
764     group->SetViewId("UIKit_DrawRect_Test_Rect_001");
765     group->SetPosition(0, 0);
766 
767     UILabel* label = CreateTitleLabel();
768     label->SetText("矩形绘制: ");
769     group->Add(label);
770 
771     UIView* view = CreateUIView();
772     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
773     view->SetStyle(STYLE_BORDER_WIDTH, 15); // 15 : value
774     view->SetStyle(STYLE_BORDER_OPA, OPA_OPAQUE);
775     view->SetStyle(STYLE_BORDER_RADIUS, 10); // 10 : offset size
776     view->Resize(120, 50);   // 120 : width 50 : weight
777     group->Add(view);
778 
779     container_->Add(group);
780     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderRadius_009", 10); // 10 : offset size
781 }
782 
UIKitDrawRectTestRectColor001()783 void UITestDrawRect::UIKitDrawRectTestRectColor001()
784 {
785     if (container_ == nullptr) {
786         return;
787     }
788 
789     UIViewGroup* group = CreateTestCaseGroup();
790     group->SetViewId("UIKit_DrawRect_Test_RectColor_001");
791 
792     UILabel* label = CreateTitleLabel();
793     label->SetText("设置不同颜色的矩形绘制 ");
794     group->Add(label);
795 
796     UIView* view = CreateUIView();
797     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
798     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : value
799     view->SetStyle(STYLE_BORDER_RADIUS, 30); // 30 : value
800     view->Resize(120, 50); // 120 : width 50 : height
801     group->Add(view);
802 
803     UIView* view1 = CreateUIView();
804     view1->SetPosition(250, 50); // 250 : start x 50 : start y
805     view1->SetStyle(STYLE_BORDER_WIDTH, 3); // 3 : value
806     view1->SetStyle(STYLE_BORDER_RADIUS, 3); // 3 : value
807     view1->Resize(120, 50); // 120 : width 50 : height
808     group->Add(view1);
809 
810     container_->Add(group);
811     group->LayoutBottomToSibling("UIKit_DrawRect_Test_Rect_001", 10); // 10 : offset size
812 }
813 
UIKitDrawRectTestRectRadius001()814 void UITestDrawRect::UIKitDrawRectTestRectRadius001()
815 {
816     if (container_ == nullptr) {
817         return;
818     }
819 
820     UIViewGroup* group = CreateTestCaseGroup();
821     group->SetViewId("UIKit_DrawRect_Test_RectRadius_001");
822 
823     UILabel* label = CreateTitleLabel();
824     label->SetText("设置圆角为零的矩形绘制 ");
825     group->Add(label);
826 
827     UIView* view = CreateUIView();
828     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
829     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : value
830     view->SetStyle(STYLE_BORDER_RADIUS, 10); // 10 : value
831     view->Resize(120, 50); // 120 : width 50 : height
832     group->Add(view);
833 
834     container_->Add(group);
835     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectColor_001", 10); // 10 : offset size
836 }
837 
UIKitDrawRectTestRectRadius002()838 void UITestDrawRect::UIKitDrawRectTestRectRadius002()
839 {
840     if (container_ == nullptr) {
841         return;
842     }
843 
844     UIViewGroup* group = CreateTestCaseGroup();
845     group->SetViewId("UIKit_DrawRect_Test_RectRadius_002");
846 
847     UILabel* label = CreateTitleLabel();
848     label->SetText("设置圆角等于宽度的矩形绘制 ");
849     group->Add(label);
850 
851     UIView* view = CreateUIView();
852     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
853     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : value
854     view->SetStyle(STYLE_BORDER_RADIUS, 50); // 50 : value
855     view->Resize(120, 50); // 120 : width 50 : height
856     group->Add(view);
857 
858     container_->Add(group);
859     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectRadius_001", 10); // 10 : offset size
860 }
861 
UIKitDrawRectTestRectRadius003()862 void UITestDrawRect::UIKitDrawRectTestRectRadius003()
863 {
864     if (container_ == nullptr) {
865         return;
866     }
867 
868     UIViewGroup* group = CreateTestCaseGroup();
869     group->SetViewId("UIKit_DrawRect_Test_RectRadius_003");
870 
871     UILabel* label = CreateTitleLabel();
872     label->SetText("设置圆角等于宽度的正方形绘制:");
873     group->Add(label);
874 
875     UIView* view = CreateUIView();
876     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
877     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : value
878     view->SetStyle(STYLE_BORDER_RADIUS, 50); // 50 : value
879     view->Resize(50, 50); // 50 : value 50 : value
880     group->Add(view);
881 
882     container_->Add(group);
883     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectRadius_002", 10); // 10 : offset size
884 }
885 
UIKitDrawRectTestRectRadius004()886 void UITestDrawRect::UIKitDrawRectTestRectRadius004()
887 {
888     if (container_ == nullptr) {
889         return;
890     }
891 
892     UIViewGroup* group = CreateTestCaseGroup();
893     group->SetViewId("UIKit_DrawRect_Test_RectRadius_004");
894 
895     UILabel* label = CreateTitleLabel();
896     label->SetText("设置不同圆角大小的矩形绘制 ");
897     group->Add(label);
898 
899     UIView* view = CreateUIView();
900     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
901     view->SetStyle(STYLE_BORDER_WIDTH, 20); // 20 : value
902     view->SetStyle(STYLE_BORDER_RADIUS, 10); // 10 : value
903     view->Resize(120, 50); // 120 : width 50 : height
904     group->Add(view);
905 
906     UIView* view1 = CreateUIView();
907     view1->SetPosition(250, 50); // 250 : offset 50 : offset
908     view1->SetStyle(STYLE_BORDER_WIDTH, 3); // 3 : value
909     view1->SetStyle(STYLE_BORDER_RADIUS, 5); // 5 : value
910     view1->Resize(120, 50); // 120 : width 50 : height
911     group->Add(view1);
912 
913     container_->Add(group);
914     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectRadius_003", 10); // 10 : offset size
915 }
916 
UIKitDrawRectTestRectOpacity001()917 void UITestDrawRect::UIKitDrawRectTestRectOpacity001()
918 {
919     if (container_ == nullptr) {
920         return;
921     }
922 
923     UIViewGroup* group = CreateTestCaseGroup();
924     group->SetViewId("UIKit_DrawRect_Test_RectOpacity_001");
925 
926     UILabel* label = CreateTitleLabel();
927     label->SetText("设置不透明背景矩形绘制: ");
928     group->Add(label);
929 
930     UIView* view = CreateUIView();
931     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
932     view->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
933     view->Resize(120, 50); // 120 : width 50 : height
934     group->Add(view);
935 
936     container_->Add(group);
937     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectRadius_004", 10); // 10 : offset size
938 }
939 
UIKitDrawRectTestRectOpacity002()940 void UITestDrawRect::UIKitDrawRectTestRectOpacity002()
941 {
942     if (container_ == nullptr) {
943         return;
944     }
945 
946     UIViewGroup* group = CreateTestCaseGroup();
947     group->SetViewId("UIKit_DrawRect_Test_RectOpacity_002");
948 
949     UILabel* label = CreateTitleLabel();
950     label->SetText("设置全透明背景矩形绘制:");
951     group->Add(label);
952 
953     UIView* view = CreateUIView();
954     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
955     view->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT);
956     view->Resize(120, 50); // 120 : width 50 : height
957     group->Add(view);
958 
959     container_->Add(group);
960     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectOpacity_001", 10); // 10 : offset size
961 }
962 
UIKitDrawRectTestRectOpacity003()963 void UITestDrawRect::UIKitDrawRectTestRectOpacity003()
964 {
965     if (container_ == nullptr) {
966         return;
967     }
968 
969     UIViewGroup* group = CreateTestCaseGroup();
970     group->SetViewId("UIKit_DrawRect_Test_RectOpacity_003");
971 
972     UILabel* label = CreateTitleLabel();
973     label->SetText("设置不同透明度矩形绘制 ");
974     group->Add(label);
975 
976     UIView* view = CreateUIView();
977     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
978     view->SetStyle(STYLE_BACKGROUND_OPA, 102); // 102 : value
979     view->Resize(120, 50); // 120 : width 50 : height
980     group->Add(view);
981 
982     UIView* view1 = CreateUIView();
983     view1->SetPosition(250, 50); // 250 : start x 50 : start y
984     view1->SetStyle(STYLE_BACKGROUND_OPA, 204); // 204 : value
985     view1->Resize(120, 50); // 120 : width 50 : height
986     group->Add(view1);
987 
988     container_->Add(group);
989     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectOpacity_002", 10); // 10 : offset size
990 }
991 
UIKitDrawRectTestRectBorderColor001()992 void UITestDrawRect::UIKitDrawRectTestRectBorderColor001()
993 {
994     if (container_ == nullptr) {
995         return;
996     }
997 
998     UIViewGroup* group = CreateTestCaseGroup();
999     group->SetViewId("UIKit_DrawRect_Test_RectBorderColor_001");
1000 
1001     UILabel* label = CreateTitleLabel();
1002     label->SetText("设置不同边框颜色的矩形绘制 ");
1003     group->Add(label);
1004 
1005     UIView* view = CreateUIView();
1006     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1007     view->SetStyle(STYLE_BORDER_COLOR, Color::Yellow().full);
1008     view->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1009 
1010     view->Resize(120, 50); // 120 : width 50 : height
1011     group->Add(view);
1012 
1013     UIView* view1 = CreateUIView();
1014     view1->SetPosition(250, 50); // 250 : start x 50 : start y
1015     view1->SetStyle(STYLE_BORDER_COLOR, Color::Red().full);
1016     view1->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1017     view1->Resize(120, 50); // 120 : width 50 : height
1018     group->Add(view1);
1019 
1020     container_->Add(group);
1021     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectOpacity_003", 10); // 10 : offset size
1022 }
1023 
UIKitDrawRectTestRectBorderWidth001()1024 void UITestDrawRect::UIKitDrawRectTestRectBorderWidth001()
1025 {
1026     if (container_ == nullptr) {
1027         return;
1028     }
1029 
1030     UIViewGroup* group = CreateTestCaseGroup();
1031     group->SetViewId("UIKit_DrawRect_Test_RectBorderWidth_001");
1032 
1033     UILabel* label = CreateTitleLabel();
1034     label->SetText("设置边框宽度为零的矩形绘制 ");
1035     group->Add(label);
1036 
1037     UIView* view = CreateUIView();
1038     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1039     view->SetStyle(STYLE_BORDER_WIDTH, 0);
1040     view->Resize(120, 50); // 120 : width 50 : height
1041     group->Add(view);
1042 
1043     container_->Add(group);
1044     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderColor_001", 10); // 10 : offset size
1045 }
1046 
UIKitDrawRectTestRectBorderWidth002()1047 void UITestDrawRect::UIKitDrawRectTestRectBorderWidth002()
1048 {
1049     if (container_ == nullptr) {
1050         return;
1051     }
1052 
1053     UIViewGroup* group = CreateTestCaseGroup();
1054     group->SetViewId("UIKit_DrawRect_Test_RectBorderWidth_002");
1055 
1056     UILabel* label = CreateTitleLabel();
1057     label->SetText("设置不同宽度边框大小的矩形绘制 ");
1058     group->Add(label);
1059 
1060     UIView* view = CreateUIView();
1061     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1062     view->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1063     view->Resize(120, 50); // 120 : width 50 : height
1064     group->Add(view);
1065 
1066     UIView* view1 = CreateUIView();
1067     view1->SetPosition(250, 50); // 250 : offset 50 : offset
1068     view1->SetStyle(STYLE_BORDER_WIDTH, 10); // 10 : value
1069     view1->Resize(120, 50); // 120 : width 50 : height
1070     group->Add(view1);
1071 
1072     container_->Add(group);
1073     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderWidth_001", 10); // 10 : offset size
1074 }
1075 
UIKitDrawRectTestRectBorderOpacity001()1076 void UITestDrawRect::UIKitDrawRectTestRectBorderOpacity001()
1077 {
1078     if (container_ == nullptr) {
1079         return;
1080     }
1081 
1082     UIViewGroup* group = CreateTestCaseGroup();
1083     group->SetViewId("UIKit_DrawRect_Test_RectBorderOpacity_001");
1084 
1085     UILabel* label = CreateTitleLabel();
1086     label->SetText("设置不透明边框矩形绘制:");
1087     group->Add(label);
1088 
1089     UIView* view = CreateUIView();
1090     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1091     view->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1092     view->SetStyle(STYLE_BORDER_OPA, OPA_OPAQUE);
1093     view->Resize(120, 50); // 120 : width 50 : height
1094     group->Add(view);
1095 
1096     container_->Add(group);
1097     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderWidth_002", 10); // 10 : offset size
1098 }
1099 
UIKitDrawRectTestRectBorderOpacity002()1100 void UITestDrawRect::UIKitDrawRectTestRectBorderOpacity002()
1101 {
1102     if (container_ == nullptr) {
1103         return;
1104     }
1105 
1106     UIViewGroup* group = CreateTestCaseGroup();
1107     group->SetViewId("UIKit_DrawRect_Test_RectBorderOpacity_002");
1108 
1109     UILabel* label = CreateTitleLabel();
1110     label->SetText("设置全透明边框矩形绘制:");
1111     group->Add(label);
1112 
1113     UIView* view = CreateUIView();
1114     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1115     view->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1116     view->SetStyle(STYLE_BORDER_OPA, OPA_TRANSPARENT);
1117     view->Resize(120, 50); // 120 : width 50 : height
1118     group->Add(view);
1119 
1120     container_->Add(group);
1121     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderOpacity_001", 10); // 10 : offset size
1122 }
1123 
UIKitDrawRectTestRectBorderOpacity003()1124 void UITestDrawRect::UIKitDrawRectTestRectBorderOpacity003()
1125 {
1126     if (container_ == nullptr) {
1127         return;
1128     }
1129 
1130     UIViewGroup* group = CreateTestCaseGroup();
1131     group->SetViewId("UIKit_DrawRect_Test_RectBorderOpacity_003");
1132 
1133     UILabel* label = CreateTitleLabel();
1134     label->SetText("设置不同透明度边框矩形绘制 ");
1135     group->Add(label);
1136 
1137     UIView* view = CreateUIView();
1138     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1139     view->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1140     view->SetStyle(STYLE_BORDER_OPA, 153); // 153 : value
1141     view->Resize(120, 50); // 120 : width 50 : height
1142     group->Add(view);
1143 
1144     UIView* view1 = CreateUIView();
1145     view1->SetPosition(250, 50); // 250 : start x 50 : start y
1146     view1->SetStyle(STYLE_BORDER_WIDTH, 5); // 5 : value
1147     view1->SetStyle(STYLE_BORDER_OPA, 204); // 204 : value
1148     view1->Resize(120, 50); // 120 : width 50 : height
1149     group->Add(view1);
1150 
1151     container_->Add(group);
1152     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderOpacity_002", 10); // 10 : offset size
1153 }
1154 
UIKitDrawRectTestRectPadding001()1155 void UITestDrawRect::UIKitDrawRectTestRectPadding001()
1156 {
1157     if (container_ == nullptr) {
1158         return;
1159     }
1160 
1161     UIViewGroup* group = CreateTestCaseGroup();
1162     group->SetViewId("UIKit_DrawRect_Test_RectPadding_001");
1163 
1164     UILabel* label = CreateTitleLabel();
1165     label->SetText("设置padding为零的矩形绘制 ");
1166     group->Add(label);
1167 
1168     UIView* view = CreateUIView();
1169     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1170     view->SetStyle(STYLE_PADDING_LEFT, 0);
1171     view->SetStyle(STYLE_PADDING_RIGHT, 0);
1172     view->SetStyle(STYLE_PADDING_TOP, 0);
1173     view->SetStyle(STYLE_PADDING_BOTTOM, 0);
1174     view->Resize(120, 50); // 120 : width 50 : height
1175     group->Add(view);
1176 
1177     container_->Add(group);
1178     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectBorderOpacity_003", 10); // 10 : offset size
1179 }
1180 
UIKitDrawRectTestRectPadding002()1181 void UITestDrawRect::UIKitDrawRectTestRectPadding002()
1182 {
1183     if (container_ == nullptr) {
1184         return;
1185     }
1186 
1187     UIViewGroup* group = CreateTestCaseGroup();
1188     group->SetViewId("UIKit_DrawRect_Test_RectPadding_002");
1189 
1190     UILabel* label = CreateTitleLabel();
1191     label->SetText("设置padding不为零的矩形绘制:");
1192     group->Add(label);
1193 
1194     UIView* view = CreateUIView();
1195     view->SetPosition(0, 50); // 0 : start x 50 : start y
1196     view->Resize(100, 50); // 100 : width 50 : height
1197     group->Add(view);
1198 
1199     UIView* view1 = CreateUIView();
1200     view1->SetPosition(120, 50); // 120 : start x 50 : start y
1201     view1->SetStyle(STYLE_PADDING_LEFT, 10); // 10 : value
1202     view1->SetStyle(STYLE_PADDING_RIGHT, 10); // 10 : value
1203     view1->SetStyle(STYLE_PADDING_TOP, 10); // 10 : value
1204     view1->SetStyle(STYLE_PADDING_BOTTOM, 10); // 10 : value
1205     view1->Resize(120, 50); // 120 : width 50 : height
1206     group->Add(view1);
1207 
1208     UIView* view2 = CreateUIView();
1209     view2->SetPosition(280, 50); // 280 : start x 50 : start y
1210     view2->SetStyle(STYLE_PADDING_LEFT, 20); // 20 : value
1211     view2->SetStyle(STYLE_PADDING_RIGHT, 10); // 10 : value
1212     view2->SetStyle(STYLE_PADDING_TOP, 20); // 20 : value
1213     view2->SetStyle(STYLE_PADDING_BOTTOM, 10); // 10 : value
1214     view2->Resize(120, 50); // 120 : width 50 : height
1215     group->Add(view2);
1216 
1217     container_->Add(group);
1218     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectPadding_001", 10); // 10 : offset size
1219 }
1220 
UIKitDrawRectTestRectMargin001()1221 void UITestDrawRect::UIKitDrawRectTestRectMargin001()
1222 {
1223     if (container_ == nullptr) {
1224         return;
1225     }
1226 
1227     UIViewGroup* group = CreateTestCaseGroup();
1228     group->SetViewId("UIKit_DrawRect_Test_RectMargin_001");
1229 
1230     UILabel* label = CreateTitleLabel();
1231     label->SetText("设置margin为零的矩形绘制 ");
1232     group->Add(label);
1233 
1234     UIView* view = CreateUIView();
1235     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1236     view->SetStyle(STYLE_MARGIN_LEFT, 0);
1237     view->SetStyle(STYLE_MARGIN_RIGHT, 0);
1238     view->SetStyle(STYLE_MARGIN_TOP, 0);
1239     view->SetStyle(STYLE_MARGIN_BOTTOM, 0);
1240     view->Resize(120, 50); // 120 : width 50 : height
1241     group->Add(view);
1242 
1243     container_->Add(group);
1244     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectPadding_002", 10); // 10 : offset size
1245 }
1246 
UIKitDrawRectTestRectMargin002()1247 void UITestDrawRect::UIKitDrawRectTestRectMargin002()
1248 {
1249     if (container_ == nullptr) {
1250         return;
1251     }
1252 
1253     UIViewGroup* group = CreateTestCaseGroup();
1254     group->SetViewId("UIKit_DrawRect_Test_RectMargin_002");
1255 
1256     UILabel* label = CreateTitleLabel();
1257     label->SetText("设置margin不为零的矩形绘制:");
1258     group->Add(label);
1259 
1260     UIView* view = CreateUIView();
1261     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1262     view->SetStyle(STYLE_MARGIN_LEFT, 10); // 10 : margin left
1263     view->SetStyle(STYLE_MARGIN_RIGHT, 10); // 10 : margin right
1264     view->SetStyle(STYLE_MARGIN_TOP, 10); // 10 : margin top
1265     view->SetStyle(STYLE_MARGIN_BOTTOM, 10); // 10 : margin bottom
1266     view->Resize(120, 50); // 120 : width 50 : height
1267     group->Add(view);
1268 
1269     UIView* view1 = CreateUIView();
1270     view1->SetPosition(250, 50); // 250 : start x 50 : start y
1271     view1->SetStyle(STYLE_MARGIN_LEFT, 20); // 20 : margin left
1272     view1->SetStyle(STYLE_MARGIN_RIGHT, 10); // 10 : margin right
1273     view1->SetStyle(STYLE_MARGIN_TOP, 20); // 20 : margin top
1274     view1->SetStyle(STYLE_MARGIN_BOTTOM, 10); // 10 : margin bottom
1275     view1->Resize(120, 50); // 120 : width 50 : height
1276     group->Add(view1);
1277 
1278     container_->Add(group);
1279     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectMargin_001", 10); // 10 : offset size
1280 }
1281 
UIKitDrawRectTestRectPaddingMargin001()1282 void UITestDrawRect::UIKitDrawRectTestRectPaddingMargin001()
1283 {
1284     if (container_ == nullptr) {
1285         return;
1286     }
1287 
1288     UIViewGroup* group = CreateTestCaseGroup();
1289     group->SetViewId("UIKit_DrawRect_Test_RectPaddingMargin_001");
1290 
1291     UILabel* label = CreateTitleLabel();
1292     label->SetText("设置 padding/margin 均为零的矩形绘制:");
1293     group->Add(label);
1294 
1295     UIView* view = CreateUIView();
1296     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1297     view->SetStyle(STYLE_MARGIN_LEFT, 0);
1298     view->SetStyle(STYLE_MARGIN_RIGHT, 0);
1299     view->SetStyle(STYLE_MARGIN_TOP, 0);
1300     view->SetStyle(STYLE_MARGIN_BOTTOM, 0);
1301     view->SetStyle(STYLE_PADDING_LEFT, 0);
1302     view->SetStyle(STYLE_PADDING_RIGHT, 0);
1303     view->SetStyle(STYLE_PADDING_TOP, 0);
1304     view->SetStyle(STYLE_PADDING_BOTTOM, 0);
1305     view->Resize(120, 50); // 120 : width 50 : height
1306     group->Add(view);
1307 
1308     container_->Add(group);
1309     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectMargin_002", 10); // 10 : offset size
1310 }
1311 
UIKitDrawRectTestRectPaddingMargin002()1312 void UITestDrawRect::UIKitDrawRectTestRectPaddingMargin002()
1313 {
1314     if (container_ == nullptr) {
1315         return;
1316     }
1317 
1318     UIViewGroup* group = CreateTestCaseGroup();
1319     group->SetViewId("UIKit_DrawRect_Test_RectPaddingMargin_002");
1320 
1321     UILabel* label = CreateTitleLabel();
1322     label->SetText("设置padding/margin均不为零的矩形绘制 ");
1323     group->Add(label);
1324 
1325     UIView* view = CreateUIView();
1326     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1327     view->SetStyle(STYLE_MARGIN_LEFT, 0);
1328     view->SetStyle(STYLE_MARGIN_RIGHT, 0);
1329     view->SetStyle(STYLE_MARGIN_TOP, 0);
1330     view->SetStyle(STYLE_MARGIN_BOTTOM, 0);
1331     view->SetStyle(STYLE_PADDING_LEFT, 0);
1332     view->SetStyle(STYLE_PADDING_RIGHT, 0);
1333     view->SetStyle(STYLE_PADDING_TOP, 0);
1334     view->SetStyle(STYLE_PADDING_BOTTOM, 0);
1335     view->Resize(120, 50); // 120 : width 50 : height
1336     group->Add(view);
1337 
1338     UIView* view1 = CreateUIView();
1339     view1->SetPosition(250, 50); // 250 : start 50 : start
1340     view1->SetStyle(STYLE_MARGIN_LEFT, 10); // 10 : margin left
1341     view1->SetStyle(STYLE_MARGIN_RIGHT, 10); // 10 : margin right
1342     view1->SetStyle(STYLE_MARGIN_TOP, 10); // 10 : margin top
1343     view1->SetStyle(STYLE_MARGIN_BOTTOM, 10); // 10 : margin bottom
1344     view1->SetStyle(STYLE_PADDING_LEFT, 10); // 10 : padding left
1345     view1->SetStyle(STYLE_PADDING_RIGHT, 10); // 10 : padding right
1346     view1->SetStyle(STYLE_PADDING_TOP, 10); // 10 : padding top
1347     view1->SetStyle(STYLE_PADDING_BOTTOM, 10); // 10 : padding bottom
1348     view1->Resize(120, 50); // 120 : width 50 : height
1349     group->Add(view1);
1350 
1351     container_->Add(group);
1352     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectPaddingMargin_001", 10); // 10 : offset size
1353 }
1354 
UIKitDrawRectTestRectWidthAndHeight001()1355 void UITestDrawRect::UIKitDrawRectTestRectWidthAndHeight001()
1356 {
1357     if (container_ == nullptr) {
1358         return;
1359     }
1360 
1361     UIViewGroup* group = CreateTestCaseGroup();
1362     group->SetViewId("UIKit_DrawRect_Test_RectWidthAndHeight_001");
1363 
1364     UILabel* label = CreateTitleLabel();
1365     label->SetText("设置宽度为零的矩形绘制 ");
1366     group->Add(label);
1367 
1368     UIView* view = CreateUIView();
1369     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1370     view->SetStyle(STYLE_BORDER_WIDTH, 0);
1371     view->SetStyle(STYLE_BORDER_RADIUS, 10); // 10 : border radius
1372     view->Resize(0, 50); // 0 : width 50 : height
1373     container_->Add(view);
1374 
1375     container_->Add(group);
1376     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectPaddingMargin_002", 20); // 20 : offset size
1377 }
1378 
UIKitDrawRectTestRectWidthAndHeight002()1379 void UITestDrawRect::UIKitDrawRectTestRectWidthAndHeight002()
1380 {
1381     if (container_ == nullptr) {
1382         return;
1383     }
1384 
1385     UIViewGroup* group = CreateTestCaseGroup();
1386     group->SetViewId("UIKit_DrawRect_Test_RectWidthAndHeight_002");
1387 
1388     UILabel* label = CreateTitleLabel();
1389     label->SetText("设置高度为零的矩形绘制 ");
1390     group->Add(label);
1391 
1392     UIView* view = CreateUIView();
1393     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1394     view->SetStyle(STYLE_BORDER_WIDTH, 0); // 10 : value
1395     view->SetStyle(STYLE_BORDER_RADIUS, 0); // 10 : value
1396     view->Resize(120, 0); // 120 : width 0 : height
1397     group->Add(view);
1398 
1399     container_->Add(group);
1400     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectWidthAndHeight_001", 20); // 20 : offset size
1401 }
1402 
UIKitDrawRectTestRectWidthAndHeight003()1403 void UITestDrawRect::UIKitDrawRectTestRectWidthAndHeight003()
1404 {
1405     if (container_ == nullptr) {
1406         return;
1407     }
1408 
1409     UIViewGroup* group = CreateTestCaseGroup();
1410     group->SetViewId("UIKit_DrawRect_Test_RectWidthAndHeight_003");
1411 
1412     UILabel* label = CreateTitleLabel();
1413     label->SetText("设置宽度和高度都为零的矩形绘制 ");
1414     group->Add(label);
1415 
1416     UIView* view = CreateUIView();
1417     view->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
1418     view->SetStyle(STYLE_BORDER_WIDTH, 0);
1419     view->SetStyle(STYLE_BORDER_RADIUS, 10); // 10 : border radius
1420     view->Resize(0, 0);  // 0 : width 0 : height
1421     group->Add(view);
1422 
1423     container_->Add(group);
1424     group->LayoutBottomToSibling("UIKit_DrawRect_Test_RectWidthAndHeight_002", 20); // 20 : offset size
1425 }
1426 } // namespace OHOS
1427