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/cancel_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 }
26 class CancelEventTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29 static void TearDownTestCase(void);
30 static CancelEvent* cancelEvent_;
31 };
32
33 CancelEvent* CancelEventTest::cancelEvent_ = nullptr;
34
SetUpTestCase(void)35 void CancelEventTest::SetUpTestCase(void)
36 {
37 if (cancelEvent_ == nullptr) {
38 cancelEvent_ = new CancelEvent(INIT_POS);
39 }
40 }
41
TearDownTestCase(void)42 void CancelEventTest::TearDownTestCase(void)
43 {
44 if (cancelEvent_ != nullptr) {
45 delete cancelEvent_;
46 cancelEvent_ = nullptr;
47 }
48 }
49
50 /**
51 * @tc.name: CancelEventConstructor_001
52 * @tc.desc: Verify Constructor function, equal.
53 * @tc.type: FUNC
54 * @tc.require: SR000DRSH4
55 */
56 HWTEST_F(CancelEventTest, CancelEventConstructor_001, TestSize.Level0)
57 {
58 if (cancelEvent_ == nullptr) {
59 EXPECT_EQ(1, 0);
60 return;
61 }
62 EXPECT_EQ(cancelEvent_->GetCurrentPos().x, INIT_POS.x);
63 EXPECT_EQ(cancelEvent_->GetCurrentPos().y, INIT_POS.y);
64 }
65 } // namespace OHOS
66