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
16 #include "system_event_wrapper_test.h"
17
18 #include <cstring>
19 #include <gtest/gtest.h>
20
21 #include "system_event_wrapper.h"
22
23 using namespace testing::ext;
24 namespace UnitTest::AssetSystemEventWrapperTest {
25 class AssetSystemEventWrapperTest : public testing::Test {
26 public:
27 static void SetUpTestCase(void);
28
29 static void TearDownTestCase(void);
30
31 void SetUp(void);
32
33 void TearDown(void);
34 };
35
SetUpTestCase(void)36 void AssetSystemEventWrapperTest::SetUpTestCase(void)
37 {
38 }
39
TearDownTestCase(void)40 void AssetSystemEventWrapperTest::TearDownTestCase(void)
41 {
42 }
43
SetUp(void)44 void AssetSystemEventWrapperTest::SetUp(void)
45 {
46 }
47
TearDown(void)48 void AssetSystemEventWrapperTest::TearDown(void)
49 {
50 }
51
PackageRemovedCallback(int32_t packageId,const uint8_t * owner,uint32_t ownerSize)52 void PackageRemovedCallback(int32_t packageId, const uint8_t *owner, uint32_t ownerSize)
53 {
54 }
55
OnUserRemovedCallback(int32_t userId)56 void OnUserRemovedCallback(int32_t userId)
57 {
58 }
59
OnScreenOffCallback(void)60 void OnScreenOffCallback(void)
61 {
62 }
63
64 /**
65 * @tc.name: AssetSystemEventWrapperTest.AssetSystemEventWrapperTest001
66 * @tc.desc: Test asset func SubscribeSystemEvent, expect ACCESS_TOKEN_ERROR
67 * @tc.type: FUNC
68 * @tc.result:0
69 */
70 HWTEST_F(AssetSystemEventWrapperTest, AssetSystemEventWrapperTest001, TestSize.Level0)
71 {
72 OnPackageRemoved onPackageRemovedPtr = &PackageRemovedCallback;
73 OnUserRemoved onUserRemovedPtr = &OnUserRemovedCallback;
74 OnScreenOff onScreenOffPtr = &OnScreenOffCallback;
75 ASSERT_EQ(true, SubscribeSystemEvent(onPackageRemovedPtr, onUserRemovedPtr, onScreenOffPtr));
76 }
77
78 /**
79 * @tc.name: AssetSystemEventWrapperTest.AssetSystemEventWrapperTest002
80 * @tc.desc: Test asset func UnSubscribeSystemEvent, expect BMS_ERROR
81 * @tc.type: FUNC
82 * @tc.result:0
83 */
84 HWTEST_F(AssetSystemEventWrapperTest, AssetSystemEventWrapperTest002, TestSize.Level0)
85 {
86 ASSERT_EQ(true, UnSubscribeSystemEvent());
87 }
88 }