1 /* 2 * Copyright (c) 2024 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 <gtest/gtest.h> 17 18 #include "authorization_dialog.h" 19 #include "inject_notice_manager.h" 20 #include "message_option.h" 21 #include "mmi_log.h" 22 23 #undef MMI_LOG_TAG 24 #define MMI_LOG_TAG "InjectNoticeManagerTest" 25 26 namespace OHOS { 27 namespace MMI { 28 namespace { 29 using namespace testing::ext; 30 } // namespace 31 32 class InjectNoticeManagerTest : public testing::Test { 33 public: SetUpTestCase(void)34 static void SetUpTestCase(void) {} TearDownTestCase(void)35 static void TearDownTestCase(void) {} SetUp()36 void SetUp() {} TearDown()37 void TearDown() {} 38 }; 39 40 class AuthorizationDialogTest : public testing::Test { 41 public: SetUpTestCase(void)42 static void SetUpTestCase(void) {} TearDownTestCase(void)43 static void TearDownTestCase(void) {} SetUp()44 void SetUp() {} TearDown()45 void TearDown() {} 46 }; 47 48 /** 49 * @tc.name: InjectNoticeManagerTest_StartNoticeAbility 50 * @tc.desc: Test StartNoticeAbility 51 * @tc.type: FUNC 52 * @tc.require: 53 */ 54 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_StartNoticeAbility, TestSize.Level1) 55 { 56 CALL_TEST_DEBUG; 57 InjectNoticeManager injectNoticeMgr; 58 injectNoticeMgr.isStartSrv_ = true; 59 EXPECT_TRUE(injectNoticeMgr.StartNoticeAbility()); 60 } 61 62 /** 63 * @tc.name: InjectNoticeManagerTest_StartNoticeAbility_001 64 * @tc.desc: Test StartNoticeAbility 65 * @tc.type: FUNC 66 * @tc.require: 67 */ 68 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_StartNoticeAbility_001, TestSize.Level1) 69 { 70 CALL_TEST_DEBUG; 71 InjectNoticeManager injectNoticeMgr; 72 injectNoticeMgr.isStartSrv_ = false; 73 EXPECT_FALSE(injectNoticeMgr.StartNoticeAbility()); 74 } 75 76 /** 77 * @tc.name: InjectNoticeManagerTest_ConnectNoticeSrv 78 * @tc.desc: Test ConnectNoticeSrv 79 * @tc.type: FUNC 80 * @tc.require: 81 */ 82 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_ConnectNoticeSrv, TestSize.Level1) 83 { 84 CALL_TEST_DEBUG; 85 InjectNoticeManager injectNoticeMgr; 86 injectNoticeMgr.connectionCallback_ = new (std::nothrow) InjectNoticeManager::InjectNoticeConnection; 87 ASSERT_NE(injectNoticeMgr.connectionCallback_, nullptr); 88 injectNoticeMgr.connectionCallback_->isConnected_ = true; 89 EXPECT_TRUE(injectNoticeMgr.ConnectNoticeSrv()); 90 injectNoticeMgr.connectionCallback_->isConnected_ = false; 91 EXPECT_FALSE(injectNoticeMgr.ConnectNoticeSrv()); 92 } 93 } // namespace MMI 94 } // namespace OHOS