Home | History | Annotate | Download | only in telephony
      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 package com.android.internal.telephony;
     18 
     19 import static org.junit.Assert.assertEquals;
     20 
     21 import android.os.Parcel;
     22 import android.support.test.filters.SmallTest;
     23 import android.telephony.AccessNetworkConstants.AccessNetworkType;
     24 import android.telephony.AccessNetworkConstants.EutranBand;
     25 import android.telephony.AccessNetworkConstants.GeranBand;
     26 import android.telephony.NetworkScanRequest;
     27 import android.telephony.RadioAccessSpecifier;
     28 
     29 import org.junit.Test;
     30 
     31 import java.util.ArrayList;
     32 
     33 /** Unit tests for {@link NetworkScanRequest}. */
     34 
     35 public class NetworkScanRequestTest {
     36 
     37     @Test
     38     @SmallTest
     39     public void testParcel() {
     40         int ranGsm = AccessNetworkType.GERAN;
     41         int[] gsmBands = {GeranBand.BAND_T380, GeranBand.BAND_T410};
     42         int[] gsmChannels = {1, 2, 3, 4};
     43         RadioAccessSpecifier gsm = new RadioAccessSpecifier(ranGsm, gsmBands, gsmChannels);
     44         int ranLte = AccessNetworkType.EUTRAN;
     45         int[] lteBands = {EutranBand.BAND_10, EutranBand.BAND_11};
     46         int[] lteChannels = {5, 6, 7, 8};
     47         RadioAccessSpecifier lte = new RadioAccessSpecifier(ranLte, lteBands, lteChannels);
     48         RadioAccessSpecifier[] ras = {gsm, lte};
     49         int searchPeriodicity = 70;
     50         int maxSearchTime = 200;
     51         boolean incrementalResults = true;
     52         int incrementalResultsPeriodicity = 7;
     53         ArrayList<String> mccmncs = new ArrayList<String>();
     54         mccmncs.add("310480");
     55         mccmncs.add("21002");
     56         NetworkScanRequest nsq = new NetworkScanRequest(NetworkScanRequest.SCAN_TYPE_ONE_SHOT, ras,
     57                   searchPeriodicity, maxSearchTime, incrementalResults,
     58                   incrementalResultsPeriodicity, mccmncs);
     59 
     60         Parcel p = Parcel.obtain();
     61         nsq.writeToParcel(p, 0);
     62         p.setDataPosition(0);
     63 
     64         NetworkScanRequest newNsq = NetworkScanRequest.CREATOR.createFromParcel(p);
     65         assertEquals(nsq, newNsq);
     66     }
     67 }
     68