1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include <vts_test_util.h>
17 #include <iostream>
18
GetRandomSerialNumber()19 int GetRandomSerialNumber() {
20 return rand();
21 }
22
CheckAnyOfErrors(RadioError err,std::vector<RadioError> errors,CheckFlag flag)23 ::testing::AssertionResult CheckAnyOfErrors(RadioError err, std::vector<RadioError> errors,
24 CheckFlag flag) {
25 const static vector<RadioError> generalErrors = {
26 RadioError::RADIO_NOT_AVAILABLE, RadioError::NO_MEMORY,
27 RadioError::INTERNAL_ERR, RadioError::SYSTEM_ERR,
28 RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED};
29 if (flag == CHECK_GENERAL_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
30 for (size_t i = 0; i < generalErrors.size(); i++) {
31 if (err == generalErrors[i]) {
32 return testing::AssertionSuccess();
33 }
34 }
35 }
36 if (flag == CHECK_OEM_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
37 if (err >= RadioError::OEM_ERROR_1 && err <= RadioError::OEM_ERROR_25) {
38 return testing::AssertionSuccess();
39 }
40 }
41 for (size_t i = 0; i < errors.size(); i++) {
42 if (err == errors[i]) {
43 return testing::AssertionSuccess();
44 }
45 }
46 return testing::AssertionFailure() << "RadioError:" + toString(err) + " is returned";
47 }
48
CheckAnyOfErrors(SapResultCode err,std::vector<SapResultCode> errors)49 ::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors) {
50 for (size_t i = 0; i < errors.size(); i++) {
51 if (err == errors[i]) {
52 return testing::AssertionSuccess();
53 }
54 }
55 return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned";
56 }