1 /* 2 * Copyright (c) 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 <functional> 17 #include <gtest/gtest.h> 18 #define private public 19 #define protected public 20 #include "advanced_notification_service_ability.h" 21 22 using namespace testing::ext; 23 24 namespace OHOS { 25 namespace Notification { 26 const int ANS_CLONE_ERROR = -1; 27 class AdvancedNotificationServiceAbilityTest : public testing::Test { 28 public: SetUpTestCase()29 static void SetUpTestCase() {}; TearDownTestCase()30 static void TearDownTestCase() {}; SetUp()31 void SetUp() {}; TearDown()32 void TearDown() {}; 33 }; 34 35 /** 36 * @tc.number : AdvancedNotificationServiceAbilityTest_00100 37 * @tc.name : ANS_AdvancedNotificationServiceAbility_0100 38 * @tc.desc : Structure AdvancedNotificationServiceAbility with systemAbilityId and runOnCreate 39 */ 40 HWTEST_F( 41 AdvancedNotificationServiceAbilityTest, AdvancedNotificationServiceAbilityTest_00100, Function | SmallTest | Level1) 42 { 43 int32_t systemAbilityId = 1; 44 bool runOnCreate = true; 45 AdvancedNotificationServiceAbility(systemAbilityId, runOnCreate); 46 } 47 48 /** 49 * @tc.number : AdvancedNotificationServiceAbilityTest_00200 50 * @tc.name : ANS_AdvancedNotificationServiceAbility_0200 51 * @tc.desc : Structure AdvancedNotificationServiceAbility with systemAbilityId and runOnCreate 52 */ 53 HWTEST_F( 54 AdvancedNotificationServiceAbilityTest, AdvancedNotificationServiceAbilityTest_00200, Function | SmallTest | Level1) 55 { 56 int32_t systemAbilityId = 1; 57 bool runOnCreate = true; 58 AdvancedNotificationServiceAbility test(systemAbilityId, runOnCreate); 59 test.OnStart(); 60 } 61 62 /** 63 * @tc.number : AdvancedNotificationServiceAbilityTest_00300 64 * @tc.name : ANS_AdvancedNotificationServiceAbility_0300 65 * @tc.desc : Structure AdvancedNotificationServiceAbility with systemAbilityId and runOnCreate 66 */ 67 HWTEST_F( 68 AdvancedNotificationServiceAbilityTest, AdvancedNotificationServiceAbilityTest_00300, Function | SmallTest | Level1) 69 { 70 int32_t systemAbilityId = 1; 71 bool runOnCreate = true; 72 AdvancedNotificationServiceAbility test(systemAbilityId, runOnCreate); 73 test.OnStop(); 74 test.OnStart(); 75 } 76 77 /** 78 * @tc.number : AdvancedNotificationServiceAbilityTest_00400 79 * @tc.name : ANS_AdvancedNotificationServiceAbility_0400 80 * @tc.desc : Structure AdvancedNotificationServiceAbility with systemAbilityId and runOnCreate 81 */ 82 HWTEST_F( 83 AdvancedNotificationServiceAbilityTest, AdvancedNotificationServiceAbilityTest_00400, Function | SmallTest | Level1) 84 { 85 int32_t systemAbilityId = 1; 86 bool runOnCreate = true; 87 std::string extension = "backup"; 88 MessageParcel data; 89 MessageParcel reply; 90 AdvancedNotificationServiceAbility test(systemAbilityId, runOnCreate); 91 ErrCode ret = test.OnExtension(extension, data, reply); 92 EXPECT_EQ(ret, (int)ERR_OK); 93 } 94 95 /** 96 * @tc.number : AdvancedNotificationServiceAbilityTest_00500 97 * @tc.name : ANS_AdvancedNotificationServiceAbility_0500 98 * @tc.desc : Structure AdvancedNotificationServiceAbility with systemAbilityId and runOnCreate 99 */ 100 HWTEST_F( 101 AdvancedNotificationServiceAbilityTest, AdvancedNotificationServiceAbilityTest_00500, Function | SmallTest | Level1) 102 { 103 int32_t systemAbilityId = 1; 104 bool runOnCreate = true; 105 std::string extension = "restore"; 106 MessageParcel data; 107 MessageParcel reply; 108 AdvancedNotificationServiceAbility test(systemAbilityId, runOnCreate); 109 ErrCode ret = test.OnExtension(extension, data, reply); 110 EXPECT_EQ(ret, (int)ANS_CLONE_ERROR); 111 } 112 } // namespace Notification 113 } // namespace OHOS 114