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 "events/long_press_event.h"
17
18 #include <climits>
19 #include <gtest/gtest.h>
20
21 using namespace testing::ext;
22 namespace OHOS {
23 namespace {
24 const Point INIT_POS = {100, 200};
25 const TimeType TIME_STAMP = 10;
26 }
27
28 class LongPressEventTest : public testing::Test {
29 public:
30 static void SetUpTestCase(void);
31 static void TearDownTestCase(void);
32 static LongPressEvent* longPressEvent_;
33 };
34
35 LongPressEvent* LongPressEventTest::longPressEvent_ = nullptr;
36
SetUpTestCase(void)37 void LongPressEventTest::SetUpTestCase(void)
38 {
39 if (longPressEvent_ == nullptr) {
40 longPressEvent_ = new LongPressEvent(INIT_POS, TIME_STAMP);
41 }
42 }
43
TearDownTestCase(void)44 void LongPressEventTest::TearDownTestCase(void)
45 {
46 if (longPressEvent_ != nullptr) {
47 delete longPressEvent_;
48 longPressEvent_ = nullptr;
49 }
50 }
51 /**
52 * @tc.name: LongPressEventConstructor_001
53 * @tc.desc: Verify GetCurrentPos function, equal.
54 * @tc.type: FUNC
55 * @tc.require: SR000DRSH4
56 */
57 HWTEST_F(LongPressEventTest, LongPressEventConstructor_001, TestSize.Level0)
58 {
59 if (longPressEvent_ == nullptr) {
60 EXPECT_EQ(1, 0);
61 return;
62 }
63 EXPECT_EQ(longPressEvent_->GetCurrentPos().x, INIT_POS.x);
64 EXPECT_EQ(longPressEvent_->GetCurrentPos().y, INIT_POS.y);
65 }
66
67 /**
68 * @tc.name: LongPressEventConstructor_002
69 * @tc.desc: Verify GetCurrentPos function, equal.
70 * @tc.type: FUNC
71 * @tc.require: SR000DRSH4
72 */
73 HWTEST_F(LongPressEventTest, LongPressEventConstructor_002, TestSize.Level0)
74 {
75 if (longPressEvent_ == nullptr) {
76 EXPECT_EQ(1, 0);
77 return;
78 }
79 EXPECT_EQ(longPressEvent_->GetTimeStamp(), TIME_STAMP);
80 }
81 } // namespace OHOS
82