1 /* 2 * Copyright (C) 2019 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.ims.cts; 18 19 import static org.junit.Assert.assertEquals; 20 21 import android.os.Parcel; 22 import android.telephony.ims.ImsCallForwardInfo; 23 24 import androidx.test.ext.junit.runners.AndroidJUnit4; 25 26 import org.junit.Test; 27 import org.junit.runner.RunWith; 28 29 @RunWith(AndroidJUnit4.class) 30 public class ImsCallForwardInfoTest { 31 32 @Test createParcelUnparcel()33 public void createParcelUnparcel() { 34 if (!ImsUtils.shouldTestImsService()) { 35 return; 36 } 37 int condition = 1; // ImsUtInterface#CDIV_CF_BUSY 38 int status = 1; //enabled 39 int toA = 0x91; // International 40 int serviceClass = 1; // CommandsInterface#SERVICE_CLASS_VOICE 41 String number = "5555551212"; 42 int timeSeconds = 1; // no reply timer 43 ImsCallForwardInfo info = new ImsCallForwardInfo(condition, status, toA, serviceClass, 44 number, timeSeconds); 45 46 Parcel infoParceled = Parcel.obtain(); 47 info.writeToParcel(infoParceled, 0); 48 infoParceled.setDataPosition(0); 49 ImsCallForwardInfo unparceledInfo = 50 ImsCallForwardInfo.CREATOR.createFromParcel(infoParceled); 51 infoParceled.recycle(); 52 53 assertEquals(condition, unparceledInfo.getCondition()); 54 assertEquals(status, unparceledInfo.getStatus()); 55 assertEquals(toA, unparceledInfo.getToA()); 56 assertEquals(serviceClass, unparceledInfo.getServiceClass()); 57 assertEquals(number, unparceledInfo.getNumber()); 58 assertEquals(timeSeconds, unparceledInfo.getTimeSeconds()); 59 } 60 } 61