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_ability_wrapper_test.h"
17
18 #include <cstring>
19 #include <gtest/gtest.h>
20
21 #include "system_ability_wrapper.h"
22 #include "system_event_wrapper.h"
23
24 using namespace testing::ext;
25 namespace UnitTest::AssetSystemAbilityWrapperTest {
26 class AssetSystemAbilityWrapperTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29
30 static void TearDownTestCase(void);
31
32 void SetUp(void);
33
34 void TearDown(void);
35 };
36
SetUpTestCase(void)37 void AssetSystemAbilityWrapperTest::SetUpTestCase(void)
38 {
39 }
40
TearDownTestCase(void)41 void AssetSystemAbilityWrapperTest::TearDownTestCase(void)
42 {
43 }
44
SetUp(void)45 void AssetSystemAbilityWrapperTest::SetUp(void)
46 {
47 }
48
TearDown(void)49 void AssetSystemAbilityWrapperTest::TearDown(void)
50 {
51 }
52
PackageRemovedCallback(int32_t packageId,const uint8_t * owner,uint32_t ownerSize,const uint8_t * bundleName,int32_t appIndex)53 void PackageRemovedCallback(int32_t packageId, const uint8_t *owner, uint32_t ownerSize,
54 const uint8_t *bundleName, int32_t appIndex)
55 {
56 }
57
OnUserRemovedCallback(int32_t userId)58 void OnUserRemovedCallback(int32_t userId)
59 {
60 }
61
OnScreenOffCallback(void)62 void OnScreenOffCallback(void)
63 {
64 }
65
OnChargingCallback(void)66 void OnChargingCallback(void)
67 {
68 }
69
OnAppRestore(int32_t packageId,const uint8_t * owner,int32_t appIndex)70 void OnAppRestore(int32_t packageId, const uint8_t *owner, int32_t appIndex)
71 {
72 }
73
OnUserUnlocked(int32_t userId)74 void OnUserUnlocked(int32_t userId)
75 {
76 }
77
78 /**
79 * @tc.name: AssetSystemAbilityWrapperTest.AssetSystemAbilityWrapperTest001
80 * @tc.desc: Test asset func SubscribeSystemEvent, expect ACCESS_TOKEN_ERROR
81 * @tc.type: FUNC
82 * @tc.result:0
83 */
84 HWTEST_F(AssetSystemAbilityWrapperTest, AssetSystemAbilityWrapperTest001, TestSize.Level0)
85 {
86 EventCallBack call_back = {
87 PackageRemovedCallback,
88 OnUserRemovedCallback,
89 OnScreenOffCallback,
90 OnChargingCallback,
91 OnAppRestore,
92 OnUserUnlocked
93 };
94 ASSERT_EQ(true, SubscribeSystemEvent(call_back));
95 }
96
97 /**
98 * @tc.name: AssetSystemAbilityWrapperTest.AssetSystemAbilityWrapperTest002
99 * @tc.desc: Test asset func UnSubscribeSystemEvent, expect BMS_ERROR
100 * @tc.type: FUNC
101 * @tc.result:0
102 */
103 HWTEST_F(AssetSystemAbilityWrapperTest, AssetSystemAbilityWrapperTest002, TestSize.Level0)
104 {
105 ASSERT_EQ(true, UnSubscribeSystemEvent());
106 }
107 }