1 /*
2  * Copyright (c) 2024 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 FOUNDATION_ACE_TEST_UNITTEST_CORE_PATTERN_SWIPER_SWIPER_TEST_NG_H
17 #define FOUNDATION_ACE_TEST_UNITTEST_CORE_PATTERN_SWIPER_SWIPER_TEST_NG_H
18 
19 #include "test/unittest/core/pattern/test_ng.h"
20 
21 #define private public
22 #define protected public
23 #include "core/components_ng/pattern/swiper/swiper_model_ng.h"
24 #include "core/components_ng/pattern/swiper/swiper_paint_method.h"
25 #include "core/components_ng/pattern/swiper/swiper_pattern.h"
26 
27 namespace OHOS::Ace::NG {
28 using namespace testing;
29 using namespace testing::ext;
30 constexpr float SWIPER_WIDTH = 480.f;
31 constexpr float SWIPER_HEIGHT = 800.f;
32 constexpr int32_t ITEM_NUMBER = 4;
33 constexpr int32_t DEFAULT_INTERVAL = 3000;
34 constexpr int32_t DEFAULT_DURATION = 400;
35 constexpr float CAPTURE_MARGIN_SIZE = 15.0f;
36 const SwiperArrowParameters ARROW_PARAMETERS = {
37     true, true, Dimension(24.f), Color::BLACK, Dimension(18.f), Color::FromString("#182431")
38 };
39 const Color HOVER_ARROW_COLOR = Color::GRAY;
40 const Color CLICK_ARROW_COLOR = Color::FromString("#19182431");
41 constexpr double ARROW_DISABLED_ALPHA = 0.5;
42 const Color INDICATOR_TEXT_FONT_COLOR = Color::FromString("#ff182431");
43 const Dimension INDICATOR_TEXT_FONT_SIZE = Dimension(14.f);
44 const FontWeight INDICATOR_TEXT_FONT_WEIGHT = FontWeight::W800;
45 constexpr float PRE_MARGIN = 10.f;
46 constexpr float NEXT_MARGIN = 20.f;
47 
48 class SwiperTestNg : public TestNG {
49 public:
50     static void SetUpTestSuite();
51     static void TearDownTestSuite();
52     void SetUp() override;
53     void TearDown() override;
54     void GetInstance();
55 
56     void Create(const std::function<void(SwiperModelNG)>& callback = nullptr);
57     void CreateWithItem(const std::function<void(SwiperModelNG)>& callback = nullptr, int32_t itemNumber = ITEM_NUMBER);
58     static void CreateItem(int32_t itemNumber = ITEM_NUMBER);
59     static void CreateItemWithSize(float width, float height);
60     void ShowNext();
61     void ShowPrevious();
62     void ChangeIndex(int32_t index);
63 
64     void InitCaptureTest();
65 
66     RefPtr<FrameNode> frameNode_;
67     RefPtr<SwiperPattern> pattern_;
68     RefPtr<SwiperEventHub> eventHub_;
69     RefPtr<SwiperLayoutProperty> layoutProperty_;
70     RefPtr<SwiperPaintProperty> paintProperty_;
71     RefPtr<SwiperAccessibilityProperty> accessibilityProperty_;
72     RefPtr<SwiperController> controller_;
73 
74     RefPtr<FrameNode> indicatorNode_;
75     RefPtr<FrameNode> leftArrowNode_;
76     RefPtr<FrameNode> rightArrowNode_;
77 };
78 } // namespace OHOS::Ace::NG
79 
80 #endif // FOUNDATION_ACE_TEST_UNITTEST_CORE_PATTERN_SWIPER_SWIPER_TEST_NG_H