1 /* 2 * Copyright (c) 2022-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 16 #include <gtest/gtest.h> 17 #include <string> 18 #include <vector> 19 #include "edm_permission.h" 20 #include "func_code.h" 21 #include "message_parcel.h" 22 23 using namespace testing::ext; 24 using namespace testing; 25 26 namespace OHOS { 27 namespace EDM { 28 namespace TEST { 29 class EdmPermissionTest : public testing::Test { 30 protected: SetUp()31 void SetUp() override {} 32 TearDown()33 void TearDown() override {} 34 }; 35 36 /** 37 * @tc.name: TestEdmPermissionEqual 38 * @tc.desc: Test EdmPermission Equal func. 39 * @tc.type: FUNC 40 */ 41 HWTEST_F(EdmPermissionTest, TestEdmPermissionEqual, TestSize.Level1) 42 { 43 EdmPermission permission1; 44 EdmPermission permission2; 45 permission1.setAdminType(AdminType::NORMAL); 46 permission1.setPermissionName("ohos.permission.EDM_TEST_PERMISSION"); 47 permission2.setAdminType(AdminType::NORMAL); 48 permission2.setPermissionName("ohos.permission.EDM_TEST_PERMISSION"); 49 EXPECT_TRUE(permission1 == permission2); 50 permission2.setPermissionName("ohos.permission.EDM_TEST_PERMISSION_FAIL"); 51 EXPECT_FALSE(permission1 == permission2); 52 } 53 54 /** 55 * @tc.name: TestMarshalling 56 * @tc.desc: Test Marshalling func. 57 * @tc.type: FUNC 58 */ 59 HWTEST_F(EdmPermissionTest, TestMarshalling, TestSize.Level1) 60 { 61 EdmPermission permission1("ohos.permission.EDM_TEST_PERMISSION", AdminType::NORMAL); 62 MessageParcel parcel; 63 permission1.Marshalling(parcel); 64 EdmPermission permission2; 65 EXPECT_TRUE(EdmPermission::Unmarshalling(parcel, permission2)); 66 EXPECT_TRUE(permission1 == permission2); 67 } 68 } // namespace TEST 69 } // namespace EDM 70 } // namespace OHOS