From c673a94a96cfd963f8c4b9802a1ecff497c2ee44 Mon Sep 17 00:00:00 2001 From: sqian Date: Wed, 24 May 2017 15:08:25 -0700 Subject: [PATCH] Add radio 1.1 vts test folder. Bug: 38034125 Test: compile; adb shell compiled_vts_binary Change-Id: I05d4f03db40ac712f120ac0e3e52301a6252f041 Merged-In: I05d4f03db40ac712f120ac0e3e52301a6252f041 --- radio/1.0/vts/functional/Android.bp | 35 ++++++++++++ .../functional/VtsHalRadioV1_0TargetTest.cpp | 2 +- .../radio_hidl_hal_cell_broadcast.cpp | 2 +- .../vts/functional/radio_hidl_hal_data.cpp | 2 +- .../1.0/vts/functional/radio_hidl_hal_icc.cpp | 2 +- .../1.0/vts/functional/radio_hidl_hal_ims.cpp | 2 +- .../vts/functional/radio_hidl_hal_misc.cpp | 2 +- .../1.0/vts/functional/radio_hidl_hal_sms.cpp | 2 +- .../1.0/vts/functional/radio_hidl_hal_stk.cpp | 2 +- .../vts/functional/radio_hidl_hal_test.cpp | 2 +- ...al_utils.h => radio_hidl_hal_utils_v1_0.h} | 6 +-- .../vts/functional/radio_hidl_hal_voice.cpp | 2 +- radio/1.0/vts/functional/radio_response.cpp | 2 +- radio/1.0/vts/functional/sap_hidl_hal_utils.h | 2 +- radio/1.1/vts/Android.mk | 19 +++++++ radio/1.1/vts/functional/Android.bp | 46 ++++++++++++++++ .../functional/VtsHalRadioV1_1TargetTest.cpp | 27 ++++++++++ .../1.1/vts/functional/radio_hidl_hal_api.cpp | 36 +++++++++++++ .../vts/functional/radio_hidl_hal_test.cpp | 39 ++++++++++++++ .../functional/radio_hidl_hal_utils_v1_1.h | 54 +++++++++++++++++++ radio/1.1/vts/functional/radio_response.cpp | 40 ++++++++++++++ radio/Android.bp | 1 + 22 files changed, 312 insertions(+), 15 deletions(-) rename radio/1.0/vts/functional/{radio_hidl_hal_utils.h => radio_hidl_hal_utils_v1_0.h} (99%) create mode 100644 radio/1.1/vts/Android.mk create mode 100644 radio/1.1/vts/functional/Android.bp create mode 100644 radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp create mode 100644 radio/1.1/vts/functional/radio_hidl_hal_api.cpp create mode 100644 radio/1.1/vts/functional/radio_hidl_hal_test.cpp create mode 100644 radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h create mode 100644 radio/1.1/vts/functional/radio_response.cpp diff --git a/radio/1.0/vts/functional/Android.bp b/radio/1.0/vts/functional/Android.bp index 540397178b..8cd823ec1a 100644 --- a/radio/1.0/vts/functional/Android.bp +++ b/radio/1.0/vts/functional/Android.bp @@ -70,3 +70,38 @@ cc_test { "-g", ], } + +cc_library_static { + name: "RadioHidlHalUtilsBase", + srcs : [ + "radio_hidl_hal_test.cpp", + "radio_response.cpp" + ], + shared_libs: [ + "libbase", + "liblog", + "libcutils", + "libhidlbase", + "libhidltransport", + "libnativehelper", + "libutils", + "android.hardware.radio@1.0", + ], + static_libs: ["VtsHalHidlTargetTestBase"], + cflags: [ + "-O0", + "-g", + ], +} + +cc_library_static { + name: "RadioVtsTestUtilBase", + srcs : [ + "vts_test_util.cpp" + ], +} + +cc_library_headers { + name: "radio.util.header@1.0", + export_include_dirs: ["."], +} \ No newline at end of file diff --git a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp index 59881eff7c..3448494ffd 100644 --- a/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp +++ b/radio/1.0/vts/functional/VtsHalRadioV1_0TargetTest.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include int main(int argc, char** argv) { ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment); diff --git a/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp b/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp index 3bf7c9d6a2..44f69e207f 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_cell_broadcast.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp index 108676b9d4..35d97ee686 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_data.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_data.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp index a8857c3455..8f01d8d43b 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include /* * Test IRadio.getIccCardStatus() for the response returned. diff --git a/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp b/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp index ec99d428c5..75a131700d 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_ims.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp index 29cb91232f..5d0824c37f 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_misc.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include /* * Test IRadio.getSignalStrength() for the response returned. diff --git a/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp index 698cf26df5..70469d2eed 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_sms.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp index 4c76c45fec..1c21303015 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_stk.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp index 1aa9d6c9f0..5b9130e07b 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_test.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_test.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include void RadioHidlTest::SetUp() { radio = diff --git a/radio/1.0/vts/functional/radio_hidl_hal_utils.h b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h similarity index 99% rename from radio/1.0/vts/functional/radio_hidl_hal_utils.h rename to radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h index 3c46e79854..3bd69ab210 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_utils.h +++ b/radio/1.0/vts/functional/radio_hidl_hal_utils_v1_0.h @@ -26,7 +26,7 @@ #include #include -#include +#include "vts_test_util.h" using ::android::hardware::radio::V1_0::ActivityStatsInfo; using ::android::hardware::radio::V1_0::AppType; @@ -90,7 +90,7 @@ extern CardStatus cardStatus; /* Callback class for radio response */ class RadioResponse : public IRadioResponse { - private: + protected: RadioHidlTest& parent; public: @@ -442,7 +442,7 @@ class RadioResponse : public IRadioResponse { // The main test class for Radio HIDL. class RadioHidlTest : public ::testing::VtsHalHidlTargetTestBase { - private: + protected: std::mutex mtx; std::condition_variable cv; int count; diff --git a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp index 95d00e32fc..e6036dbf39 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include /* * Test IRadio.getCurrentCalls() for the response returned. diff --git a/radio/1.0/vts/functional/radio_response.cpp b/radio/1.0/vts/functional/radio_response.cpp index ef887ebd28..434d488f5f 100644 --- a/radio/1.0/vts/functional/radio_response.cpp +++ b/radio/1.0/vts/functional/radio_response.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include CardStatus cardStatus; diff --git a/radio/1.0/vts/functional/sap_hidl_hal_utils.h b/radio/1.0/vts/functional/sap_hidl_hal_utils.h index fe93a4dbbf..7126b06e03 100644 --- a/radio/1.0/vts/functional/sap_hidl_hal_utils.h +++ b/radio/1.0/vts/functional/sap_hidl_hal_utils.h @@ -25,7 +25,7 @@ #include #include -#include +#include "vts_test_util.h" using namespace ::android::hardware::radio::V1_0; diff --git a/radio/1.1/vts/Android.mk b/radio/1.1/vts/Android.mk new file mode 100644 index 0000000000..df5dac8072 --- /dev/null +++ b/radio/1.1/vts/Android.mk @@ -0,0 +1,19 @@ +# +# Copyright (C) 2016 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. +# + +LOCAL_PATH := $(call my-dir) + +include $(call all-subdir-makefiles) \ No newline at end of file diff --git a/radio/1.1/vts/functional/Android.bp b/radio/1.1/vts/functional/Android.bp new file mode 100644 index 0000000000..59ef905834 --- /dev/null +++ b/radio/1.1/vts/functional/Android.bp @@ -0,0 +1,46 @@ +// +// 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. +// + +cc_test { + name: "VtsHalRadioV1_1TargetTest", + defaults: ["hidl_defaults"], + srcs: ["radio_hidl_hal_api.cpp", + "radio_hidl_hal_test.cpp", + "radio_response.cpp", + "VtsHalRadioV1_1TargetTest.cpp"], + shared_libs: [ + "libbase", + "liblog", + "libcutils", + "libhidlbase", + "libhidltransport", + "libnativehelper", + "libutils", + "android.hardware.radio@1.1", + "android.hardware.radio@1.0", + ], + static_libs: ["VtsHalHidlTargetTestBase", + "RadioHidlHalUtilsBase", + "RadioVtsTestUtilBase"], + header_libs: [ + "radio.util.header@1.0", + ], + cflags: [ + "-O0", + "-g", + ], +} + diff --git a/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp new file mode 100644 index 0000000000..09351c850a --- /dev/null +++ b/radio/1.1/vts/functional/VtsHalRadioV1_1TargetTest.cpp @@ -0,0 +1,27 @@ +/* + * 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 + +int main(int argc, char** argv) { + ::testing::AddGlobalTestEnvironment(new RadioHidlEnvironment); + ::testing::InitGoogleTest(&argc, argv); + + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + + return status; +} \ No newline at end of file diff --git a/radio/1.1/vts/functional/radio_hidl_hal_api.cpp b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp new file mode 100644 index 0000000000..4f4fa6d5b0 --- /dev/null +++ b/radio/1.1/vts/functional/radio_hidl_hal_api.cpp @@ -0,0 +1,36 @@ +/* + * 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 + +/* + * Test IRadio.setSimCardPower() for the response returned. + */ +TEST_F(RadioHidlTest_v1_1, setSimCardPower_1_1) { + int serial = GetRandomSerialNumber(); + + radio_v1_1->setSimCardPower_1_1(serial, CardPowerState::POWER_DOWN); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial); + + if (cardStatus.cardState == CardState::ABSENT) { + ASSERT_TRUE(radioRsp_v1_1->rspInfo.error == RadioError::NONE || + radioRsp_v1_1->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED || + radioRsp_v1_1->rspInfo.error == RadioError::INVALID_ARGUMENTS || + radioRsp_v1_1->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE); + } +} diff --git a/radio/1.1/vts/functional/radio_hidl_hal_test.cpp b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp new file mode 100644 index 0000000000..eb87549406 --- /dev/null +++ b/radio/1.1/vts/functional/radio_hidl_hal_test.cpp @@ -0,0 +1,39 @@ +/* + * 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 + +void RadioHidlTest_v1_1::SetUp() { + radio_v1_1 = + ::testing::VtsHalHidlTargetTestBase::getService<::android::hardware::radio::V1_1::IRadio>( + hidl_string(RADIO_SERVICE_NAME)); + ASSERT_NE(radio_v1_1, nullptr); + + radioRsp_v1_1 = new RadioResponse_v1_1(*this); + ASSERT_NE(radioRsp_v1_1, nullptr); + + count = 0; + + radioInd_v1_1 = NULL; + radio_v1_1->setResponseFunctions(radioRsp_v1_1, radioInd_v1_1); + + int serial = GetRandomSerialNumber(); + radio_v1_1->getIccCardStatus(serial); + EXPECT_EQ(std::cv_status::no_timeout, wait()); + EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_1->rspInfo.type); + EXPECT_EQ(serial, radioRsp_v1_1->rspInfo.serial); + EXPECT_EQ(RadioError::NONE, radioRsp_v1_1->rspInfo.error); +} diff --git a/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h new file mode 100644 index 0000000000..ae72d8f6d5 --- /dev/null +++ b/radio/1.1/vts/functional/radio_hidl_hal_utils_v1_1.h @@ -0,0 +1,54 @@ +/* + * 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 +#include +#include +#include + +#include "radio_hidl_hal_utils_v1_0.h" + +using namespace ::android::hardware::radio::V1_1; + +class RadioHidlTest_v1_1; + +/* Callback class for radio response v1_1*/ +class RadioResponse_v1_1 : public RadioResponse { + protected: + RadioHidlTest_v1_1& parent_v1_1; + + public: + RadioResponse_v1_1(RadioHidlTest_v1_1& parent_v1_1); + virtual ~RadioResponse_v1_1() = default; + + /* 1.1 Api */ + Return setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo& info); + + Return setSimCardPowerResponse_1_1(const RadioResponseInfo& info); + + Return startNetworkScanResponse(const RadioResponseInfo& info); + + Return stopNetworkScanResponse(const RadioResponseInfo& info); +}; + +// The main test class for Radio HIDL. +class RadioHidlTest_v1_1 : public RadioHidlTest { + public: + virtual void SetUp() override; + sp<::android::hardware::radio::V1_1::IRadio> radio_v1_1; + sp radioRsp_v1_1; + sp<::android::hardware::radio::V1_1::IRadioIndication> radioInd_v1_1; +}; \ No newline at end of file diff --git a/radio/1.1/vts/functional/radio_response.cpp b/radio/1.1/vts/functional/radio_response.cpp new file mode 100644 index 0000000000..5b64543d48 --- /dev/null +++ b/radio/1.1/vts/functional/radio_response.cpp @@ -0,0 +1,40 @@ +/* + * 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 + +RadioResponse_v1_1::RadioResponse_v1_1(RadioHidlTest_v1_1& parent) + : RadioResponse(parent), parent_v1_1(parent) {} + +/* 1.1 Apis */ +Return RadioResponse_v1_1::setCarrierInfoForImsiEncryptionResponse( + const RadioResponseInfo& /*info*/) { + return Void(); +} + +Return RadioResponse_v1_1::setSimCardPowerResponse_1_1(const RadioResponseInfo& info) { + rspInfo = info; + parent_v1_1.notify(); + return Void(); +} + +Return RadioResponse_v1_1::startNetworkScanResponse(const RadioResponseInfo& /*info*/) { + return Void(); +} + +Return RadioResponse_v1_1::stopNetworkScanResponse(const RadioResponseInfo& /*info*/) { + return Void(); +} diff --git a/radio/Android.bp b/radio/Android.bp index dbeca0cf52..0acb2ee86d 100644 --- a/radio/Android.bp +++ b/radio/Android.bp @@ -3,5 +3,6 @@ subdirs = [ "1.0", "1.0/vts/functional", "1.1", + "1.1/vts/functional", "deprecated/1.0", ]