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