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 if (label2 == nullptr) {
235 return;
236 }
237 label2->SetArcTextCenter(CENTER_X + 200, CENTER_Y + 20); // 200: width 20 : height
238 group->Add(label2);
239 container_->Add(group);
240 group->LayoutBottomToSibling("UIKitOpacityTestUILabelButton001", 10); // 10 : height
241 }
242 }
243
CreateTestCaseUIImageView(const char * path,uint8_t opaScale) const244 UIImageView* UITestOpacity::CreateTestCaseUIImageView(const char* path, uint8_t opaScale) const
245 {
246 UIImageView* imageView = new UIImageView();
247 imageView->SetPosition(10, 30, 130, 130); // 10 x 30: y 130 : size
248 imageView->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
249 imageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
250 imageView->SetSrc(path);
251 imageView->SetOpaScale(opaScale); // 200: opacity
252 return imageView;
253 }
254
UIKitOpacityTestUIImageView001()255 void UITestOpacity::UIKitOpacityTestUIImageView001()
256 {
257 if (container_ != nullptr) {
258 UIViewGroup* group = CreateTestCaseGroup(" display UIImageView with opacity 200 and 100");
259 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
260 group->SetViewId("UIKitOpacityTestUIImageView001");
261 UIImageView* imageView = CreateTestCaseUIImageView(BLUE_IMAGE_PATH, 200); // 200: opacity
262 group->Add(imageView);
263 UIImageView* imageView2 = CreateTestCaseUIImageView(BLUE_ARGB8888_IMAGE_PATH, 100); // 100: opacity
264 imageView2->SetX(200); // 200: width
265 group->Add(imageView2);
266 container_->Add(group);
267 group->LayoutBottomToSibling("UIKitOpacityTestUIArcLabel001", 10); // 10 : height
268 }
269 }
270
CreateTestCaseUIImageAnimator(const ImageAnimatorInfo imageAnimatorInfo[],uint8_t opaScale) const271 UIImageAnimatorView* UITestOpacity::CreateTestCaseUIImageAnimator(const ImageAnimatorInfo imageAnimatorInfo[],
272 uint8_t opaScale) const
273 {
274 UIImageAnimatorView* imageAnimator = new UIImageAnimatorView();
275 imageAnimator->SetPosition(10, 30, 200, 200); // 10 : offset 30 : offset 200 : offset 200: offset
276 imageAnimator->SetOpaScale(opaScale);
277 imageAnimator->SetImageAnimatorSrc(imageAnimatorInfo, 4, 10); // 4: image number, 10: updating time
278 imageAnimator->Start();
279 return imageAnimator;
280 }
281
UIKitOpacityTestUIImageAnimator001()282 void UITestOpacity::UIKitOpacityTestUIImageAnimator001()
283 {
284 if (container_ != nullptr) {
285 UIViewGroup* group = CreateTestCaseGroup(" display UIImageAnimator with opacity 200 and 100");
286 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50: height
287 group->SetViewId("UIKitOpacityTestUIImageAnimator001");
288 UIImageAnimatorView* imageAnimator = CreateTestCaseUIImageAnimator(g_imageAnimatorInfo, 200); // 200: opacity
289 group->Add(imageAnimator);
290 UIImageAnimatorView* imageAnimator2 = CreateTestCaseUIImageAnimator(g_imageAnimatorInfo2, 100); // 100: opacity
291 imageAnimator2->SetPosition(230, 30); // 230: width 30: height
292 group->Add(imageAnimator2);
293 container_->Add(group);
294 group->LayoutBottomToSibling("UIKitOpacityTestUIImageView001", 10); // 10: height
295 }
296 }
CreateTestCaseUIView(uint8_t opaScale) const297 UIView* UITestOpacity::CreateTestCaseUIView(uint8_t opaScale) const
298 {
299 UIView* view = new UIView();
300 view->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT); // 10: x 30: y
301 view->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
302 view->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
303 view->SetOpaScale(opaScale);
304 return view;
305 }
306
UIKitOpacityTestUIView001()307 void UITestOpacity::UIKitOpacityTestUIView001()
308 {
309 if (container_ != nullptr) {
310 UIViewGroup* group = CreateTestCaseGroup(" display UIView with opacity 200 and 100");
311 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 50); // 50 : height
312 group->SetViewId("UIKitOpacityTestUIView001");
313
314 UIView* view = CreateTestCaseUIView(200); // 200 : opacity
315 group->Add(view);
316 UIView* view2 = CreateTestCaseUIView(100); // 100 : opacity
317 view2->SetX(200); // 200: wdith
318 group->Add(view2);
319
320 container_->Add(group);
321 group->LayoutBottomToSibling("UIKitOpacityTestUIImageAnimator001", 10); // 10 : height
322 }
323 }
324
UIKitOpacityTestUIViewGroup001()325 void UITestOpacity::UIKitOpacityTestUIViewGroup001()
326 {
327 if (container_ != nullptr) {
328 UIViewGroup* group = CreateTestCaseGroup(" display UIViewGroup with opacity 200 and 100");
329 group->Resize(Screen::GetInstance().GetWidth(), (BUTTON_HEIGHT << 1) + 100); // 100: height
330 group->SetViewId("UIKitOpacityTestUIViewGroup001");
331
332 UIViewGroup* group1 = new UIViewGroup();
333 group1->SetPosition(10, 30, (BUTTON_WIDTH << 1) + 50, (BUTTON_HEIGHT << 1) + 100); // 30 y 50: width 100: height
334 group1->SetStyle(STYLE_BACKGROUND_COLOR, (Color::Red()).full);
335 UIViewGroup* group2 = new UIViewGroup();
336 group2->SetPosition(170, 250, 150, 150); // 170: x 250: y 150: width 150: height
337 group2->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
338
339 UILabelButton* labelButton = new UILabelButton();
340 labelButton->SetPosition(10, 10, 60, 30); // 10: x y 60 wdith 30 height
341 labelButton->SetText("Test1");
342 UILabelButton* labelButton2 = new UILabelButton();
343 labelButton2->SetPosition(170, 10, 60, 30); // 170: x 10: y 60 wdith 30 height
344 labelButton2->SetText("Test2");
345 labelButton2->SetOpaScale(100); // 100: opacity
346 UIButton* button = new UIButton();
347 button->SetPosition(10, 60, BUTTON_WIDTH, BUTTON_HEIGHT); // 10: x 60: y
348 UIButton* button2 = new UIButton();
349 button2->SetPosition(170, 60, BUTTON_WIDTH, BUTTON_HEIGHT); // 170: x 60: y
350 button2->SetImageSrc(BLUE_IMAGE_PATH, YELLOW_IMAGE_PATH);
351 button2->SetOpaScale(100); // 100: opacity
352 UIImageView* imageView = new UIImageView();
353 imageView->SetPosition(10, 250, 50, 50); // 10: x 250: y 50 : size
354 imageView->SetSrc(BLUE_IMAGE_PATH);
355 imageView->SetOpaScale(100); // 100: opacity
356 UIImageView* imageView2 = new UIImageView();
357 imageView2->SetPosition(10, 10, 50, 50); // 10: x y 50 : size
358 imageView2->SetSrc(YELLOW_IMAGE_PATH);
359
360 group2->Add(imageView2);
361 group1->Add(labelButton);
362 group1->Add(labelButton2);
363 group1->Add(button);
364 group1->Add(button2);
365 group1->Add(imageView);
366 group1->Add(group2);
367 group2->SetOpaScale(100); // 100: opacity
368 group1->SetOpaScale(200); // 200: opacity
369
370 group->Add(group1);
371 container_->Add(group);
372 group->LayoutBottomToSibling("UIKitOpacityTestUIView001", 10); // 10 : height
373 }
374 }
375
CreateTestCaseUIList(uint8_t opaScale) const376 UIList* UITestOpacity::CreateTestCaseUIList(uint8_t opaScale) const
377 {
378 List<const char*>* adapterData = new List<const char*>();
379 adapterData->PushBack("000");
380 adapterData->PushBack("111");
381 adapterData->PushBack("222");
382 adapterData->PushBack("333");
383 adapterData->PushBack("444");
384 adapterData->PushBack("555");
385 adapterData->PushBack("666");
386 adapterData->PushBack("777");
387 adapterData->PushBack("888");
388 adapterData->PushBack("999");
389
390 TextAdapter* adapter = new TextAdapter();
391 adapter->SetData(adapterData);
392 UIList* list = new UIList(UIList::VERTICAL);
393 list->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
394 list->SetPosition(10, 30, BUTTON_WIDTH, BUTTON_HEIGHT); // 10 x 30 y
395 list->SetAdapter(adapter);
396 list->SetOpaScale(opaScale); // 200: opacity
397 return list;
398 }
399
UIKitOpacityTestUIList001()400 void UITestOpacity::UIKitOpacityTestUIList001()
401 {
402 if (container_ != nullptr) {
403 UIViewGroup* group = CreateTestCaseGroup(" display UIList with opacity 200 and 100");
404 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT + 100); // 100: height
405 group->SetViewId("UIKitOpacityTestUIList001");
406 UIList* list = CreateTestCaseUIList(200); // 200 : opacity
407 group->Add(list);
408 UIList* list2 = CreateTestCaseUIList(100); // 100 : opacity
409 list2->SetX(200); // 200: width
410 group->Add(list2);
411 container_->Add(group);
412 group->LayoutBottomToSibling("UIKitOpacityTestUIViewGroup001", 10); // 10 : height
413 }
414 }
415
UIKitOpacityTestUIScrollView001()416 void UITestOpacity::UIKitOpacityTestUIScrollView001()
417 {
418 if (container_ != nullptr) {
419 UIViewGroup* group = CreateTestCaseGroup(" display UIScrollView with opacity 200 and 100");
420 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT << 1);
421 group->SetViewId("UIKitOpacityTestUIScrollView001");
422
423 UIScrollView* group1 = new UIScrollView();
424 group1->SetPosition(10, 30, (BUTTON_WIDTH << 1) + 50, (BUTTON_HEIGHT) + 100); // 10 x 30 y 50: width 100: height
425 group1->SetStyle(STYLE_BACKGROUND_COLOR, (Color::Red()).full);
426 UIScrollView* group2 = new UIScrollView();
427 group2->SetPosition(170, 80, 150, 150); // 170: x 80: y 150: width 150: height
428 group2->SetStyle(STYLE_BACKGROUND_COLOR, (Color::White()).full);
429 UILabelButton* labelButton = new UILabelButton();
430 labelButton->SetPosition(10, 10, 80, 40); // 10 x y 80: width 40: height
431 labelButton->SetText("test1");
432 UILabelButton* labelButton2 = new UILabelButton();
433 labelButton2->SetPosition(170, 10, 80, 40); // 170: x 10: y 80: width 40: height
434 labelButton2->SetText("test2");
435 labelButton2->SetOpaScale(100); // 100: opacity
436 UIImageView* imageView = new UIImageView();
437 imageView->SetPosition(10, 80, 50, 50); // 10: x 80: y 50 : size
438 imageView->SetSrc(BLUE_IMAGE_PATH);
439 imageView->SetOpaScale(100); // 100: opacity
440 UIImageView* imageView2 = new UIImageView();
441 imageView2->SetPosition(10, 10, 50, 50); // 10: x y 50 : size
442 imageView2->SetSrc(YELLOW_IMAGE_PATH);
443
444 group2->Add(imageView2);
445 group1->Add(labelButton);
446 group1->Add(labelButton2);
447 group1->Add(imageView);
448 group1->Add(group2);
449 group2->SetOpaScale(100); // 100: opacity
450 group1->SetOpaScale(200); // 200: opacity
451 group->Add(group1);
452 container_->Add(group);
453 group->LayoutBottomToSibling("UIKitOpacityTestUIList001", 10); // 10 : height
454 }
455 }
456
UIKitOpacityTestUISwipeView001()457 void UITestOpacity::UIKitOpacityTestUISwipeView001()
458 {
459 if (container_ != nullptr) {
460 UIViewGroup* group = CreateTestCaseGroup(" display UISwipeView with opacity 200 and 100");
461 group->Resize(Screen::GetInstance().GetWidth(), BUTTON_HEIGHT);
462 group->SetViewId("UIKitOpacityTestUISwipeView001");
463
464 UISwipeView* swipe = new UISwipeView(UISwipeView::HORIZONTAL);
465 swipe->SetStyle(STYLE_BACKGROUND_COLOR, Color::Red().full);
466 swipe->SetPosition(10, 30, BUTTON_WIDTH << 1, BUTTON_HEIGHT); // 10 30 size
467 swipe->SetBlankSize(50); // 50: is blank size
468 group->Add(swipe);
469
470 UILabelButton* button1 = new UILabelButton();
471 button1->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
472 button1->SetText("button1");
473 swipe->Add(button1);
474
475 UILabelButton* button2 = new UILabelButton();
476 button2->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
477 button2->SetText("button2");
478 button2->SetOpaScale(200); // 200: opacity
479 swipe->Add(button2);
480
481 UILabelButton* button3 = new UILabelButton();
482 button3->SetPosition(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT >> 1);
483 button3->SetText("button3");
484 button3->SetOpaScale(100); // 100: opacity
485 swipe->Add(button3);
486
487 swipe->SetOpaScale(200); // 200: opacity
488 container_->Add(group);
489 group->LayoutBottomToSibling("UIKitOpacityTestUIScrollView001", 10); // 10 : height
490 }
491 }
492 } // namespace OHOS
493