1 /*
2 * Copyright (c) 2023 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 #include <gtest/gtest.h>
16 #include <vector>
17
18 #include "driver_ext_mgr_client.h"
19 #include "hilog_wrapper.h"
20
21
22 namespace OHOS {
23 namespace ExternalDeviceManager {
24 using namespace testing::ext;
25 class EmitEventTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
SetUp()29 void SetUp() override {};
TearDown()30 void TearDown() override {};
31
32 static DriverExtMgrClient &edmClient;
33 };
34
35 DriverExtMgrClient &EmitEventTest::edmClient = DriverExtMgrClient::GetInstance();
36
SetUpTestCase()37 void EmitEventTest::SetUpTestCase()
38 {
39 auto ret = edmClient.CreateDevice(100, 100, 100);
40 ASSERT_GE(ret, 0);
41 }
42
TearDownTestCase()43 void EmitEventTest::TearDownTestCase()
44 {
45 int32_t ret = edmClient.DestroyDevice();
46 ASSERT_EQ(ret, 0);
47 }
48
49 HWTEST_F(EmitEventTest, EmitEvent001, TestSize.Level1)
50 {
51 std::vector<EmitItem> items({
52 {0, 1, 0x14a, 108},
53 {0, 3, 0, 50 },
54 {0, 3, 1, 50 },
55 {0, 0, 0, 0 }
56 });
57 auto ret = edmClient.EmitEvent(0, items);
58 ASSERT_EQ(ret, 0);
59 }
60
61 HWTEST_F(EmitEventTest, EmitEvent002, TestSize.Level1)
62 {
63 std::vector<EmitItem> items(21, {0, 1, 0x14a, 108});
64 auto ret = edmClient.EmitEvent(0, items);
65 ASSERT_NE(ret, 0);
66 }
67
68 HWTEST_F(EmitEventTest, EmitEvent003, TestSize.Level1)
69 {
70 std::vector<EmitItem> items(20, {0, 1, 0x14a, 108});
71 auto ret = edmClient.EmitEvent(0, items);
72 ASSERT_EQ(ret, 0);
73 }
74 } // namespace ExternalDeviceManager
75 } // namespace OHOS