1 /* 2 * Copyright (c) 2021-2022 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 #define private public 19 #define protected public 20 #include "extra_params.h" 21 #undef private 22 #undef protected 23 24 using namespace testing::ext; 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 class ExtraParamsBaseTest : public testing::Test { 29 public: SetUpTestCase()30 static void SetUpTestCase() {}; TearDownTestCase()31 static void TearDownTestCase() {}; SetUp()32 void SetUp() {}; TearDown()33 void TearDown() {}; 34 }; 35 36 /** 37 * @tc.number: AppExecFwk_ExtraParams_SetDevType_0100 38 * @tc.name: SetDevType 39 * @tc.desc: 40 */ 41 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_SetDevType_0100, Function | MediumTest | Level1) 42 { 43 std::vector<string> devType; 44 ExtraParams extraParams; 45 extraParams.SetDevType(devType); 46 std::vector<string> result = extraParams.GetDevType(); 47 EXPECT_EQ(result, devType); 48 } 49 50 /** 51 * @tc.number: AppExecFwk_ExtraParams_SetTargetBundleName_0100 52 * @tc.name: SetTargetBundleName 53 * @tc.desc: 54 */ 55 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_SetTargetBundleName_0100, Function | MediumTest | Level1) 56 { 57 string targetBundleName; 58 ExtraParams extraParams; 59 extraParams.SetTargetBundleName(targetBundleName); 60 string result = extraParams.GetTargetBundleName(); 61 EXPECT_EQ(result, targetBundleName); 62 } 63 64 /** 65 * @tc.number: AppExecFwk_ExtraParams_SetJsonParams_0100 66 * @tc.name: SetJsonParams 67 * @tc.desc: 68 */ 69 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_SetJsonParams_0100, Function | MediumTest | Level1) 70 { 71 string jsonParams; 72 ExtraParams extraParams; 73 extraParams.SetJsonParams(jsonParams); 74 string result = extraParams.GetJsonParams(); 75 EXPECT_EQ(result, jsonParams); 76 } 77 78 /** 79 * @tc.number: AppExecFwk_ExtraParams_SetDescription_0100 80 * @tc.name: SetDescription 81 * @tc.desc: 82 */ 83 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_SetDescription_0100, Function | MediumTest | Level1) 84 { 85 string description; 86 ExtraParams extraParams; 87 extraParams.SetDescription(description); 88 string result = extraParams.GetDescription(); 89 EXPECT_EQ(result, description); 90 } 91 92 /** 93 * @tc.number: AppExecFwk_ExtraParams_Marshallin_0100 94 * @tc.name: Marshallin 95 * @tc.desc: 96 */ 97 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_Marshallin_0100, Function | MediumTest | Level1) 98 { 99 ExtraParams extraParams; 100 std::vector<string> devType; 101 extraParams.SetDevType(devType); 102 string targetBundleName; 103 extraParams.SetTargetBundleName(targetBundleName); 104 string jsonParams; 105 extraParams.SetJsonParams(jsonParams); 106 string description; 107 extraParams.SetDescription(description); 108 Parcel parcel; 109 bool result = extraParams.Marshalling(parcel); 110 EXPECT_EQ(result, true); 111 } 112 113 /** 114 * @tc.number: AppExecFwk_ExtraParams_Unmarshalling_0100 115 * @tc.name: Unmarshalling 116 * @tc.desc: Test Unmarshalling. 117 * @tc.require: issueI653GZ 118 */ 119 HWTEST_F(ExtraParamsBaseTest, AppExecFwk_ExtraParams_Unmarshalling_0100, Function | MediumTest | Level1) 120 { 121 ExtraParams other; 122 ExtraParams oextraParams(other); 123 oextraParams.GetTargetBundleName(); 124 std::vector<string> devType; 125 string targetBundleName = "TargetBundleName"; 126 string description = "Description"; 127 string jsonParams; 128 ExtraParams extraParams(devType, targetBundleName, description, jsonParams); 129 Parcel parcel; 130 extraParams.Unmarshalling(parcel); 131 string result = extraParams.GetTargetBundleName(); 132 EXPECT_EQ(result, targetBundleName); 133 } 134 } 135 } 136