blob: 283c71b38eeff73cf686cb80928751b9ea3b00d6 [file] [log] [blame]
Sahin Caliskanf00a8762019-01-24 14:32:12 -08001/*
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 */
16package com.android.tests.ims;
17
18import static com.google.common.truth.Truth.assertThat;
19
20import android.os.Parcel;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080021import android.telephony.ims.RcsParticipantAliasChangedEvent;
Leland Millerc39f23c2019-02-06 10:07:38 -080022import android.telephony.ims.RcsParticipantAliasChangedEventDescriptor;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080023
Brett Chabot502ec7a2019-03-01 14:43:20 -080024import androidx.test.runner.AndroidJUnit4;
25
Sahin Caliskanf00a8762019-01-24 14:32:12 -080026import org.junit.Test;
27import org.junit.runner.RunWith;
28
29@RunWith(AndroidJUnit4.class)
30public class RcsParticipantAliasChangedEventTest {
31 private static final String OLD_ALIAS = "old alias";
32 private static final String NEW_ALIAS = "new alias";
Leland Millerc39f23c2019-02-06 10:07:38 -080033 private int mParticipantId = 3;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080034
35 @Test
36 public void testCanUnparcel() {
Leland Millerc39f23c2019-02-06 10:07:38 -080037 RcsParticipantAliasChangedEventDescriptor aliasChangedEventDescriptor =
38 new RcsParticipantAliasChangedEventDescriptor(
39 1234567890, mParticipantId, NEW_ALIAS);
Sahin Caliskanf00a8762019-01-24 14:32:12 -080040
41 Parcel parcel = Parcel.obtain();
Leland Millerc39f23c2019-02-06 10:07:38 -080042 aliasChangedEventDescriptor.writeToParcel(
43 parcel, aliasChangedEventDescriptor.describeContents());
Sahin Caliskanf00a8762019-01-24 14:32:12 -080044
45 parcel.setDataPosition(0);
46
Leland Millerc39f23c2019-02-06 10:07:38 -080047 aliasChangedEventDescriptor = RcsParticipantAliasChangedEventDescriptor.CREATOR
48 .createFromParcel(parcel);
Sahin Caliskanf00a8762019-01-24 14:32:12 -080049
Leland Millerc39f23c2019-02-06 10:07:38 -080050 RcsParticipantAliasChangedEvent aliasChangedEvent =
51 aliasChangedEventDescriptor.createRcsEvent();
52
53 assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId);
Sahin Caliskanf00a8762019-01-24 14:32:12 -080054 assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS);
55 assertThat(aliasChangedEvent.getTimestamp()).isEqualTo(1234567890);
56 }
57}