Files
hardware_interfaces/radio/1.0/vts/functional/vts_test_util.cpp
Youming Ye f11cccda3b Correct the comments for radio hal types
The type of mcc and mnc is String instead of Int now. They should be an
empty string if unknown. Also added a test case for their values.

Bug: 111703979
Test: Vts
Change-Id: Ie0426453dc426ccc6cf203b315806e78511ce14d
2018-09-04 11:10:32 -07:00

56 lines
2.1 KiB
C++

/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vts_test_util.h>
#include <iostream>
int GetRandomSerialNumber() {
return rand();
}
::testing::AssertionResult CheckAnyOfErrors(RadioError err, std::vector<RadioError> errors,
CheckFlag flag) {
const static vector<RadioError> generalErrors = {
RadioError::RADIO_NOT_AVAILABLE, RadioError::NO_MEMORY,
RadioError::INTERNAL_ERR, RadioError::SYSTEM_ERR,
RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED};
if (flag == CHECK_GENERAL_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
for (size_t i = 0; i < generalErrors.size(); i++) {
if (err == generalErrors[i]) {
return testing::AssertionSuccess();
}
}
}
if (flag == CHECK_OEM_ERROR || flag == CHECK_OEM_AND_GENERAL_ERROR) {
if (err >= RadioError::OEM_ERROR_1 && err <= RadioError::OEM_ERROR_25) {
return testing::AssertionSuccess();
}
}
for (size_t i = 0; i < errors.size(); i++) {
if (err == errors[i]) {
return testing::AssertionSuccess();
}
}
return testing::AssertionFailure() << "RadioError:" + toString(err) + " is returned";
}
::testing::AssertionResult CheckAnyOfErrors(SapResultCode err, std::vector<SapResultCode> errors) {
for (size_t i = 0; i < errors.size(); i++) {
if (err == errors[i]) {
return testing::AssertionSuccess();
}
}
return testing::AssertionFailure() << "SapError:" + toString(err) + " is returned";
}