1 /*
2 * Copyright (c) 2025 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 "pasteboard_common.h"
19
20 namespace OHOS::MiscServices {
21 using namespace testing::ext;
22
23 class PasteboardCommonTest : public testing::Test {
24 public:
25 static void SetUpTestCase(void);
26 static void TearDownTestCase(void);
27 void SetUp();
28 void TearDown();
29 };
30
SetUpTestCase(void)31 void PasteboardCommonTest::SetUpTestCase(void) { }
32
TearDownTestCase(void)33 void PasteboardCommonTest::TearDownTestCase(void) { }
34
SetUp(void)35 void PasteboardCommonTest::SetUp(void) { }
36
TearDown(void)37 void PasteboardCommonTest::TearDown(void) { }
38
39 /**
40 * @tc.name: IsPasteboardService
41 * @tc.desc: Check whether this process is pasteboard service or not.
42 * @tc.type: FUNC
43 */
44 HWTEST_F(PasteboardCommonTest, IsPasteboardService, TestSize.Level0)
45 {
46 auto result = PasteBoardCommon::GetInstance().IsPasteboardService();
47 EXPECT_FALSE(result);
48 }
49
50 /**
51 * @tc.name: GetAppBundleManager
52 * @tc.desc: Get app bundle manager.
53 * @tc.type: FUNC
54 */
55 HWTEST_F(PasteboardCommonTest, GetAppBundleManager, TestSize.Level0)
56 {
57 auto result = PasteBoardCommon::GetInstance().GetAppBundleManager();
58 EXPECT_TRUE(result != nullptr);
59 }
60
61 /**
62 * @tc.name: GetApiTargetVersionForSelf
63 * @tc.desc: Get api target version for this process.
64 * @tc.type: FUNC
65 */
66 HWTEST_F(PasteboardCommonTest, GetApiTargetVersionForSelf, TestSize.Level0)
67 {
68 auto result = PasteBoardCommon::GetInstance().GetApiTargetVersionForSelf();
69 EXPECT_TRUE(result >= 0);
70 }
71
72 /**
73 * @tc.name: GetAnonymousStringTest001
74 * @tc.desc: GetAnonymousString.
75 * @tc.type: FUNC
76 * @tc.require:
77 * @tc.author:
78 */
79 HWTEST_F(PasteboardCommonTest, GetAnonymousStringTest001, TestSize.Level0)
80 {
81 std::string testStr = "anon";
82 std::string resultStr = PasteBoardCommon::GetAnonymousString(testStr);
83 EXPECT_EQ(resultStr, testStr);
84 testStr = "anon123456789";
85 resultStr = PasteBoardCommon::GetAnonymousString(testStr);
86 std::string anonStr = "anon**6789";
87 EXPECT_EQ(resultStr, anonStr);
88 }
89 } // namespace OHOS::MiscServices
90