1a3e0fd82Sopenharmony_ci/* 2a3e0fd82Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3a3e0fd82Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4a3e0fd82Sopenharmony_ci * you may not use this file except in compliance with the License. 5a3e0fd82Sopenharmony_ci * You may obtain a copy of the License at 6a3e0fd82Sopenharmony_ci * 7a3e0fd82Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8a3e0fd82Sopenharmony_ci * 9a3e0fd82Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10a3e0fd82Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11a3e0fd82Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12a3e0fd82Sopenharmony_ci * See the License for the specific language governing permissions and 13a3e0fd82Sopenharmony_ci * limitations under the License. 14a3e0fd82Sopenharmony_ci */ 15a3e0fd82Sopenharmony_ci 16a3e0fd82Sopenharmony_ci#include "events/event.h" 17a3e0fd82Sopenharmony_ci 18a3e0fd82Sopenharmony_ci#include <climits> 19a3e0fd82Sopenharmony_ci#include <gtest/gtest.h> 20a3e0fd82Sopenharmony_ci 21a3e0fd82Sopenharmony_ciusing namespace testing::ext; 22a3e0fd82Sopenharmony_cinamespace OHOS { 23a3e0fd82Sopenharmony_cinamespace { 24a3e0fd82Sopenharmony_ci const Point INIT_POS = { 100, 200 }; 25a3e0fd82Sopenharmony_ci const TimeType TIME_STAMP = 10; 26a3e0fd82Sopenharmony_ci} 27a3e0fd82Sopenharmony_ci 28a3e0fd82Sopenharmony_ciclass EventTest : public testing::Test { 29a3e0fd82Sopenharmony_cipublic: 30a3e0fd82Sopenharmony_ci static void SetUpTestCase(void); 31a3e0fd82Sopenharmony_ci static void TearDownTestCase(void); 32a3e0fd82Sopenharmony_ci static Event* event_; 33a3e0fd82Sopenharmony_ci}; 34a3e0fd82Sopenharmony_ci 35a3e0fd82Sopenharmony_ciEvent* EventTest::event_ = nullptr; 36a3e0fd82Sopenharmony_ci 37a3e0fd82Sopenharmony_civoid EventTest::SetUpTestCase(void) 38a3e0fd82Sopenharmony_ci{ 39a3e0fd82Sopenharmony_ci if (event_ == nullptr) { 40a3e0fd82Sopenharmony_ci event_ = new Event(INIT_POS); 41a3e0fd82Sopenharmony_ci } 42a3e0fd82Sopenharmony_ci} 43a3e0fd82Sopenharmony_ci 44a3e0fd82Sopenharmony_civoid EventTest::TearDownTestCase(void) 45a3e0fd82Sopenharmony_ci{ 46a3e0fd82Sopenharmony_ci if (event_ != nullptr) { 47a3e0fd82Sopenharmony_ci delete event_; 48a3e0fd82Sopenharmony_ci event_ = nullptr; 49a3e0fd82Sopenharmony_ci } 50a3e0fd82Sopenharmony_ci} 51a3e0fd82Sopenharmony_ci/** 52a3e0fd82Sopenharmony_ci * @tc.name: EventConstructor_001 53a3e0fd82Sopenharmony_ci * @tc.desc: Verify Constructor function, equal. 54a3e0fd82Sopenharmony_ci * @tc.type: FUNC 55a3e0fd82Sopenharmony_ci * @tc.require: SR000DRSH4 56a3e0fd82Sopenharmony_ci */ 57a3e0fd82Sopenharmony_ciHWTEST_F(EventTest, EventConstructor_001, TestSize.Level1) 58a3e0fd82Sopenharmony_ci{ 59a3e0fd82Sopenharmony_ci if (event_ == nullptr) { 60a3e0fd82Sopenharmony_ci EXPECT_EQ(1, 0); 61a3e0fd82Sopenharmony_ci return; 62a3e0fd82Sopenharmony_ci } 63a3e0fd82Sopenharmony_ci EXPECT_EQ(event_->GetCurrentPos().x, INIT_POS.x); 64a3e0fd82Sopenharmony_ci EXPECT_EQ(event_->GetCurrentPos().y, INIT_POS.y); 65a3e0fd82Sopenharmony_ci} 66a3e0fd82Sopenharmony_ci 67a3e0fd82Sopenharmony_ci/** 68a3e0fd82Sopenharmony_ci * @tc.name: EventSetTimeStamp_001 69a3e0fd82Sopenharmony_ci * @tc.desc: Verify SetTimeStamp function, equal. 70a3e0fd82Sopenharmony_ci * @tc.type: FUNC 71a3e0fd82Sopenharmony_ci * @tc.require: SR000DRSH4 72a3e0fd82Sopenharmony_ci */ 73a3e0fd82Sopenharmony_ciHWTEST_F(EventTest, EventSetTimeStamp_001, TestSize.Level0) 74a3e0fd82Sopenharmony_ci{ 75a3e0fd82Sopenharmony_ci if (event_ == nullptr) { 76a3e0fd82Sopenharmony_ci EXPECT_EQ(1, 0); 77a3e0fd82Sopenharmony_ci return; 78a3e0fd82Sopenharmony_ci } 79a3e0fd82Sopenharmony_ci event_->SetTimeStamp(TIME_STAMP); 80a3e0fd82Sopenharmony_ci EXPECT_EQ(event_->GetTimeStamp(), TIME_STAMP); 81a3e0fd82Sopenharmony_ci} 82a3e0fd82Sopenharmony_ci} // namespace OHOS 83