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 "components/ui_repeat_button.h"
17 
18 #include <climits>
19 #include <gtest/gtest.h>
20 
21 using namespace testing::ext;
22 namespace OHOS {
23 class UIRepeatButtonTest : public testing::Test {
24 public:
25     static void SetUpTestCase();
26     static void TearDownTestCase();
27     static UIRepeatButton* repeatBtn_;
28 };
29 
30 UIRepeatButton* UIRepeatButtonTest::repeatBtn_ = nullptr;
31 
SetUpTestCase()32 void UIRepeatButtonTest::SetUpTestCase()
33 {
34     if (repeatBtn_ == nullptr) {
35         repeatBtn_ = new UIRepeatButton();
36     }
37 }
38 
TearDownTestCase()39 void UIRepeatButtonTest::TearDownTestCase()
40 {
41     if (repeatBtn_ != nullptr) {
42         delete repeatBtn_;
43         repeatBtn_ = nullptr;
44     }
45 }
46 
47 /**
48  * @tc.name: UIRepeatButtonGetViewType_001
49  * @tc.desc: Verify GetViewType function, equal.
50  * @tc.type: FUNC
51  * @tc.require: SR000DRSH1
52  */
53 HWTEST_F(UIRepeatButtonTest, UIRepeatButtonTestGetViewType_001, TestSize.Level1)
54 {
55     if (repeatBtn_ == nullptr) {
56         EXPECT_NE(0, 0);
57         return;
58     }
59     EXPECT_EQ(repeatBtn_->GetViewType(), UI_REPEAT_BUTTON);
60 }
61 
62 /**
63  * @tc.name: UIRepeatButtonSetInterval_001
64  * @tc.desc: Verify SetInterval function, equal.
65  * @tc.type: FUNC
66  * @tc.require: SR000DRSH1
67  */
68 HWTEST_F(UIRepeatButtonTest, UIRepeatButtonSetInterval_001, TestSize.Level0)
69 {
70     if (repeatBtn_ == nullptr) {
71         EXPECT_NE(0, 0);
72         return;
73     }
74     const uint16_t interval = 10;
75     repeatBtn_->SetInterval(interval);
76     EXPECT_EQ(repeatBtn_->GetInterval(), interval);
77 }
78 } // namespace OHOS
79