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 "array_wrapper.h" 21#undef private 22#undef protected 23 24using namespace testing::ext; 25 26namespace OHOS { 27namespace AAFwk { 28class ArrayWrapperBaseTest : public testing::Test { 29public: 30 static void SetUpTestCase() {}; 31 static void TearDownTestCase() {}; 32 void SetUp() {}; 33 void TearDown() {}; 34}; 35 36/** 37 * @tc.number: AaFwk_Array_Wrapper_Get_0100 38 * @tc.name: Get 39 * @tc.desc: 40 */ 41HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_Get_0100, Function | MediumTest | Level1) 42{ 43 long index = 5; 44 InterfaceID typeId; 45 sptr<IArray> arr = new Array(index, typeId); 46 sptr<IInterface> value; 47 ErrCode result = arr->Get(index, value); 48 EXPECT_EQ(result, ERR_INVALID_VALUE); 49} 50 51/** 52 * @tc.number: AaFwk_Array_Wrapper_Get_0200 53 * @tc.name: Get 54 * @tc.desc: 55 */ 56HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_Get_0200, Function | MediumTest | Level1) 57{ 58 long index = 5; 59 InterfaceID typeId; 60 sptr<IArray> arr = new Array(index, typeId); 61 sptr<IInterface> value; 62 long key = 1; 63 ErrCode result = arr->Get(key, value); 64 EXPECT_EQ(result, ERR_OK); 65} 66 67/** 68 * @tc.number: AaFwk_Array_Wrapper_GetLength_0100 69 * @tc.name: GetLength 70 * @tc.desc: 71 */ 72HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_GetLength_0100, Function | MediumTest | Level1) 73{ 74 long size = 1; 75 InterfaceID typeId; 76 sptr<IArray> arr = new Array(size, typeId); 77 ErrCode result = arr->GetLength(size); 78 EXPECT_EQ(result, ERR_OK); 79} 80 81/** 82 * @tc.number: AaFwk_Array_Wrapper_GetType_0100 83 * @tc.name: GetType 84 * @tc.desc: 85 */ 86HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_GetType_0100, Function | MediumTest | Level1) 87{ 88 long size = 1; 89 InterfaceID typeId = g_IID_IString; 90 sptr<IArray> arr = new Array(size, typeId); 91 ErrCode result = arr->GetType(typeId); 92 EXPECT_EQ(result, ERR_OK); 93} 94 95/** 96 * @tc.number: AaFwk_Array_Wrapper_Set_0100 97 * @tc.name: Set 98 * @tc.desc: 99 */ 100HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_Set_0100, Function | MediumTest | Level1) 101{ 102 long index = 5; 103 InterfaceID typeId; 104 sptr<IArray> arr = new Array(index, typeId); 105 sptr<IInterface> value; 106 long key = 1; 107 ErrCode result = arr->Set(key, value); 108 EXPECT_EQ(result, ERR_OK); 109} 110 111/** 112 * @tc.number: AaFwk_Array_Wrapper_Set_0200 113 * @tc.name: Set 114 * @tc.desc: 115 */ 116HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_Set_0200, Function | MediumTest | Level1) 117{ 118 long index = 5; 119 InterfaceID typeId; 120 sptr<IArray> arr = new Array(index, typeId); 121 sptr<IInterface> value; 122 long key = -1; 123 ErrCode result = arr->Set(key, value); 124 EXPECT_EQ(result, ERR_INVALID_VALUE); 125} 126 127/** 128 * @tc.number: AaFwk_Array_Wrapper_IsBooleanArray_0100 129 * @tc.name: IsBooleanArray 130 * @tc.desc: 131 */ 132HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsBooleanArray_0100, Function | MediumTest | Level1) 133{ 134 long index = 5; 135 InterfaceID typeId; 136 sptr<IArray> arr = new Array(index, typeId); 137 bool result = Array::IsBooleanArray(arr); 138 EXPECT_EQ(result, false); 139} 140 141/** 142 * @tc.number: AaFwk_Array_Wrapper_IsBooleanArray_0200 143 * @tc.name: IsBooleanArray 144 * @tc.desc: 145 */ 146HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsBooleanArray_0200, Function | MediumTest | Level1) 147{ 148 long index = 5; 149 InterfaceID typeId = g_IID_IBoolean; 150 sptr<IArray> arr = new Array(index, typeId); 151 bool result = Array::IsBooleanArray(arr); 152 EXPECT_EQ(result, true); 153} 154 155/** 156 * @tc.number: AaFwk_Array_Wrapper_IsCharArray_0100 157 * @tc.name: IsCharArray 158 * @tc.desc: 159 */ 160HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsCharArray_0100, Function | MediumTest | Level1) 161{ 162 long index = 5; 163 InterfaceID typeId; 164 sptr<IArray> arr = new Array(index, typeId); 165 bool result = Array::IsCharArray(arr); 166 EXPECT_EQ(result, false); 167} 168 169/** 170 * @tc.number: AaFwk_Array_Wrapper_IsCharArray_0200 171 * @tc.name: IsCharArray 172 * @tc.desc: 173 */ 174HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsCharArray_0200, Function | MediumTest | Level1) 175{ 176 long index = 5; 177 InterfaceID typeId = g_IID_IChar; 178 sptr<IArray> arr = new Array(index, typeId); 179 bool result = Array::IsCharArray(arr); 180 EXPECT_EQ(result, true); 181} 182 183/** 184 * @tc.number: AaFwk_Array_Wrapper_IsByteArray_0100 185 * @tc.name: IsByteArray 186 * @tc.desc: 187 */ 188HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsByteArray_0100, Function | MediumTest | Level1) 189{ 190 long index = 5; 191 InterfaceID typeId; 192 sptr<IArray> arr = new Array(index, typeId); 193 bool result = Array::IsByteArray(arr); 194 EXPECT_EQ(result, false); 195} 196 197/** 198 * @tc.number: AaFwk_Array_Wrapper_IsByteArray_0200 199 * @tc.name: IsByteArray 200 * @tc.desc: 201 */ 202HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsByteArray_0200, Function | MediumTest | Level1) 203{ 204 long index = 5; 205 InterfaceID typeId = g_IID_IByte; 206 sptr<IArray> arr = new Array(index, typeId); 207 bool result = Array::IsByteArray(arr); 208 EXPECT_EQ(result, true); 209} 210 211/** 212 * @tc.number: AaFwk_Array_Wrapper_IsShortArray_0100 213 * @tc.name: IsShortArray 214 * @tc.desc: 215 */ 216HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsShortArray_0100, Function | MediumTest | Level1) 217{ 218 long index = 5; 219 InterfaceID typeId; 220 sptr<IArray> arr = new Array(index, typeId); 221 bool result = Array::IsShortArray(arr); 222 EXPECT_EQ(result, false); 223} 224 225/** 226 * @tc.number: AaFwk_Array_Wrapper_IsShortArray_0200 227 * @tc.name: IsShortArray 228 * @tc.desc: 229 */ 230HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsShortArray_0200, Function | MediumTest | Level1) 231{ 232 long index = 5; 233 InterfaceID typeId = g_IID_IShort; 234 sptr<IArray> arr = new Array(index, typeId); 235 bool result = Array::IsShortArray(arr); 236 EXPECT_EQ(result, true); 237} 238 239/** 240 * @tc.number: AaFwk_Array_Wrapper_IsIntegerArray_0100 241 * @tc.name: IsIntegerArray 242 * @tc.desc: 243 */ 244HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsIntegerArray_0100, Function | MediumTest | Level1) 245{ 246 long index = 5; 247 InterfaceID typeId; 248 sptr<IArray> arr = new Array(index, typeId); 249 bool result = Array::IsIntegerArray(arr); 250 EXPECT_EQ(result, false); 251} 252 253/** 254 * @tc.number: AaFwk_Array_Wrapper_IsIntegerArray_0200 255 * @tc.name: IsIntegerArray 256 * @tc.desc: 257 */ 258HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsIntegerArray_0200, Function | MediumTest | Level1) 259{ 260 long index = 5; 261 InterfaceID typeId = g_IID_IInteger; 262 sptr<IArray> arr = new Array(index, typeId); 263 bool result = Array::IsIntegerArray(arr); 264 EXPECT_EQ(result, true); 265} 266 267/** 268 * @tc.number: AaFwk_Array_Wrapper_IsLongArray_0100 269 * @tc.name: IsLongArray 270 * @tc.desc: 271 */ 272HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsLongArray_0100, Function | MediumTest | Level1) 273{ 274 long index = 5; 275 InterfaceID typeId; 276 sptr<IArray> arr = new Array(index, typeId); 277 bool result = Array::IsLongArray(arr); 278 EXPECT_EQ(result, false); 279} 280 281/** 282 * @tc.number: AaFwk_Array_Wrapper_IsLongArray_0200 283 * @tc.name: IsLongArray 284 * @tc.desc: 285 */ 286HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsLongArray_0200, Function | MediumTest | Level1) 287{ 288 long index = 5; 289 InterfaceID typeId = g_IID_ILong; 290 sptr<IArray> arr = new Array(index, typeId); 291 bool result = Array::IsLongArray(arr); 292 EXPECT_EQ(result, true); 293} 294 295/** 296 * @tc.number: AaFwk_Array_Wrapper_IsFloatArray_0100 297 * @tc.name: IsFloatArray 298 * @tc.desc: 299 */ 300HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsFloatArray_0100, Function | MediumTest | Level1) 301{ 302 long index = 5; 303 InterfaceID typeId; 304 sptr<IArray> arr = new Array(index, typeId); 305 bool result = Array::IsFloatArray(arr); 306 EXPECT_EQ(result, false); 307} 308 309/** 310 * @tc.number: AaFwk_Array_Wrapper_IsFloatArray_0200 311 * @tc.name: IsFloatArray 312 * @tc.desc: 313 */ 314HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsFloatArray_0200, Function | MediumTest | Level1) 315{ 316 long index = 5; 317 InterfaceID typeId = g_IID_IFloat; 318 sptr<IArray> arr = new Array(index, typeId); 319 bool result = Array::IsFloatArray(arr); 320 EXPECT_EQ(result, true); 321} 322 323/** 324 * @tc.number: AaFwk_Array_Wrapper_IsDoubleArray_0100 325 * @tc.name: IsDoubleArray 326 * @tc.desc: 327 */ 328HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsDoubleArray_0100, Function | MediumTest | Level1) 329{ 330 long index = 5; 331 InterfaceID typeId; 332 sptr<IArray> arr = new Array(index, typeId); 333 bool result = Array::IsDoubleArray(arr); 334 EXPECT_EQ(result, false); 335} 336 337/** 338 * @tc.number: AaFwk_Array_Wrapper_IsDoubleArray_0200 339 * @tc.name: IsDoubleArray 340 * @tc.desc: 341 */ 342HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsDoubleArray_0200, Function | MediumTest | Level1) 343{ 344 long index = 5; 345 InterfaceID typeId = g_IID_IDouble; 346 sptr<IArray> arr = new Array(index, typeId); 347 bool result = Array::IsDoubleArray(arr); 348 EXPECT_EQ(result, true); 349} 350 351/** 352 * @tc.number: AaFwk_Array_Wrapper_IsStringArray_0100 353 * @tc.name: IsStringArray 354 * @tc.desc: 355 */ 356HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsStringArray_0100, Function | MediumTest | Level1) 357{ 358 long index = 5; 359 InterfaceID typeId; 360 sptr<IArray> arr = new Array(index, typeId); 361 bool result = Array::IsStringArray(arr); 362 EXPECT_EQ(result, false); 363} 364 365/** 366 * @tc.number: AaFwk_Array_Wrapper_IsStringArray_0200 367 * @tc.name: IsStringArray 368 * @tc.desc: 369 */ 370HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsStringArray_0200, Function | MediumTest | Level1) 371{ 372 long index = 5; 373 InterfaceID typeId = g_IID_IString; 374 sptr<IArray> arr = new Array(index, typeId); 375 bool result = Array::IsStringArray(arr); 376 EXPECT_EQ(result, true); 377} 378 379/** 380 * @tc.number: AaFwk_Array_Wrapper_IsWantParamsArray_0100 381 * @tc.name: IsWantParamsArray 382 * @tc.desc: 383 */ 384HWTEST_F(ArrayWrapperBaseTest, AaFwk_Array_Wrapper_IsWantParamsArray_0100, Function | MediumTest | Level1) 385{ 386 long index = 5; 387 InterfaceID typeId; 388 sptr<IArray> arr = new Array(index, typeId); 389 bool result = Array::IsWantParamsArray(arr); 390 EXPECT_EQ(result, false); 391} 392} 393}