• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import android.test.suitebuilder.annotation.SmallTest;
26 
27 import org.junit.Test;
28 
29 import java.util.ArrayList;
30 import java.util.List;
31 
32 public class PhoneCapabilityTest {
33     @Test
34     @SmallTest
parcelReadWrite()35     public void parcelReadWrite() throws Exception {
36         int maxActiveVoice = 1;
37         int maxActiveData = 2;
38         ModemInfo modemInfo = new ModemInfo(1, 2, true, false);
39         List<ModemInfo> logicalModemList = new ArrayList<>();
40         logicalModemList.add(modemInfo);
41         int[] deviceNrCapabilities = new int[]{};
42 
43         Parcel parcel = Parcel.obtain();
44         parcel.writeInt(maxActiveVoice);
45         parcel.writeInt(maxActiveData);
46         parcel.writeBoolean(false);
47         parcel.writeList(logicalModemList);
48         parcel.writeIntArray(deviceNrCapabilities);
49 
50         parcel.setDataPosition(0);
51         PhoneCapability toCompare = PhoneCapability.CREATOR.createFromParcel(parcel);
52 
53         assertEquals(maxActiveVoice, toCompare.getMaxActiveVoiceSubscriptions());
54         assertEquals(maxActiveData, toCompare.getMaxActiveDataSubscriptions());
55         assertArrayEquals(deviceNrCapabilities, toCompare.getDeviceNrCapabilities());
56     }
57 }
58