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 package android.telephony.cts; 18 19 import static org.junit.Assert.assertArrayEquals; 20 import static org.junit.Assert.assertEquals; 21 22 import android.os.Parcel; 23 import android.telephony.ModemInfo; 24 import android.telephony.PhoneCapability; 25 26 import androidx.test.filters.SmallTest; 27 28 import org.junit.Test; 29 30 import java.util.ArrayList; 31 import java.util.List; 32 33 public class PhoneCapabilityTest { 34 @Test 35 @SmallTest parcelReadWrite()36 public void parcelReadWrite() throws Exception { 37 int maxActiveVoice = 1; 38 int maxActiveData = 2; 39 ModemInfo modemInfo = new ModemInfo(1, 2, true, false); 40 List<ModemInfo> logicalModemList = new ArrayList<>(); 41 logicalModemList.add(modemInfo); 42 int[] deviceNrCapabilities = new int[]{}; 43 44 Parcel parcel = Parcel.obtain(); 45 parcel.writeInt(maxActiveVoice); 46 parcel.writeInt(maxActiveData); 47 parcel.writeBoolean(false); 48 parcel.writeList(logicalModemList); 49 parcel.writeIntArray(deviceNrCapabilities); 50 51 parcel.setDataPosition(0); 52 PhoneCapability toCompare = PhoneCapability.CREATOR.createFromParcel(parcel); 53 54 assertEquals(maxActiveVoice, toCompare.getMaxActiveVoiceSubscriptions()); 55 assertEquals(maxActiveData, toCompare.getMaxActiveDataSubscriptions()); 56 assertArrayEquals(deviceNrCapabilities, toCompare.getDeviceNrCapabilities()); 57 } 58 } 59