1 /*
2 * Copyright (C) 2020 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
17 #define LOG_TAG "RadioTest"
18
19 #include <vts_test_util_v1_6.h>
20 #include <iostream>
21 #include "VtsCoreUtil.h"
22
CheckAnyOfErrors(::android::hardware::radio::V1_6::RadioError err,std::vector<::android::hardware::radio::V1_6::RadioError> errors,CheckFlag flag)23 ::testing::AssertionResult CheckAnyOfErrors(
24 ::android::hardware::radio::V1_6::RadioError err,
25 std::vector<::android::hardware::radio::V1_6::RadioError> errors, CheckFlag flag) {
26 const static vector<::android::hardware::radio::V1_6::RadioError> generalErrors = {
27 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
28 ::android::hardware::radio::V1_6::RadioError::NO_MEMORY,
29 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
30 ::android::hardware::radio::V1_6::RadioError::SYSTEM_ERR,
31 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
32 ::android::hardware::radio::V1_6::RadioError::CANCELLED};
33 if (flag == CHECK_GENERAL_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
34 for (size_t i = 0; i < generalErrors.size(); i++) {
35 if (err == generalErrors[i]) {
36 return testing::AssertionSuccess();
37 }
38 }
39 }
40 if (flag == CHECK_OEM_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
41 if (err >= ::android::hardware::radio::V1_6::RadioError::OEM_ERROR_1 &&
42 err <= ::android::hardware::radio::V1_6::RadioError::OEM_ERROR_25) {
43 return testing::AssertionSuccess();
44 }
45 }
46 for (size_t i = 0; i < errors.size(); i++) {
47 if (err == errors[i]) {
48 return testing::AssertionSuccess();
49 }
50 }
51 return testing::AssertionFailure() << "RadioError:" + toString(err) + " is returned";
52 }
53