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: AuthorizationDialogTest_ConnectSystemUi 50 * @tc.desc: Test ConnectSystemUi 51 * @tc.type: FUNC 52 * @tc.require: 53 */ 54 HWTEST_F(AuthorizationDialogTest, AuthorizationDialogTest_ConnectSystemUi, TestSize.Level1) 55 { 56 CALL_TEST_DEBUG; 57 AuthorizationDialog dialog; 58 dialog.dialogConnectionCallback_ = new AuthorizationDialog::DialogAbilityConnection(); 59 EXPECT_FALSE(dialog.ConnectSystemUi()); 60 } 61 62 /** 63 * @tc.name: InjectNoticeManagerTest_StartNoticeAbility 64 * @tc.desc: Test StartNoticeAbility 65 * @tc.type: FUNC 66 * @tc.require: 67 */ 68 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_StartNoticeAbility, TestSize.Level1) 69 { 70 CALL_TEST_DEBUG; 71 InjectNoticeManager injectNoticeMgr; 72 injectNoticeMgr.isStartSrv_ = true; 73 EXPECT_TRUE(injectNoticeMgr.StartNoticeAbility()); 74 } 75 76 /** 77 * @tc.name: InjectNoticeManagerTest_StartNoticeAbility_001 78 * @tc.desc: Test StartNoticeAbility 79 * @tc.type: FUNC 80 * @tc.require: 81 */ 82 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_StartNoticeAbility_001, TestSize.Level1) 83 { 84 CALL_TEST_DEBUG; 85 InjectNoticeManager injectNoticeMgr; 86 injectNoticeMgr.isStartSrv_ = false; 87 EXPECT_FALSE(injectNoticeMgr.StartNoticeAbility()); 88 } 89 90 /** 91 * @tc.name: InjectNoticeManagerTest_ConnectNoticeSrv 92 * @tc.desc: Test ConnectNoticeSrv 93 * @tc.type: FUNC 94 * @tc.require: 95 */ 96 HWTEST_F(InjectNoticeManagerTest, InjectNoticeManagerTest_ConnectNoticeSrv, TestSize.Level1) 97 { 98 CALL_TEST_DEBUG; 99 InjectNoticeManager injectNoticeMgr; 100 injectNoticeMgr.connectionCallback_ = new (std::nothrow) InjectNoticeManager::InjectNoticeConnection; 101 ASSERT_NE(injectNoticeMgr.connectionCallback_, nullptr); 102 injectNoticeMgr.connectionCallback_->isConnected_ = true; 103 EXPECT_TRUE(injectNoticeMgr.ConnectNoticeSrv()); 104 injectNoticeMgr.connectionCallback_->isConnected_ = false; 105 EXPECT_FALSE(injectNoticeMgr.ConnectNoticeSrv()); 106 } 107 } // namespace MMI 108 } // namespace OHOS