Home | History | Annotate | Download | only in functional
      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 
     17 #include <radio_hidl_hal_utils.h>
     18 
     19 using namespace ::android::hardware::radio::V1_0;
     20 
     21 /*
     22  * Test IRadio.setGsmBroadcastConfig() for the response returned.
     23  */
     24 TEST_F(RadioHidlTest, setGsmBroadcastConfig) {
     25     int serial = GetRandomSerialNumber();
     26 
     27     // Create GsmBroadcastSmsConfigInfo #1
     28     GsmBroadcastSmsConfigInfo gbSmsConfig1;
     29     gbSmsConfig1.fromServiceId = 4352;
     30     gbSmsConfig1.toServiceId = 4354;
     31     gbSmsConfig1.fromCodeScheme = 0;
     32     gbSmsConfig1.toCodeScheme = 255;
     33     gbSmsConfig1.selected = true;
     34 
     35     // Create GsmBroadcastSmsConfigInfo #2
     36     GsmBroadcastSmsConfigInfo gbSmsConfig2;
     37     gbSmsConfig2.fromServiceId = 4356;
     38     gbSmsConfig2.toServiceId = 4356;
     39     gbSmsConfig2.fromCodeScheme = 0;
     40     gbSmsConfig2.toCodeScheme = 255;
     41     gbSmsConfig2.selected = true;
     42 
     43     // Create GsmBroadcastSmsConfigInfo #3
     44     GsmBroadcastSmsConfigInfo gbSmsConfig3;
     45     gbSmsConfig3.fromServiceId = 4370;
     46     gbSmsConfig3.toServiceId = 4379;
     47     gbSmsConfig3.fromCodeScheme = 0;
     48     gbSmsConfig3.toCodeScheme = 255;
     49     gbSmsConfig3.selected = true;
     50 
     51     // Create GsmBroadcastSmsConfigInfo #4
     52     GsmBroadcastSmsConfigInfo gbSmsConfig4;
     53     gbSmsConfig4.fromServiceId = 4383;
     54     gbSmsConfig4.toServiceId = 4391;
     55     gbSmsConfig4.fromCodeScheme = 0;
     56     gbSmsConfig4.toCodeScheme = 255;
     57     gbSmsConfig4.selected = true;
     58 
     59     // Create GsmBroadcastSmsConfigInfo #5
     60     GsmBroadcastSmsConfigInfo gbSmsConfig5;
     61     gbSmsConfig5.fromServiceId = 4392;
     62     gbSmsConfig5.toServiceId = 4392;
     63     gbSmsConfig5.fromCodeScheme = 0;
     64     gbSmsConfig5.toCodeScheme = 255;
     65     gbSmsConfig5.selected = true;
     66 
     67     android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo> gsmBroadcastSmsConfigsInfoList = {
     68         gbSmsConfig1, gbSmsConfig2, gbSmsConfig3, gbSmsConfig4, gbSmsConfig5};
     69 
     70     radio->setGsmBroadcastConfig(serial, gsmBroadcastSmsConfigsInfoList);
     71 
     72     EXPECT_EQ(std::cv_status::no_timeout, wait());
     73     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
     74     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
     75 
     76     if (cardStatus.cardState == CardState::ABSENT) {
     77         ASSERT_TRUE(CheckGeneralError() ||
     78                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
     79                     radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
     80                     radioRsp->rspInfo.error == RadioError::NONE ||
     81                     radioRsp->rspInfo.error == RadioError::INVALID_MODEM_STATE);
     82     }
     83 }
     84 
     85 /*
     86  * Test IRadio.getGsmBroadcastConfig() for the response returned.
     87  */
     88 TEST_F(RadioHidlTest, getGsmBroadcastConfig) {
     89     int serial = GetRandomSerialNumber();
     90 
     91     radio->getGsmBroadcastConfig(serial);
     92 
     93     EXPECT_EQ(std::cv_status::no_timeout, wait());
     94     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
     95     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
     96 
     97     if (cardStatus.cardState == CardState::ABSENT) {
     98         ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
     99                     radioRsp->rspInfo.error == RadioError::NONE ||
    100                     radioRsp->rspInfo.error == RadioError::INVALID_MODEM_STATE);
    101     }
    102 }
    103 
    104 /*
    105  * Test IRadio.setCdmaBroadcastConfig() for the response returned.
    106  */
    107 TEST_F(RadioHidlTest, setCdmaBroadcastConfig) {
    108     int serial = GetRandomSerialNumber();
    109 
    110     CdmaBroadcastSmsConfigInfo cbSmsConfig;
    111     cbSmsConfig.serviceCategory = 4096;
    112     cbSmsConfig.language = 1;
    113     cbSmsConfig.selected = true;
    114 
    115     android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo> cdmaBroadcastSmsConfigInfoList = {
    116         cbSmsConfig};
    117 
    118     radio->setCdmaBroadcastConfig(serial, cdmaBroadcastSmsConfigInfoList);
    119 
    120     EXPECT_EQ(std::cv_status::no_timeout, wait());
    121     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
    122     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
    123 
    124     if (cardStatus.cardState == CardState::ABSENT) {
    125         ASSERT_TRUE(CheckGeneralError() ||
    126                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
    127     }
    128 }
    129 
    130 /*
    131  * Test IRadio.getCdmaBroadcastConfig() for the response returned.
    132  */
    133 TEST_F(RadioHidlTest, getCdmaBroadcastConfig) {
    134     int serial = GetRandomSerialNumber();
    135 
    136     radio->getCdmaBroadcastConfig(serial);
    137 
    138     EXPECT_EQ(std::cv_status::no_timeout, wait());
    139     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
    140     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
    141 
    142     if (cardStatus.cardState == CardState::ABSENT) {
    143         ASSERT_TRUE(CheckGeneralError());
    144     }
    145 }
    146 
    147 /*
    148  * Test IRadio.setCdmaBroadcastActivation() for the response returned.
    149  */
    150 TEST_F(RadioHidlTest, setCdmaBroadcastActivation) {
    151     int serial = GetRandomSerialNumber();
    152     bool activate = false;
    153 
    154     radio->setCdmaBroadcastActivation(serial, activate);
    155 
    156     EXPECT_EQ(std::cv_status::no_timeout, wait());
    157     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
    158     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
    159 
    160     if (cardStatus.cardState == CardState::ABSENT) {
    161         ASSERT_TRUE(CheckGeneralError() ||
    162                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
    163     }
    164 }
    165 
    166 /*
    167  * Test IRadio.setGsmBroadcastActivation() for the response returned.
    168  */
    169 TEST_F(RadioHidlTest, setGsmBroadcastActivation) {
    170     int serial = GetRandomSerialNumber();
    171     bool activate = false;
    172 
    173     radio->setGsmBroadcastActivation(serial, activate);
    174 
    175     EXPECT_EQ(std::cv_status::no_timeout, wait());
    176     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
    177     EXPECT_EQ(serial, radioRsp->rspInfo.serial);
    178 
    179     if (cardStatus.cardState == CardState::ABSENT) {
    180         ASSERT_TRUE(CheckGeneralError() ||
    181                     radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
    182                     radioRsp->rspInfo.error == RadioError::INVALID_STATE ||
    183                     radioRsp->rspInfo.error == RadioError::NONE ||
    184                     radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
    185                     radioRsp->rspInfo.error == RadioError::INVALID_MODEM_STATE);
    186     }
    187 }
    188