• 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 
16 #include <gtest/gtest.h>
17 #include <string>
18 #include "ipolicy_manager.h"
19 
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace EDM {
24 namespace TEST {
25 const std::string TEST_ADMIN_NAME = "com.edm.test.demo";
26 const std::string TEST_ADMIN_NAME1 = "com.edm.test.demo1";
27 const std::string TEST_STRING_POLICY_NAME = "testStringPolicy";
28 class IPolicyManagerTest : public testing::Test {};
29 
30 /**
31  * @tc.name: TestGetPolicy
32  * @tc.desc: Test TestGetPolicy func.
33  * @tc.type: FUNC
34  */
35 HWTEST_F(IPolicyManagerTest, TestGetPolicy, TestSize.Level1)
36 {
37     ErrCode res;
38     auto policyManager = IPolicyManager::GetInstance();
39     std::string policyValue = "";
40     res = policyManager->GetPolicy(TEST_ADMIN_NAME, TEST_STRING_POLICY_NAME, policyValue);
41     ASSERT_TRUE(res == ERR_OK);
42     ASSERT_TRUE(policyValue.empty());
43     res = policyManager->GetPolicy("", TEST_STRING_POLICY_NAME, policyValue);
44     ASSERT_TRUE(res == ERR_OK);
45     ASSERT_TRUE(policyValue.empty());
46 
47     res = policyManager->GetPolicy(TEST_ADMIN_NAME1, TEST_STRING_POLICY_NAME, policyValue);
48     ASSERT_TRUE(res == ERR_OK);
49     ASSERT_TRUE(policyValue.empty());
50     res = policyManager->GetPolicy("", TEST_STRING_POLICY_NAME, policyValue);
51     ASSERT_TRUE(res == ERR_OK);
52     ASSERT_TRUE(policyValue.empty());
53 }
54 } // namespace TEST
55 } // namespace EDM
56 } // namespace OHOS