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_opacity.h"
17 #include "common/screen.h"
18 #include "components/ui_swipe_view.h"
19 #include "font/ui_font.h"
20 #include "test_resource_config.h"
21 
22 namespace OHOS {
23 namespace {
24 const int16_t TITLE_HEIGHT = 20;
25 const uint16_t LABEL_WIDTH = 200;
26 const uint16_t LABEL_HEIGHT = 50;
27 const uint16_t BUTTON_WIDTH = 150;
28 const uint16_t BUTTON_HEIGHT = 160;
29 const uint16_t CENTER_X = 100;
30 const uint16_t CENTER_Y = 100;
31 const uint16_t RADIUS = 80;
32 static ImageAnimatorInfo g_imageAnimatorInfo[4] = {
33     {GREEN_IMAGE_PATH, {50, 50}, 94, 94, IMG_SRC_FILE_PATH},
34     {YELLOW_IMAGE_PATH, {50, 50}, 94, 94, IMG_SRC_FILE_PATH},
35     {BLUE_IMAGE_PATH, {50, 50}, 94, 94, IMG_SRC_FILE_PATH},
36     {RED_IMAGE_PATH, {50, 50}, 94, 94, IMG_SRC_FILE_PATH},
37 };
38 static ImageAnimatorInfo g_imageAnimatorInfo2[4] = {
39     {GREEN_IMAGE_PATH, {200, 50}, 94, 94, IMG_SRC_FILE_PATH},
40     {YELLOW_IMAGE_PATH, {200, 50}, 94, 94, IMG_SRC_FILE_PATH},
41     {BLUE_IMAGE_PATH, {200, 50}, 94, 94, IMG_SRC_FILE_PATH},
42     {RED_IMAGE_PATH, {200, 50}, 94, 94, IMG_SRC_FILE_PATH},
43 };
44 } // namespace
45 
SetUp()46 void UITestOpacity::SetUp()
47 {
48     if (container_ == nullptr) {
49         container_ = new UIScrollView();
50         container_->SetThrowDrag(true);
51         container_->Resize(Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight() - BACK_BUTTON_HEIGHT);
52     }
53 }
54 
TearDown()55 void UITestOpacity::TearDown()
56 {
57     DeleteChildren(container_);
58     container_ = nullptr;
59 }
60 
CreateTestCaseGroup(const char * title) const61 UIViewGroup* UITestOpacity::CreateTestCaseGroup(const char* title) const
62 {
63     UIViewGroup* group = new UIViewGroup();
64     group->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
65     group->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
66     group->SetPosition(0, 0);
67     UILabel* titleLabel = new UILabel();
68     titleLabel->SetPosition(0, 0, Screen::GetInstance().GetWidth(), TITLE_LABEL_DEFAULT_HEIGHT);
69     titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
70     titleLabel->SetText(title);
71     group->Add(titleLabel);
72     return group;
73 }
74 
GetTestView()75 const UIView* UITestOpacity::GetTestView()
76 {
77     UIKitOpacityTestUILabel001();
78     UIKitOpacityTestUILabel002();
79     UIKitOpacityTestUIButton001();
80     UIKitOpacityTestUIButton002();
81     UIKitOpacityTestUILabelButton001();
82     UIKitOpacityTestUIArcLabel001();
83     UIKitOpacityTestUIImageView001();
84     UIKitOpacityTestUIImageAnimator001();
85     UIKitOpacityTestUIView001();
86     UIKitOpacityTestUIViewGroup001();
87     UIKitOpacityTestUIList001();
88     UIKitOpacityTestUIScrollView001();
89     UIKitOpacityTestUISwipeView001();
90     return container_;
91 }
92 
CreateTestCaseUILabel(const char * title,uint8_t opaScale) const93 UILabel* UITestOpacity::CreateTestCaseUILabel(const char* title, uint8_t opaScale) const
94 {
95     UILabel* label = new UILabel();
96     label->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
97     label->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
98     label->SetPosition(10, 30); // 10 width 30: height
99     label->Resize(LABEL_WIDTH, LABEL_HEIGHT);
100     label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); // 20:font size
101     label->SetText(title);
102     label->SetOpaScale(opaScale); // 200: opacity
103     return label;
104 }
105 
UIKitOpacityTestUILabel001()106 void UITestOpacity::UIKitOpacityTestUILabel001()
107 {
108     if (container_ != nullptr) {
109         UIViewGroup* group = CreateTestCaseGroup(" display dynamic text with opacity 200 and 100");
110         group->Resize(Screen::GetInstance().GetWidth(), LABEL_HEIGHT + 50); // 50 : height
111         group->SetViewId("UIKitOpacityTestUILabel001");
112         UILabel* label = CreateTestCaseUILabel("轻量级GUI-200", 200);  // 200: opacity
113         UILabel* label2 = CreateTestCaseUILabel("轻量级GUI-100", 100); // 100: opacity
114         label2->SetX(220);                                             // 220: width
115         group->Add(label);
116         group->Add(label2);
117         container_->Add(group);
118     }
119 }
120 
UIKitOpacityTestUILabel002()121 void UITestOpacity::UIKitOpacityTestUILabel002()
122 {
123     if (container_ != nullptr) {
124         UIViewGroup* group = CreateTestCaseGroup(" display dynamic text with opacity 256  and -1, uint8_t");
125         group->Resize(Screen::GetInstance().GetWidth(), LABEL_HEIGHT + 50); // 50 : height
126         group->SetViewId("UIKitOpacityTestUILabel002");
127         UILabel* label = CreateTestCaseUILabel("轻量级GUI-200", 256); // 256: opacity
128         UILabel* label2 = CreateTestCaseUILabel("轻量级GUI-100", -1); // -1: opacity
129         label2->SetX(220);                                            // 220: width
130         group->Add(label);
131         group->Add(label2);
132         container_->Add(group);
133         group->LayoutBottomToSibling("UIKitOpacityTestUILabel001", 10); // 10: height
134     }
135 }
136 
UIKitOpacityTestUIButton001()137 void UITestOpacity::UIKitOpacityTestUIButton001()
138 {
139     if (container_ != nullptr) {
140         UIViewGroup* group = CreateTestCaseGroup(" display UIButton with opacity 200 and 100");
141         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT);
142         group->SetViewId("UIKitOpacityTestUIButton001");
143 
144         UIButton* button = new UIButton();
145         button->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT >> 1); // 10: width 30  :height
146         button->SetOpaScale(200);                                      // 200: opacity
147         UIButton* button2 = new UIButton();
148         button2->SetPosition(200, 30, BUTTON_WIDTH, BUTTON_HEIGHT >> 1); // 200: width 30 : height
149         button2->SetOpaScale(100);                                       // 100: opacity
150 
151         group->Add(button);
152         group->Add(button2);
153         container_->Add(group);
154         group->LayoutBottomToSibling("UIKitOpacityTestUILabel002", 10); // 10: height
155     }
156 }
157 
CreateTestCaseUIButton(uint8_t opaScale) const158 UIButton* UITestOpacity::CreateTestCaseUIButton(uint8_t opaScale) const
159 {
160     UIButton* button = new UIButton();
161     button->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
162     button->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
163     button->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT); // 10 30 x y
164     button->SetImageSrc(BLUE_IMAGE_PATH, YELLOW_IMAGE_PATH);
165     button->SetOpaScale(opaScale); // 200: opacity
166     return button;
167 }
168 
UIKitOpacityTestUIButton002()169 void UITestOpacity::UIKitOpacityTestUIButton002()
170 {
171     if (container_ != nullptr) {
172         UIViewGroup* group = CreateTestCaseGroup(" display UIButton Image with opacity 200 and 100");
173         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
174         group->SetViewId("UIKitOpacityTestUIButton002");
175 
176         UIButton* button = CreateTestCaseUIButton(200); // 200: opacity
177         group->Add(button);
178         UIButton* button2 = CreateTestCaseUIButton(100); // 100: opacity
179         button2->SetPosition(200, 30);                   // 200: width 30 y
180         group->Add(button2);
181         container_->Add(group);
182         group->LayoutBottomToSibling("UIKitOpacityTestUIButton001", 10); // 10: height
183     }
184 }
185 
CreateTestCaseUILabelButton(const char * title,uint8_t opaScale) const186 UILabelButton* UITestOpacity::CreateTestCaseUILabelButton(const char* title, uint8_t opaScale) const
187 {
188     UILabelButton* labelButton = new UILabelButton();
189     labelButton->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT >> 1); // 10 x 30 : y
190     labelButton->SetText(title);
191     labelButton->SetOpaScale(opaScale);
192     return labelButton;
193 }
194 
UIKitOpacityTestUILabelButton001()195 void UITestOpacity::UIKitOpacityTestUILabelButton001()
196 {
197     if (container_ != nullptr) {
198         UIViewGroup* group = CreateTestCaseGroup(" display UILabelButton with opacity 200 and 100");
199         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT);
200         group->SetViewId("UIKitOpacityTestUILabelButton001");
201         UILabelButton* labelButton = CreateTestCaseUILabelButton("200", 200); // 200 : opacity
202         group->Add(labelButton);
203         UILabelButton* labelButton2 = CreateTestCaseUILabelButton("100", 100); // 100: opacity
204         labelButton2->SetX(200);                                               // 200: width
205         group->Add(labelButton2);
206         container_->Add(group);
207         group->LayoutBottomToSibling("UIKitOpacityTestUIButton002", 10); // 10: height
208     }
209 }
210 
CreateTestCaseUIArcLabel(const char * title,uint8_t opaScale) const211 UIArcLabel* UITestOpacity::CreateTestCaseUIArcLabel(const char* title, uint8_t opaScale) const
212 {
213     UIArcLabel* label = new UIArcLabel();
214     label->SetArcTextCenter(CENTER_X, CENTER_Y + 20); // 20 : height
215     label->SetArcTextRadius(RADIUS);
216     label->SetArcTextAngle(270, 0);                   // 270: start angle, 0: end angle
217     label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // 30: font size
218     label->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
219     label->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
220     label->SetText(title);
221     label->SetStyle(STYLE_LETTER_SPACE, 30); // 30: space
222     label->SetOpaScale(opaScale);            // 200: opacity
223     return label;
224 }
UIKitOpacityTestUIArcLabel001()225 void UITestOpacity::UIKitOpacityTestUIArcLabel001()
226 {
227     if (container_ != nullptr) {
228         UIViewGroup* group = CreateTestCaseGroup(" display UIArcLabel with opacity 200 and 100");
229         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
230         group->SetViewId("UIKitOpacityTestUIArcLabel001");
231         UIArcLabel* label = CreateTestCaseUIArcLabel("01234567", 200); // 200: opacity
232         group->Add(label);
233         UIArcLabel* label2 = CreateTestCaseUIArcLabel("01234567", 100); // 100: opacity
234         label2->SetArcTextCenter(CENTER_X + 200, CENTER_Y + 20);        // 200: width 20 : height
235         group->Add(label2);
236         container_->Add(group);
237         group->LayoutBottomToSibling("UIKitOpacityTestUILabelButton001", 10); // 10 : height
238     }
239 }
240 
CreateTestCaseUIImageView(const char * path,uint8_t opaScale) const241 UIImageView* UITestOpacity::CreateTestCaseUIImageView(const char* path, uint8_t opaScale) const
242 {
243     UIImageView* imageView = new UIImageView();
244     imageView->SetPosition(10, 30, 130, 130); // 10 x 30: y 130 : size
245     imageView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
246     imageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
247     imageView->SetSrc(path);
248     imageView->SetOpaScale(opaScale); // 200: opacity
249     return imageView;
250 }
251 
UIKitOpacityTestUIImageView001()252 void UITestOpacity::UIKitOpacityTestUIImageView001()
253 {
254     if (container_ != nullptr) {
255         UIViewGroup* group = CreateTestCaseGroup(" display UIImageView with opacity 200 and 100");
256         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
257         group->SetViewId("UIKitOpacityTestUIImageView001");
258         UIImageView* imageView = CreateTestCaseUIImageView(BLUE_IMAGE_PATH, 200); // 200: opacity
259         group->Add(imageView);
260         UIImageView* imageView2 = CreateTestCaseUIImageView(BLUE_ARGB8888_IMAGE_PATH, 100); // 100: opacity
261         imageView2->SetX(200);                                                                  // 200: width
262         group->Add(imageView2);
263         container_->Add(group);
264         group->LayoutBottomToSibling("UIKitOpacityTestUIArcLabel001", 10); // 10 : height
265     }
266 }
267 
CreateTestCaseUIImageAnimator(const ImageAnimatorInfo imageAnimatorInfo[],uint8_t opaScale) const268 UIImageAnimatorView* UITestOpacity::CreateTestCaseUIImageAnimator(const ImageAnimatorInfo imageAnimatorInfo[],
269                                                                   uint8_t opaScale) const
270 {
271     UIImageAnimatorView* imageAnimator = new UIImageAnimatorView();
272     imageAnimator->SetPosition(10, 30, 200, 200); // 10 : offset 30 : offset 200 : offset 200: offset
273     imageAnimator->SetOpaScale(opaScale);
274     imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, 4, 10); // 4: image number, 10: updating time
275     imageAnimator->Start();
276     return imageAnimator;
277 }
278 
UIKitOpacityTestUIImageAnimator001()279 void UITestOpacity::UIKitOpacityTestUIImageAnimator001()
280 {
281     if (container_ != nullptr) {
282         UIViewGroup* group = CreateTestCaseGroup(" display UIImageAnimator with opacity 200 and 100");
283         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50: height
284         group->SetViewId("UIKitOpacityTestUIImageAnimator001");
285         UIImageAnimatorView* imageAnimator = CreateTestCaseUIImageAnimator(g_imageAnimatorInfo, 200); // 200: opacity
286         group->Add(imageAnimator);
287         UIImageAnimatorView* imageAnimator2 = CreateTestCaseUIImageAnimator(g_imageAnimatorInfo2, 100); // 100: opacity
288         imageAnimator2->SetPosition(230, 30); // 230: width 30: height
289         group->Add(imageAnimator2);
290         container_->Add(group);
291         group->LayoutBottomToSibling("UIKitOpacityTestUIImageView001", 10); // 10: height
292     }
293 }
CreateTestCaseUIView(uint8_t opaScale) const294 UIView* UITestOpacity::CreateTestCaseUIView(uint8_t opaScale) const
295 {
296     UIView* view = new UIView();
297     view->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT); // 10: x 30: y
298     view->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
299     view->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
300     view->SetOpaScale(opaScale);
301     return view;
302 }
303 
UIKitOpacityTestUIView001()304 void UITestOpacity::UIKitOpacityTestUIView001()
305 {
306     if (container_ != nullptr) {
307         UIViewGroup* group = CreateTestCaseGroup(" display UIView with opacity 200 and 100");
308         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
309         group->SetViewId("UIKitOpacityTestUIView001");
310 
311         UIView* view = CreateTestCaseUIView(200); // 200 : opacity
312         group->Add(view);
313         UIView* view2 = CreateTestCaseUIView(100); // 100 : opacity
314         view2->SetX(200);                          // 200: wdith
315         group->Add(view2);
316 
317         container_->Add(group);
318         group->LayoutBottomToSibling("UIKitOpacityTestUIImageAnimator001", 10); // 10 : height
319     }
320 }
321 
UIKitOpacityTestUIViewGroup001()322 void UITestOpacity::UIKitOpacityTestUIViewGroup001()
323 {
324     if (container_ != nullptr) {
325         UIViewGroup* group = CreateTestCaseGroup(" display UIViewGroup with opacity 200 and 100");
326         group->Resize(Screen::GetInstance().GetWidth(), (BUTTON_HEIGHT << 1) + 100); // 100: height
327         group->SetViewId("UIKitOpacityTestUIViewGroup001");
328 
329         UIViewGroup* group1 = new UIViewGroup();
330         group1->SetPosition(10, 30, (BUTTON_WIDTH << 1) + 50, (BUTTON_HEIGHT << 1) + 100); // 30 y 50: width 100: height
331         group1->SetStyle(STYLE_BACKGROUND_COLOR, (Color::Red()).full);
332         UIViewGroup* group2 = new UIViewGroup();
333         group2->SetPosition(170, 250, 150, 150); // 170: x 250: y 150: width 150: height
334         group2->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
335 
336         UILabelButton* labelButton = new UILabelButton();
337         labelButton->SetPosition(10, 10, 60, 30); // 10: x y 60 wdith 30 height
338         labelButton->SetText("Test1");
339         UILabelButton* labelButton2 = new UILabelButton();
340         labelButton2->SetPosition(170, 10, 60, 30); // 170: x 10: y 60 wdith 30 height
341         labelButton2->SetText("Test2");
342         labelButton2->SetOpaScale(100); // 100: opacity
343         UIButton* button = new UIButton();
344         button->SetPosition(10, 60, BUTTON_WIDTH, BUTTON_HEIGHT); // 10: x 60: y
345         UIButton* button2 = new UIButton();
346         button2->SetPosition(170, 60, BUTTON_WIDTH, BUTTON_HEIGHT); // 170: x 60: y
347         button2->SetImageSrc(BLUE_IMAGE_PATH, YELLOW_IMAGE_PATH);
348         button2->SetOpaScale(100); // 100: opacity
349         UIImageView* imageView = new UIImageView();
350         imageView->SetPosition(10, 250, 50, 50); // 10: x 250: y 50 : size
351         imageView->SetSrc(BLUE_IMAGE_PATH);
352         imageView->SetOpaScale(100); // 100: opacity
353         UIImageView* imageView2 = new UIImageView();
354         imageView2->SetPosition(10, 10, 50, 50); // 10: x y 50 : size
355         imageView2->SetSrc(YELLOW_IMAGE_PATH);
356 
357         group2->Add(imageView2);
358         group1->Add(labelButton);
359         group1->Add(labelButton2);
360         group1->Add(button);
361         group1->Add(button2);
362         group1->Add(imageView);
363         group1->Add(group2);
364         group2->SetOpaScale(100); // 100: opacity
365         group1->SetOpaScale(200); // 200: opacity
366 
367         group->Add(group1);
368         container_->Add(group);
369         group->LayoutBottomToSibling("UIKitOpacityTestUIView001", 10); // 10 : height
370     }
371 }
372 
CreateTestCaseUIList(uint8_t opaScale) const373 UIList* UITestOpacity::CreateTestCaseUIList(uint8_t opaScale) const
374 {
375     List<const char*>* adapterData = new List<const char*>();
376     adapterData->PushBack("000");
377     adapterData->PushBack("111");
378     adapterData->PushBack("222");
379     adapterData->PushBack("333");
380     adapterData->PushBack("444");
381     adapterData->PushBack("555");
382     adapterData->PushBack("666");
383     adapterData->PushBack("777");
384     adapterData->PushBack("888");
385     adapterData->PushBack("999");
386 
387     TextAdapter* adapter = new TextAdapter();
388     adapter->SetData(adapterData);
389     UIList* list = new UIList(UIList::VERTICAL);
390     list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
391     list->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT); // 10 x 30 y
392     list->SetAdapter(adapter);
393     list->SetOpaScale(opaScale); // 200: opacity
394     return list;
395 }
396 
UIKitOpacityTestUIList001()397 void UITestOpacity::UIKitOpacityTestUIList001()
398 {
399     if (container_ != nullptr) {
400         UIViewGroup* group = CreateTestCaseGroup(" display UIList with opacity 200 and 100");
401         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 100); // 100: height
402         group->SetViewId("UIKitOpacityTestUIList001");
403         UIList* list = CreateTestCaseUIList(200); // 200 : opacity
404         group->Add(list);
405         UIList* list2 = CreateTestCaseUIList(100); // 100 : opacity
406         list2->SetX(200);                          // 200: width
407         group->Add(list2);
408         container_->Add(group);
409         group->LayoutBottomToSibling("UIKitOpacityTestUIViewGroup001", 10); // 10 : height
410     }
411 }
412 
UIKitOpacityTestUIScrollView001()413 void UITestOpacity::UIKitOpacityTestUIScrollView001()
414 {
415     if (container_ != nullptr) {
416         UIViewGroup* group = CreateTestCaseGroup(" display UIScrollView with opacity 200 and 100");
417         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT << 1);
418         group->SetViewId("UIKitOpacityTestUIScrollView001");
419 
420         UIScrollView* group1 = new UIScrollView();
421         group1->SetPosition(10, 30, (BUTTON_WIDTH << 1) + 50, (BUTTON_HEIGHT) + 100); // 10 x 30 y 50: width 100: height
422         group1->SetStyle(STYLE_BACKGROUND_COLOR, (Color::Red()).full);
423         UIScrollView* group2 = new UIScrollView();
424         group2->SetPosition(170, 80, 150, 150); // 170: x 80: y 150: width 150: height
425         group2->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
426         UILabelButton* labelButton = new UILabelButton();
427         labelButton->SetPosition(10, 10, 80, 40); // 10 x y 80: width 40: height
428         labelButton->SetText("test1");
429         UILabelButton* labelButton2 = new UILabelButton();
430         labelButton2->SetPosition(170, 10, 80, 40); // 170: x 10: y 80: width 40: height
431         labelButton2->SetText("test2");
432         labelButton2->SetOpaScale(100); // 100: opacity
433         UIImageView* imageView = new UIImageView();
434         imageView->SetPosition(10, 80, 50, 50); // 10: x 80: y 50 : size
435         imageView->SetSrc(BLUE_IMAGE_PATH);
436         imageView->SetOpaScale(100); // 100: opacity
437         UIImageView* imageView2 = new UIImageView();
438         imageView2->SetPosition(10, 10, 50, 50); // 10: x y 50 : size
439         imageView2->SetSrc(YELLOW_IMAGE_PATH);
440 
441         group2->Add(imageView2);
442         group1->Add(labelButton);
443         group1->Add(labelButton2);
444         group1->Add(imageView);
445         group1->Add(group2);
446         group2->SetOpaScale(100); // 100: opacity
447         group1->SetOpaScale(200); // 200: opacity
448         group->Add(group1);
449         container_->Add(group);
450         group->LayoutBottomToSibling("UIKitOpacityTestUIList001", 10); // 10 : height
451     }
452 }
453 
UIKitOpacityTestUISwipeView001()454 void UITestOpacity::UIKitOpacityTestUISwipeView001()
455 {
456     if (container_ != nullptr) {
457         UIViewGroup* group = CreateTestCaseGroup(" display UISwipeView with opacity 200 and 100");
458         group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT);
459         group->SetViewId("UIKitOpacityTestUISwipeView001");
460 
461         UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
462         swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
463         swipe->SetPosition(10, 30, BUTTON_WIDTH << 1, BUTTON_HEIGHT); // 10 30 size
464         swipe->SetBlankSize(50);                                      // 50: is blank size
465         group->Add(swipe);
466 
467         UILabelButton* button1 = new UILabelButton();
468         button1->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
469         button1->SetText("button1");
470         swipe->Add(button1);
471 
472         UILabelButton* button2 = new UILabelButton();
473         button2->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
474         button2->SetText("button2");
475         button2->SetOpaScale(200); // 200: opacity
476         swipe->Add(button2);
477 
478         UILabelButton* button3 = new UILabelButton();
479         button3->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
480         button3->SetText("button3");
481         button3->SetOpaScale(100); // 100: opacity
482         swipe->Add(button3);
483 
484         swipe->SetOpaScale(200); // 200: opacity
485         container_->Add(group);
486         group->LayoutBottomToSibling("UIKitOpacityTestUIScrollView001", 10); // 10 : height
487     }
488 }
489 } // namespace OHOS
490