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