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 #include <thread> 16 #include <gtest/gtest.h> 17 #include "iservice_registry.h" 18 #include "pasteboard_dialog.h" 19 #include "pasteboard_error.h" 20 21 using namespace OHOS; 22 GetSystemAbilityManager()23sptr<ISystemAbilityManager> OHOS::SystemAbilityManagerClient::GetSystemAbilityManager() 24 { 25 return nullptr; 26 } 27 28 namespace OHOS::MiscServices { 29 using namespace testing::ext; 30 class PasteboardDialogAbnormalBranchTest : public testing::Test { 31 public: 32 static void SetUpTestCase(void); 33 static void TearDownTestCase(void); 34 void SetUp(); 35 void TearDown(); 36 }; 37 SetUpTestCase(void)38void PasteboardDialogAbnormalBranchTest::SetUpTestCase(void) 39 { 40 } 41 TearDownTestCase(void)42void PasteboardDialogAbnormalBranchTest::TearDownTestCase(void) 43 { 44 } 45 SetUp(void)46void PasteboardDialogAbnormalBranchTest::SetUp(void) 47 { 48 } 49 TearDown(void)50void PasteboardDialogAbnormalBranchTest::TearDown(void) 51 { 52 } 53 54 /** 55 * @tc.name: ShowToastAbnormalTest 56 * @tc.desc: Show Toast test abnormal branch. 57 * @tc.type: FUNC 58 */ 59 HWTEST_F(PasteboardDialogAbnormalBranchTest, ShowToastAbnormalTest, TestSize.Level0) 60 { 61 PasteBoardDialog::ToastMessageInfo message; 62 message.appName = "myAppName"; 63 int32_t ret = PasteBoardDialog::GetInstance().ShowToast(message); 64 EXPECT_TRUE(ret == static_cast<int32_t>(PasteboardError::OBTAIN_SERVER_SA_ERROR)); 65 } 66 67 /** 68 * @tc.name: CancelToastAbnormalTest 69 * @tc.desc: Cancel Toast test abnormal branch. 70 * @tc.type: FUNC 71 */ 72 HWTEST_F(PasteboardDialogAbnormalBranchTest, CancelToastAbnormalTest, TestSize.Level0) 73 { 74 PasteBoardDialog::GetInstance().CancelToast(); 75 EXPECT_TRUE(true); 76 } 77 }