Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 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 | package com.android.tests.ims; |
| 17 | |
| 18 | import static com.google.common.truth.Truth.assertThat; |
| 19 | |
| 20 | import android.os.Parcel; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 21 | import android.telephony.ims.RcsParticipantAliasChangedEvent; |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 22 | import android.telephony.ims.RcsParticipantAliasChangedEventDescriptor; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 23 | |
Brett Chabot | 502ec7a | 2019-03-01 14:43:20 -0800 | [diff] [blame^] | 24 | import androidx.test.runner.AndroidJUnit4; |
| 25 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 26 | import org.junit.Test; |
| 27 | import org.junit.runner.RunWith; |
| 28 | |
| 29 | @RunWith(AndroidJUnit4.class) |
| 30 | public class RcsParticipantAliasChangedEventTest { |
| 31 | private static final String OLD_ALIAS = "old alias"; |
| 32 | private static final String NEW_ALIAS = "new alias"; |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 33 | private int mParticipantId = 3; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 34 | |
| 35 | @Test |
| 36 | public void testCanUnparcel() { |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 37 | RcsParticipantAliasChangedEventDescriptor aliasChangedEventDescriptor = |
| 38 | new RcsParticipantAliasChangedEventDescriptor( |
| 39 | 1234567890, mParticipantId, NEW_ALIAS); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 40 | |
| 41 | Parcel parcel = Parcel.obtain(); |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 42 | aliasChangedEventDescriptor.writeToParcel( |
| 43 | parcel, aliasChangedEventDescriptor.describeContents()); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 44 | |
| 45 | parcel.setDataPosition(0); |
| 46 | |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 47 | aliasChangedEventDescriptor = RcsParticipantAliasChangedEventDescriptor.CREATOR |
| 48 | .createFromParcel(parcel); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 49 | |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 50 | RcsParticipantAliasChangedEvent aliasChangedEvent = |
| 51 | aliasChangedEventDescriptor.createRcsEvent(); |
| 52 | |
| 53 | assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 54 | assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS); |
| 55 | assertThat(aliasChangedEvent.getTimestamp()).isEqualTo(1234567890); |
| 56 | } |
| 57 | } |