Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2018 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.euicc.cts;
     18 
     19 import static org.junit.Assert.assertEquals;
     20 import static org.junit.Assert.assertNotNull;
     21 import static org.junit.Assert.assertTrue;
     22 
     23 import android.os.Parcel;
     24 import android.os.Parcelable;
     25 import android.support.test.runner.AndroidJUnit4;
     26 
     27 import org.junit.Before;
     28 import org.junit.Test;
     29 import org.junit.runner.RunWith;
     30 
     31 import android.telephony.euicc.EuiccInfo;
     32 
     33 @RunWith(AndroidJUnit4.class)
     34 public class EuiccInfoTest {
     35 
     36     private static final String OS_VERSION = "1.23";
     37 
     38     private EuiccInfo mEuiccInfo;
     39 
     40     @Before
     41     public void setUp() throws Exception {
     42         mEuiccInfo = new EuiccInfo(OS_VERSION);
     43     }
     44 
     45     @Test
     46     public void testGetOsVersion() {
     47         assertNotNull(mEuiccInfo);
     48         assertEquals(OS_VERSION, mEuiccInfo.getOsVersion());
     49     }
     50 
     51     @Test
     52     public void testDescribeContents() {
     53         assertNotNull(mEuiccInfo);
     54         int bitmask = mEuiccInfo.describeContents();
     55         assertTrue(bitmask == 0 || bitmask == Parcelable.CONTENTS_FILE_DESCRIPTOR);
     56     }
     57 
     58     @Test
     59     public void testWriteToParcel() {
     60         assertNotNull(mEuiccInfo);
     61 
     62         // write object to parcel
     63         Parcel parcel = Parcel.obtain();
     64         mEuiccInfo.writeToParcel(parcel, mEuiccInfo.describeContents());
     65 
     66         // extract object from parcel
     67         parcel.setDataPosition(0 /* pos */);
     68         EuiccInfo euiccInfoFromParcel = EuiccInfo.CREATOR.createFromParcel(parcel);
     69         assertEquals(OS_VERSION, euiccInfoFromParcel.getOsVersion());
     70     }
     71 }
     72