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.net.Uri; |
| 21 | import android.os.Parcel; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 22 | import android.telephony.ims.RcsGroupThreadIconChangedEvent; |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 23 | import android.telephony.ims.RcsGroupThreadIconChangedEventDescriptor; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 24 | |
Brett Chabot | 502ec7a | 2019-03-01 14:43:20 -0800 | [diff] [blame^] | 25 | import androidx.test.runner.AndroidJUnit4; |
| 26 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 27 | import org.junit.Test; |
| 28 | import org.junit.runner.RunWith; |
| 29 | |
| 30 | @RunWith(AndroidJUnit4.class) |
| 31 | public class RcsGroupThreadIconChangedEventTest { |
| 32 | |
| 33 | @Test |
| 34 | public void testCanUnparcel() { |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 35 | int rcsGroupThreadId = 1; |
| 36 | int rcsParticipantId = 2; |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 37 | Uri newIconUri = Uri.parse("content://new_icon"); |
| 38 | |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 39 | RcsGroupThreadIconChangedEventDescriptor iconChangedEventDescriptor = |
| 40 | new RcsGroupThreadIconChangedEventDescriptor(1234567890, rcsGroupThreadId, |
| 41 | rcsParticipantId, newIconUri); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 42 | |
| 43 | Parcel parcel = Parcel.obtain(); |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 44 | iconChangedEventDescriptor.writeToParcel( |
| 45 | parcel, iconChangedEventDescriptor.describeContents()); |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 46 | |
| 47 | parcel.setDataPosition(0); |
| 48 | |
Leland Miller | c39f23c | 2019-02-06 10:07:38 -0800 | [diff] [blame] | 49 | iconChangedEventDescriptor = |
| 50 | RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel); |
| 51 | |
| 52 | RcsGroupThreadIconChangedEvent iconChangedEvent = |
| 53 | iconChangedEventDescriptor.createRcsEvent(); |
| 54 | |
| 55 | |
Sahin Caliskan | f00a876 | 2019-01-24 14:32:12 -0800 | [diff] [blame] | 56 | |
| 57 | assertThat(iconChangedEvent.getNewIcon()).isEqualTo(newIconUri); |
| 58 | assertThat(iconChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); |
| 59 | assertThat(iconChangedEvent.getOriginatingParticipant().getId()).isEqualTo(2); |
| 60 | assertThat(iconChangedEvent.getTimestamp()).isEqualTo(1234567890); |
| 61 | } |
| 62 | } |