• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <gtest/gtest.h>
16 
17 #include "clipboard_info.h"
18 #include "clipboard_utils.h"
19 #include "utils.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace EDM {
25 namespace TEST {
26 class ClipboardUtilsTest : public testing::Test {
27 protected:
28     static void SetUpTestSuite(void);
29 
30     static void TearDownTestSuite(void);
31 };
32 
SetUpTestSuite(void)33 void ClipboardUtilsTest::SetUpTestSuite(void)
34 {
35     Utils::SetEdmInitialEnv();
36 }
37 
TearDownTestSuite(void)38 void ClipboardUtilsTest::TearDownTestSuite(void)
39 {
40     Utils::ResetTokenTypeAndUid();
41     ASSERT_TRUE(Utils::IsOriginalUTEnv());
42     std::cout << "now ut process is orignal ut env : " << Utils::IsOriginalUTEnv() << std::endl;
43 }
44 
45 /**
46  * @tc.name: HandlePasteboardPolicy
47  * @tc.desc: Test ClipboardUtils::HandlePasteboardPolicy when jsonString is empty
48  * @tc.type: FUNC
49  */
50 HWTEST_F(ClipboardUtilsTest, TestHandlePasteboardPolicy, TestSize.Level1)
51 {
52     std::map<int32_t, ClipboardInfo> result;
53     ClipboardInfo info1 = {ClipboardPolicy::DEFAULT, -1, ""};
54     ClipboardInfo info2 = {ClipboardPolicy::IN_APP, -1, ""};
55     ClipboardInfo info3 = {ClipboardPolicy::LOCAL_DEVICE, -1, ""};
56     ClipboardInfo info4 = {ClipboardPolicy::CROSS_DEVICE, -1, ""};
57     result.insert(std::make_pair(1, info1));
58     result.insert(std::make_pair(2, info2));
59     result.insert(std::make_pair(3, info3));
60     result.insert(std::make_pair(4, info4));
61     ErrCode ret = ClipboardUtils::HandlePasteboardPolicy(result);
62     ASSERT_TRUE(ret == ERR_OK);
63 }
64 } // namespace TEST
65 } // namespace EDM
66 } // namespace OHOS