• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_border_margin_padding.h"
17 #include "common/screen.h"
18 #include "components/text_adapter.h"
19 #include "components/ui_arc_label.h"
20 #include "components/ui_box_progress.h"
21 #include "components/ui_canvas.h"
22 #include "components/ui_circle_progress.h"
23 #include "components/ui_image_animator.h"
24 #include "components/ui_label_button.h"
25 #include "components/ui_list.h"
26 #include "components/ui_qrcode.h"
27 #include "components/ui_radio_button.h"
28 #include "components/ui_slider.h"
29 #include "components/ui_swipe_view.h"
30 #include "test_resource_config.h"
31 
32 namespace OHOS {
33 static ImageAnimatorInfo g_imageAnimatorInfo[4] = {
34     {IMAGE_ANIMATOR_0_PATH, {84, 108}, 116, 116, IMG_SRC_FILE_PATH},
35     {IMAGE_ANIMATOR_1_PATH, {84, 108}, 116, 116, IMG_SRC_FILE_PATH},
36     {IMAGE_ANIMATOR_2_PATH, {84, 108}, 116, 116, IMG_SRC_FILE_PATH},
37     {IMAGE_ANIMATOR_3_PATH, {84, 108}, 116, 116, IMG_SRC_FILE_PATH},
38 };
39 
40 class MarginListener : public UICheckBox::OnChangeListener {
41 public:
MarginListener(UITestBorderMarginPadding * view)42     explicit MarginListener(UITestBorderMarginPadding* view)
43     {
44         view_ = view;
45     }
46 
~MarginListener()47     virtual ~MarginListener() {}
48 
OnChange(UICheckBox::UICheckBoxState state)49     bool OnChange(UICheckBox::UICheckBoxState state) override
50     {
51         if (state == UICheckBox::SELECTED) {
52             view_->style_.SetStyle(STYLE_MARGIN_LEFT, MARGIN_SIZE);
53             view_->style_.SetStyle(STYLE_MARGIN_TOP, MARGIN_SIZE);
54             view_->style_.SetStyle(STYLE_MARGIN_RIGHT, MARGIN_SIZE);
55             view_->style_.SetStyle(STYLE_MARGIN_BOTTOM, MARGIN_SIZE);
56         } else {
57             view_->style_.SetStyle(STYLE_MARGIN_LEFT, 0);
58             view_->style_.SetStyle(STYLE_MARGIN_TOP, 0);
59             view_->style_.SetStyle(STYLE_MARGIN_RIGHT, 0);
60             view_->style_.SetStyle(STYLE_MARGIN_BOTTOM, 0);
61         }
62         view_->ReloadTest();
63         return true;
64     }
65 
66 private:
67     static constexpr int16_t MARGIN_SIZE = 30;
68     UITestBorderMarginPadding* view_ = nullptr;
69 };
70 
71 class BorderListener : public UICheckBox::OnChangeListener {
72 public:
BorderListener(UITestBorderMarginPadding * view)73     explicit BorderListener(UITestBorderMarginPadding* view)
74     {
75         view_ = view;
76     }
77 
~BorderListener()78     virtual ~BorderListener() {}
79 
OnChange(UICheckBox::UICheckBoxState state)80     bool OnChange(UICheckBox::UICheckBoxState state) override
81     {
82         if (state == UICheckBox::SELECTED) {
83             view_->style_.SetStyle(STYLE_BORDER_WIDTH, 20); // 20: border width
84             view_->style_.SetStyle(STYLE_BORDER_OPA, OPA_OPAQUE);
85             view_->style_.SetStyle(STYLE_BORDER_COLOR, Color::Blue().full);
86         } else {
87             view_->style_.SetStyle(STYLE_BORDER_WIDTH, 0);
88         }
89         view_->ReloadTest();
90         return true;
91     }
92 
93 private:
94     UITestBorderMarginPadding* view_ = nullptr;
95 };
96 
97 class PaddingListener : public UICheckBox::OnChangeListener {
98 public:
PaddingListener(UITestBorderMarginPadding * view)99     explicit PaddingListener(UITestBorderMarginPadding* view)
100     {
101         view_ = view;
102     }
103 
~PaddingListener()104     virtual ~PaddingListener() {}
105 
OnChange(UICheckBox::UICheckBoxState state)106     bool OnChange(UICheckBox::UICheckBoxState state) override
107     {
108         if (state == UICheckBox::SELECTED) {
109             view_->style_.SetStyle(STYLE_PADDING_LEFT, PADDING_SIZE);
110             view_->style_.SetStyle(STYLE_PADDING_TOP, PADDING_SIZE);
111             view_->style_.SetStyle(STYLE_PADDING_RIGHT, PADDING_SIZE);
112             view_->style_.SetStyle(STYLE_PADDING_BOTTOM, PADDING_SIZE);
113         } else {
114             view_->style_.SetStyle(STYLE_PADDING_LEFT, 0);
115             view_->style_.SetStyle(STYLE_PADDING_TOP, 0);
116             view_->style_.SetStyle(STYLE_PADDING_RIGHT, 0);
117             view_->style_.SetStyle(STYLE_PADDING_BOTTOM, 0);
118         }
119         view_->ReloadTest();
120         return true;
121     }
122 
123 private:
124     static constexpr int16_t PADDING_SIZE = 30;
125     UITestBorderMarginPadding* view_ = nullptr;
126 };
127 
SetUp()128 void UITestBorderMarginPadding::SetUp()
129 {
130     if (container_ == nullptr) {
131         container_ = new UIViewGroup();
132     }
133     if (scroll_ == nullptr) {
134         scroll_ = new UIScrollView();
135     }
136     if (layoutButton_ == nullptr) {
137         layoutButton_ = new GridLayout();
138     }
139     if (listScroll_ == nullptr) {
140         listScroll_ = new ListLayout();
141     }
142 
143     UIToggleButton* marginBtn = new UIToggleButton();
144     UIToggleButton* borderBtn = new UIToggleButton();
145     UIToggleButton* paddingBtn = new UIToggleButton();
146     UILabel* labelMargin = new UILabel();
147     UILabel* labelBorder = new UILabel();
148     UILabel* labelPadding = new UILabel();
149 
150     container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
151                             Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
152 
153     scroll_->SetPosition(0, 0, Screen::GetInstance().GetWidth() - BUTTON_GROUP_WIDTH,
154                          Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
155     scroll_->SetThrowDrag(true);
156     scroll_->SetHorizontalScrollState(false);
157     scroll_->SetScrollBlankSize(100); // 100 : blank size
158 
159     layoutButton_->SetPosition(Screen::GetInstance().GetWidth() - BUTTON_GROUP_WIDTH, 0, BUTTON_GROUP_WIDTH,
160                                Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
161     layoutButton_->SetRows(3); // 3: rows
162     layoutButton_->SetCols(2); // 2: cols
163 
164     listScroll_ = new ListLayout(ListLayout::VERTICAL);
165     listScroll_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
166     listScroll_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Olive().full);
167     listScroll_->SetPosition(0, 0, Screen::GetInstance().GetWidth() - BUTTON_GROUP_WIDTH,
168                              Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
169     scroll_->Add(listScroll_);
170 
171     container_->Add(scroll_);
172     container_->Add(layoutButton_);
173     marginBtn->Resize(64, 64);  // 64 : button size
174     borderBtn->Resize(64, 64);  // 64 : button size
175     paddingBtn->Resize(64, 64); // 64 : button size
176 
177     labelMargin->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
178     labelMargin->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15); // 15: font size
179     labelMargin->SetText("margin ON/OFF");
180     labelMargin->ReMeasure();
181 
182     labelBorder->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
183     labelBorder->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15); // 15: font size
184     labelBorder->SetText("border ON/OFF");
185     labelBorder->ReMeasure();
186 
187     labelPadding->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
188     labelPadding->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 15); // 15: font size
189     labelPadding->SetText("padding ON/OFF");
190     labelPadding->ReMeasure();
191 
192     layoutButton_->Add(labelMargin);
193     layoutButton_->Add(marginBtn);
194     layoutButton_->Add(labelBorder);
195     layoutButton_->Add(borderBtn);
196     layoutButton_->Add(labelPadding);
197     layoutButton_->Add(paddingBtn);
198     layoutButton_->LayoutChildren();
199 
200     if (borderListener_ == nullptr) {
201         borderListener_ = new BorderListener(this);
202     }
203     borderBtn->SetOnChangeListener(borderListener_);
204     if (marginListener_ == nullptr) {
205         marginListener_ = new MarginListener(this);
206     }
207     marginBtn->SetOnChangeListener(marginListener_);
208     if (paddingListener_ == nullptr) {
209         paddingListener_ = new PaddingListener(this);
210     }
211     paddingBtn->SetOnChangeListener(paddingListener_);
212 
213     if (adapterData_ == nullptr) {
214         adapterData_ = new List<const char*>();
215         adapterData_->PushBack("000");
216         adapterData_->PushBack("111");
217         adapterData_->PushBack("222");
218         adapterData_->PushBack("333");
219         adapterData_->PushBack("444");
220         adapterData_->PushBack("555");
221         adapterData_->PushBack("666");
222         adapterData_->PushBack("777");
223         adapterData_->PushBack("888");
224         adapterData_->PushBack("999");
225         adapterData_->PushBack("AAA");
226         adapterData_->PushBack("BBB");
227         adapterData_->PushBack("CCC");
228     }
229 }
230 
TearDown()231 void UITestBorderMarginPadding::TearDown()
232 {
233     if (borderListener_ != nullptr) {
234         delete borderListener_;
235         borderListener_ = nullptr;
236     }
237     if (marginListener_ != nullptr) {
238         delete marginListener_;
239         marginListener_ = nullptr;
240     }
241     if (paddingListener_ != nullptr) {
242         delete paddingListener_;
243         paddingListener_ = nullptr;
244     }
245     if (adapterData_ != nullptr) {
246         adapterData_->Clear();
247         delete adapterData_;
248         adapterData_ = nullptr;
249     }
250     if (picker_ != nullptr) {
251         listScroll_->Remove(picker_);
252         delete picker_;
253         picker_ = nullptr;
254     }
255     if (chart_ != nullptr) {
256         listScroll_->Remove(chart_);
257         chart_->ClearDataSerial();
258         delete dataSerial_;
259         dataSerial_ = nullptr;
260         delete chart_;
261         chart_ = nullptr;
262     }
263     DeleteChildren(container_);
264     container_ = nullptr;
265     scroll_ = nullptr;
266     layoutButton_ = nullptr;
267     listScroll_ = nullptr;
268 }
269 
ReloadTest()270 void UITestBorderMarginPadding::ReloadTest()
271 {
272     int16_t heightBefor = listScroll_->GetHeight();
273     int16_t yBefor = listScroll_->GetY();
274 
275     scroll_->RemoveAll();
276     if (chart_ != nullptr) {
277         listScroll_->Remove(chart_);
278         chart_->ClearDataSerial();
279         delete dataSerial_;
280         dataSerial_ = nullptr;
281         delete chart_;
282         chart_ = nullptr;
283     }
284 
285     if (picker_ != nullptr) {
286         listScroll_->Remove(picker_);
287         delete picker_;
288         picker_ = nullptr;
289     }
290 
291     DeleteChildren(listScroll_);
292     listScroll_ = new ListLayout(ListLayout::VERTICAL);
293     listScroll_->SetPosition(0, 0, Screen::GetInstance().GetWidth() - BUTTON_GROUP_WIDTH,
294                              Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
295     listScroll_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
296     listScroll_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Olive().full);
297     scroll_->Add(listScroll_);
298     GetTestView();
299 
300     int16_t yAfter = listScroll_->GetHeight() * yBefor / heightBefor;
301     scroll_->ScrollBy(0, yAfter);
302     container_->Invalidate();
303 }
304 
GetTestView()305 const UIView* UITestBorderMarginPadding::GetTestView()
306 {
307     UIKit_UITestBorderMarginPadding_Test_001();
308     UIKit_UITestBorderMarginPadding_Test_002();
309     UIKit_UITestBorderMarginPadding_Test_003();
310     UIKit_UITestBorderMarginPadding_Test_004();
311     UIKit_UITestBorderMarginPadding_Test_005();
312     UIKit_UITestBorderMarginPadding_Test_006();
313     UIKit_UITestBorderMarginPadding_Test_007();
314     UIKit_UITestBorderMarginPadding_Test_008();
315     UIKit_UITestBorderMarginPadding_Test_009();
316     UIKit_UITestBorderMarginPadding_Test_011();
317     UIKit_UITestBorderMarginPadding_Test_012();
318     UIKit_UITestBorderMarginPadding_Test_013();
319     UIKit_UITestBorderMarginPadding_Test_014();
320     UIKit_UITestBorderMarginPadding_Test_015();
321     UIKit_UITestBorderMarginPadding_Test_016();
322     UIKit_UITestBorderMarginPadding_Test_017();
323     UIKit_UITestBorderMarginPadding_Test_018();
324     return container_;
325 }
326 
AddTitle(const char * text)327 void UITestBorderMarginPadding::AddTitle(const char* text)
328 {
329     UILabel* titleLabel = new UILabel();
330     titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
331     titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
332     titleLabel->SetText(text);
333     listScroll_->Add(titleLabel);
334 }
335 
UIKit_UITestBorderMarginPadding_Test_001()336 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_001()
337 {
338     AddTitle("UIView");
339     UIView* view = new UIView();
340     view->SetStyle(style_);
341     view->Resize(200, 100); // 200:size 100: size
342     listScroll_->Add(view);
343 }
344 
UIKit_UITestBorderMarginPadding_Test_002()345 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_002()
346 {
347     AddTitle("UILabel");
348     UILabel* view = new UILabel();
349     view->SetStyle(style_);
350     view->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
351     view->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
352     view->Resize(200, 100); // 200:size 100: size
353     view->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
354     view->SetText("TEST UILABEL");
355     listScroll_->Add(view);
356 }
357 
UIKit_UITestBorderMarginPadding_Test_003()358 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_003()
359 {
360     AddTitle("ArcLabel");
361     UIArcLabel* view = new UIArcLabel();
362     view->SetStyle(style_);
363     view->SetArcTextCenter(180, 180);                // 180: text center
364     view->SetArcTextRadius(150);                     // 150: text radius
365     view->SetArcTextAngle(0, 270);                   // 0: start angle 270: end angle
366     view->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: font size
367     view->SetText("012345678ABCDEF0123456789ABCDE");
368     listScroll_->Add(view);
369 }
370 
UIKit_UITestBorderMarginPadding_Test_004()371 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_004()
372 {
373     AddTitle("BoxProgress");
374     UIBoxProgress* boxProgress = new UIBoxProgress();
375     boxProgress->SetStyle(style_);
376     boxProgress->SetPosition(10, 10, 100, 10); // 10: x 10: y 100: width 10: height
377     boxProgress->SetValue(20);                 // 20: value
378     boxProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, Color::Yellow().full);
379     boxProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full);
380     listScroll_->Add(boxProgress);
381 }
382 
UIKit_UITestBorderMarginPadding_Test_005()383 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_005()
384 {
385     AddTitle("UIViewGroup");
386     UIViewGroup* group = new UIViewGroup();
387     group->SetStyle(style_);
388     group->Resize(200, 100); // 200: size 100: size
389     listScroll_->Add(group);
390 
391     UIButton* button = new UIButton();
392     button->SetPosition(0, 0, 100, 50); // 100: size 50: size
393     group->Add(button);
394 }
395 
UIKit_UITestBorderMarginPadding_Test_006()396 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_006()
397 {
398     AddTitle("UICanvas");
399     UICanvas* canvas = new UICanvas();
400     canvas->SetStyle(style_);
401     canvas->Resize(400, 400); // 400: size
402     Paint paint;
403     paint.SetStrokeWidth(10); // 10: line width
404     // {10, 10}: Start point coordinates x, y; {300, 10}: end point coordinates x, y
405     canvas->DrawLine({10, 10}, {300, 10}, paint);
406 
407     paint.SetStrokeColor(Color::Yellow());
408     canvas->DrawCurve({100, 50}, {150, 50}, {150, 50}, {150, 100}, paint);
409 
410     paint.SetStyle(Paint::PaintStyle::FILL_STYLE);
411     paint.SetFillColor(Color::Yellow());
412     paint.SetStrokeWidth(30); // 30: line width
413     // {10, 200}: left corner coordinates point, 50: width, 50: rectangle style
414     canvas->DrawRect({10, 200}, 50, 50, paint);
415 
416     paint.SetStyle(Paint::PaintStyle::STROKE_FILL_STYLE);
417     paint.SetFillColor(Color::Yellow());
418     paint.SetStrokeColor(Color::Blue());
419     paint.SetStrokeWidth(10); // 10: line width
420     paint.SetOpacity(127);    // 127: opacity
421     // {300, 100}: circle center coordinates, 30: circle radius
422     canvas->DrawCircle({300, 100}, 30, paint);
423     listScroll_->Add(canvas);
424 }
425 
UIKit_UITestBorderMarginPadding_Test_007()426 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_007()
427 {
428     AddTitle("UIChart");
429     chart_ = new UIChartPolyline();
430     chart_->SetStyle(style_);
431     chart_->SetPosition(VIEW_DISTANCE_TO_LEFT_SIDE, VIEW_DISTANCE_TO_TOP_SIDE);
432     chart_->SetWidth(454);  // 454: width
433     chart_->SetHeight(250); // 250: height
434 
435     dataSerial_ = new UIChartDataSerial();
436     dataSerial_->SetMaxDataCount(5); // 5: number of data points
437     Point pointArray[5] = {{0, 2478}, {1, 2600}, {2, 3000}, {3, 3200}, {4, 3500}};
438     dataSerial_->AddPoints(pointArray, 5); // 5: number of data points
439     dataSerial_->SetLineColor(Color::Red());
440     dataSerial_->SetFillColor(Color::Red());
441     dataSerial_->EnableGradient(true);
442 
443     UIXAxis& xAxis = chart_->GetXAxis();
444     UIYAxis& yAxis = chart_->GetYAxis();
445     xAxis.SetMarkNum(5);         // 5: number of scales
446     xAxis.SetDataRange(0, 5);    // 0: minimum value, 5: maximum value
447     yAxis.SetDataRange(0, 5000); // 0: minimum value, 5000: maximum value
448 
449     chart_->SetGradientOpacity(25, 127); // 25: min opacity, 127: max opacity
450     chart_->AddDataSerial(dataSerial_);
451 
452     listScroll_->Add(chart_);
453 }
UIKit_UITestBorderMarginPadding_Test_008()454 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_008()
455 {
456     AddTitle("Button");
457     UIViewGroup* group = new UIViewGroup();
458     group->Resize(Screen::GetInstance().GetWidth() - BUTTON_GROUP_WIDTH, 200); // 200: button UIViewGroup height
459 
460     UIButton* button = new UIButton();
461     button->SetStyleForState(STYLE_MARGIN_LEFT, style_.marginLeft_, UIButton::RELEASED);
462     button->SetStyleForState(STYLE_MARGIN_LEFT, style_.marginLeft_, UIButton::PRESSED);
463     button->SetStyleForState(STYLE_MARGIN_TOP, style_.marginTop_, UIButton::RELEASED);
464     button->SetStyleForState(STYLE_MARGIN_TOP, style_.marginTop_, UIButton::PRESSED);
465     button->SetStyleForState(STYLE_MARGIN_RIGHT, style_.marginRight_, UIButton::RELEASED);
466     button->SetStyleForState(STYLE_MARGIN_RIGHT, style_.marginRight_, UIButton::PRESSED);
467     button->SetStyleForState(STYLE_MARGIN_BOTTOM, style_.marginBottom_, UIButton::RELEASED);
468     button->SetStyleForState(STYLE_MARGIN_BOTTOM, style_.marginBottom_, UIButton::PRESSED);
469 
470     button->SetStyleForState(STYLE_BORDER_WIDTH, style_.borderWidth_, UIButton::RELEASED);
471     button->SetStyleForState(STYLE_BORDER_WIDTH, style_.borderWidth_, UIButton::PRESSED);
472     button->SetStyleForState(STYLE_BORDER_OPA, style_.borderOpa_, UIButton::RELEASED);
473     button->SetStyleForState(STYLE_BORDER_OPA, style_.borderOpa_, UIButton::PRESSED);
474     button->SetStyleForState(STYLE_BORDER_COLOR, style_.borderColor_.full, UIButton::RELEASED);
475     button->SetStyleForState(STYLE_BORDER_COLOR, style_.borderColor_.full, UIButton::PRESSED);
476 
477     button->SetStyleForState(STYLE_PADDING_LEFT, style_.paddingLeft_, UIButton::RELEASED);
478     button->SetStyleForState(STYLE_PADDING_LEFT, style_.paddingLeft_, UIButton::PRESSED);
479     button->SetStyleForState(STYLE_PADDING_TOP, style_.paddingTop_, UIButton::RELEASED);
480     button->SetStyleForState(STYLE_PADDING_TOP, style_.paddingTop_, UIButton::PRESSED);
481     button->SetStyleForState(STYLE_PADDING_RIGHT, style_.paddingRight_, UIButton::RELEASED);
482     button->SetStyleForState(STYLE_PADDING_RIGHT, style_.paddingRight_, UIButton::PRESSED);
483     button->SetStyleForState(STYLE_PADDING_BOTTOM, style_.paddingBottom_, UIButton::RELEASED);
484     button->SetStyleForState(STYLE_PADDING_BOTTOM, style_.paddingBottom_, UIButton::PRESSED);
485 
486     button->SetPosition(50, 30, 70, 50); // 50: x 30: y 70: width 50: height
487     group->Add(button);
488 
489     UICheckBox* checkbox = new UICheckBox();
490     checkbox->SetStyle(style_);
491     checkbox->SetPosition(200, 30, 50, 50); // 200: x-coordinate, 30: y-coordinate, 50: size
492     group->Add(checkbox);
493 
494     UIRadioButton* radioButton = new UIRadioButton();
495     radioButton->SetStyle(style_);
496     radioButton->SetPosition(350, 30, 50, 50); // 350: x-coordinate, 30: y-coordinate, 50: size
497     group->Add(radioButton);
498 
499     UIToggleButton* toggleButton = new UIToggleButton();
500     toggleButton->SetStyle(style_);
501     toggleButton->SetPosition(500, 30, 50, 50); // 500: x-coordinate, 30: y-coordinate, 50: size
502     group->Add(toggleButton);
503 
504     listScroll_->Add(group);
505 }
506 
UIKit_UITestBorderMarginPadding_Test_009()507 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_009()
508 {
509     AddTitle("UICircleProgress");
510     UICircleProgress* circleProgress = new UICircleProgress();
511     circleProgress->SetStyle(style_);
512     circleProgress->Resize(150, 150);          // 150: width 150: height
513     circleProgress->SetCenterPosition(75, 75); // 75: position x 75: position y
514     circleProgress->SetRadius(50);             // 50: radius
515     circleProgress->SetValue(20);              // 20: value
516     listScroll_->Add(circleProgress);
517 }
518 
UIKit_UITestBorderMarginPadding_Test_010()519 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_010()
520 {
521     AddTitle("UIImageAnimatorView");
522     UIImageAnimatorView* imageAnimator = new UIImageAnimatorView();
523     imageAnimator->SetStyle(style_);
524     imageAnimator->SetPosition(50, 50, 200, 200);                    // 50 : offset 50 : offset 200 : offset 200: offset
525     imageAnimator->SetImageAnimatorSrc(g_imageAnimatorInfo, 4, 100); // 4: the number of images, 100: updating time
526     imageAnimator->Start();
527     listScroll_->Add(imageAnimator);
528 }
529 
UIKit_UITestBorderMarginPadding_Test_011()530 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_011()
531 {
532     AddTitle("UIImageView");
533     UIImageView* imageView = new UIImageView();
534     imageView->SetStyle(style_);
535     imageView->SetWidth(50);  // 50 : size
536     imageView->SetHeight(50); // 50 : size
537     imageView->SetSrc(BLUE_RGB888_IMAGE_PATH);
538     listScroll_->Add(imageView);
539 }
540 
UIKit_UITestBorderMarginPadding_Test_012()541 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_012()
542 {
543     AddTitle("UILabelButton");
544     UILabelButton* button = new UILabelButton();
545     button->SetStyleForState(STYLE_MARGIN_LEFT, style_.marginLeft_, UIButton::RELEASED);
546     button->SetStyleForState(STYLE_MARGIN_LEFT, style_.marginLeft_, UIButton::PRESSED);
547     button->SetStyleForState(STYLE_MARGIN_TOP, style_.marginTop_, UIButton::RELEASED);
548     button->SetStyleForState(STYLE_MARGIN_TOP, style_.marginTop_, UIButton::PRESSED);
549     button->SetStyleForState(STYLE_MARGIN_RIGHT, style_.marginRight_, UIButton::RELEASED);
550     button->SetStyleForState(STYLE_MARGIN_RIGHT, style_.marginRight_, UIButton::PRESSED);
551     button->SetStyleForState(STYLE_MARGIN_BOTTOM, style_.marginBottom_, UIButton::RELEASED);
552     button->SetStyleForState(STYLE_MARGIN_BOTTOM, style_.marginBottom_, UIButton::PRESSED);
553 
554     button->SetStyleForState(STYLE_BORDER_WIDTH, style_.borderWidth_, UIButton::RELEASED);
555     button->SetStyleForState(STYLE_BORDER_WIDTH, style_.borderWidth_, UIButton::PRESSED);
556     button->SetStyleForState(STYLE_BORDER_OPA, style_.borderOpa_, UIButton::RELEASED);
557     button->SetStyleForState(STYLE_BORDER_OPA, style_.borderOpa_, UIButton::PRESSED);
558     button->SetStyleForState(STYLE_BORDER_COLOR, style_.borderColor_.full, UIButton::RELEASED);
559     button->SetStyleForState(STYLE_BORDER_COLOR, style_.borderColor_.full, UIButton::PRESSED);
560 
561     button->SetStyleForState(STYLE_PADDING_LEFT, style_.paddingLeft_, UIButton::RELEASED);
562     button->SetStyleForState(STYLE_PADDING_LEFT, style_.paddingLeft_, UIButton::PRESSED);
563     button->SetStyleForState(STYLE_PADDING_TOP, style_.paddingTop_, UIButton::RELEASED);
564     button->SetStyleForState(STYLE_PADDING_TOP, style_.paddingTop_, UIButton::PRESSED);
565     button->SetStyleForState(STYLE_PADDING_RIGHT, style_.paddingRight_, UIButton::RELEASED);
566     button->SetStyleForState(STYLE_PADDING_RIGHT, style_.paddingRight_, UIButton::PRESSED);
567     button->SetStyleForState(STYLE_PADDING_BOTTOM, style_.paddingBottom_, UIButton::RELEASED);
568     button->SetStyleForState(STYLE_PADDING_BOTTOM, style_.paddingBottom_, UIButton::PRESSED);
569     button->SetWidth(200); // 200 : size
570     button->SetHeight(50); // 50 : size
571     button->SetText("Test UILabelButton");
572     listScroll_->Add(button);
573 }
574 
UIKit_UITestBorderMarginPadding_Test_013()575 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_013()
576 {
577     AddTitle("UIList");
578     if (adapter_ == nullptr) {
579         adapter_ = new TextAdapter();
580     }
581     adapter_->SetData(adapterData_);
582     adapter_->GetStyle() = style_;
583 
584     UIList* list = new UIList(UIList::VERTICAL);
585     list->SetIntercept(true);
586     list->SetStyle(style_);
587     list->Resize(300, 400); // 300 : size, 400 : size
588     list->SetAdapter(adapter_);
589     listScroll_->Add(list);
590 }
591 
UIKit_UITestBorderMarginPadding_Test_014()592 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_014()
593 {
594     AddTitle("UIPicker");
595     picker_ = new UIPicker();
596     picker_->SetIntercept(true);
597     picker_->SetStyle(style_);
598     picker_->SetFontId(16, 18); // 16:back font id 18:high light font id
599     picker_->SetItemHeight(50); // 50: height
600     picker_->SetTextColor(Color::White(), Color::Red());
601     picker_->SetValues(-5, 20); // -5: start 20:end
602     picker_->Resize(300, 400);  // 300: picker size 400: picker size
603     listScroll_->Add(picker_);
604 }
605 
UIKit_UITestBorderMarginPadding_Test_015()606 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_015()
607 {
608     AddTitle("UIQrcode");
609     UIQrcode* qrcode = new UIQrcode();
610     qrcode->SetStyle(style_);
611     qrcode->Resize(60, 60); // 60: height
612     qrcode->SetQrcodeInfo("Hello\n HarmonyOS Lite GUI");
613     listScroll_->Add(qrcode);
614 }
615 
UIKit_UITestBorderMarginPadding_Test_016()616 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_016()
617 {
618     AddTitle("UIScroll");
619     UIScrollView* scroll = new UIScrollView();
620     scroll->SetIntercept(true);
621     scroll->SetStyle(style_);
622     scroll->Resize(200, 200); // 200: size
623 
624     UILabelButton* button = new UILabelButton();
625     button->SetPosition(0, 0, 300, 300); // 300: size
626     button->SetText("button1");
627     scroll->Add(button);
628     listScroll_->Add(scroll);
629 }
UIKit_UITestBorderMarginPadding_Test_017()630 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_017()
631 {
632     AddTitle("UISlider");
633     UISlider* slider = new UISlider();
634     slider->SetIntercept(true);
635     slider->SetStyle(style_);
636     slider->Resize(50, 300);     // 50: width; 300: height
637     slider->SetValidHeight(250); // 250: valid height;
638     slider->SetValue(20);        // 20:  progress bar current value
639     slider->SetDirection(UISlider::Direction::DIR_BOTTOM_TO_TOP);
640     listScroll_->Add(slider);
641 }
642 
UIKit_UITestBorderMarginPadding_Test_018()643 void UITestBorderMarginPadding::UIKit_UITestBorderMarginPadding_Test_018()
644 {
645     AddTitle("UISwipe");
646     UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
647     swipe->SetIntercept(true);
648     swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
649     swipe->Resize(200, 200);  // 200: size
650     swipe->SetBlankSize(100); // 100: is blank size
651     UILabel* view1 = new UILabel();
652     view1->SetStyle(style_);
653     view1->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
654     view1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
655     view1->SetPosition(0, 0, 150, 150); // 150: size
656     view1->SetText("label1");
657     swipe->Add(view1);
658     UILabel* view2 = new UILabel();
659     view2->SetStyle(style_);
660     view2->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
661     view2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
662     view2->SetPosition(0, 0, 150, 150); // 150: size
663     view2->SetText("label2");
664     swipe->Add(view2);
665     UILabel* view3 = new UILabel();
666     view3->SetStyle(style_);
667     view3->SetLineBreakMode(UILabel::LINE_BREAK_CLIP);
668     view3->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
669     view3->SetPosition(0, 0, 150, 150); // 150: size
670     view3->SetText("label3");
671     swipe->Add(view3);
672 
673     listScroll_->Add(swipe);
674 }
675 } // namespace OHOS
676