1 /*
2  * Copyright (c) 2020-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef UI_TEST_CLIP_H
17 #define UI_TEST_CLIP_H
18 
19 #include "components/ui_image_view.h"
20 #include "components/ui_label_button.h"
21 #include "components/ui_scroll_view.h"
22 #include "draw/clip_utils.h"
23 #include "ui_test.h"
24 
25 namespace OHOS {
26 constexpr char* UI_TEST_RADIUS_1 = "radius+1";
27 constexpr char* UI_TEST_RADIUS_2 = "radius-1";
28 constexpr char* UI_TEST_RADIUS_3 = "radius+5";
29 constexpr char* UI_TEST_RADIUS_4 = "radius-5";
30 constexpr char* UI_TEST_ARC_1 = "startAngle+1";
31 constexpr char* UI_TEST_ARC_2 = "startAngle-1";
32 constexpr char* UI_TEST_ARC_3 = "endAngle+1";
33 constexpr char* UI_TEST_ARC_4 = "endAngle-1";
34 class UITestClip : public UITest, public UIView::OnClickListener {
35 public:
UITestClip()36     UITestClip() {}
~UITestClip()37     ~UITestClip() {}
38     void SetUp() override;
39     void TearDown() override;
40     UIView* GetTestView() override;
41     bool OnClick(UIView& view, const ClickEvent& event) override;
42 
43     void UIKitClipTest001();
44     void UIKitClipTest002();
45     void UIKitClipTest003();
46     void UIKitClipTest004();
47     void UIKitClipTest005();
48 
49 private:
50     const static int32_t BUFFER_SIZE = 20;
51     const static int16_t GAP = 10;
52     const static int16_t TITLE_HEIGHT = 29;
53     const static uint16_t BLOCK_WIDTH = 454;
54     const static uint16_t BLOCK_HEIGHT = 200;
55     const static uint16_t IMAGE_POSITION_X = 20;
56     const static uint16_t IMAGE_POSITION_Y = 20;
57     const static int16_t ANGLE_STEP = 5;
58     const static int16_t RADIUS_STEP_1 = 1;
59     const static int16_t RADIUS_STEP_5 = 5;
60 
61     void CreateTitleLabel(const char* title);
62     UIImageView* CreateImageView();
63     void ClipImage(UIImageView* imageView, ClipPath& path);
64     void SetUpButton(UILabelButton* btn, const char* title, int16_t x, int16_t y, const char* id = nullptr);
65 
66     UILabelButton* btnRadiusInc1_ = nullptr;
67     UILabelButton* btnRadiusInc5_ = nullptr;
68     UILabelButton* btnRadiusDec1_ = nullptr;
69     UILabelButton* btnRadiusDec5_ = nullptr;
70     UILabelButton* btnStartAngleInc_ = nullptr;
71     UILabelButton* btnStartAngleDec_ = nullptr;
72     UILabelButton* btnEndAngleInc_ = nullptr;
73     UILabelButton* btnEndAngleDec_ = nullptr;
74     UILabel* radiusText_ = nullptr;
75     UIImageView* imageView1_ = nullptr;
76     UIImageView* imageView2_ = nullptr;
77     UIScrollView* container_ = nullptr;
78 };
79 } // namespace OHOS
80 #endif
81