1 /*
2  * Copyright (C) 2021 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 com.google.common.truth.Truth.assertThat;
20 
21 import android.os.Parcel;
22 import android.telephony.UiccPortInfo;
23 import android.test.AndroidTestCase;
24 
25 public class UiccPortInfoTest extends AndroidTestCase {
26     /**
27      * Create fake UiccPortInfo objects run basic tests.
28      */
testFakeUiccSlotInfoObject()29     public void testFakeUiccSlotInfoObject() {
30         String iccId = "FAKE_ICC_ID";
31         int portIndex = 0;
32         int logicalSlotIndex = 0;
33         boolean isActive = true;
34         UiccPortInfo uiccPortInfo = new UiccPortInfo(
35                 iccId,            /* ICCID */
36                 portIndex,      /* portIndex */
37                 logicalSlotIndex, /* logicalSlotIndex */
38                 isActive     /* isActive */
39         );
40 
41         //Getters.
42         assertThat(uiccPortInfo.getIccId()).isEqualTo(iccId);
43         assertThat(uiccPortInfo.getPortIndex()).isEqualTo(portIndex);
44         assertThat(uiccPortInfo.getLogicalSlotIndex()).isEqualTo(logicalSlotIndex);
45         assertThat(uiccPortInfo.isActive()).isEqualTo(isActive);
46 
47         // Other common methods.
48         assertThat(uiccPortInfo.describeContents()).isEqualTo(0);
49         assertThat(uiccPortInfo.hashCode()).isNotEqualTo(0);
50         assertThat(uiccPortInfo.toString()).isNotEmpty();
51 
52         // Parcel read and write.
53         Parcel parcel = Parcel.obtain();
54         uiccPortInfo.writeToParcel(parcel, 0);
55         parcel.setDataPosition(0);
56         UiccPortInfo toCompare = uiccPortInfo.CREATOR.createFromParcel(parcel);
57         assertThat(uiccPortInfo.hashCode()).isEqualTo(toCompare.hashCode());
58         assertThat(uiccPortInfo).isEqualTo(toCompare);
59     }
60 }
61