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 #ifndef UI_TEST_SCREENSHOT_H
17 #define UI_TEST_SCREENSHOT_H
18 
19 #include "graphic_config.h"
20 #if defined(ENABLE_DEBUG) && ENABLE_DEBUG
21 #include "components/ui_scroll_view.h"
22 #include "components/ui_label.h"
23 #include "components/ui_label_button.h"
24 #include "dfx/ui_screenshot.h"
25 #include "ui_test.h"
26 
27 namespace OHOS {
28 class UITestScreenshot : public UITest {
29 public:
UITestScreenshot()30     UITestScreenshot() {}
~UITestScreenshot()31     ~UITestScreenshot() {}
32     void SetUp() override;
33     void TearDown() override;
34     const UIView* GetTestView() override;
35 
36     /**
37      * @brief Test screenshot Function
38      */
39     void UIKit_SCREENSHOT_TEST_001();
40 
41 private:
42     UIScrollView* container_ = nullptr;
43     UIView::OnClickListener* clickLeftListener_ = nullptr;
44     UIView::OnClickListener* clickRightListener_ = nullptr;
SetUpButton(const char * title)45     UILabelButton* SetUpButton(const char* title)
46     {
47         UILabelButton* btn = new UILabelButton();
48         btn->SetText(title);
49         btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
50         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
51         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
52         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
53         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
54         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
55         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
56         return btn;
57     }
58 }; // namespace OHOS
59 }
60 #endif // ENABLE_DEBUG
61 #endif // UI_TEST_SCREENSHOT_H
62