blob: e8989424de6d87db04c0beb6d183906bf529f973 [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.net.Uri;
21import android.os.Parcel;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080022import android.telephony.ims.RcsGroupThreadIconChangedEvent;
Leland Millerc39f23c2019-02-06 10:07:38 -080023import android.telephony.ims.RcsGroupThreadIconChangedEventDescriptor;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080024
Brett Chabot502ec7a2019-03-01 14:43:20 -080025import androidx.test.runner.AndroidJUnit4;
26
Sahin Caliskanf00a8762019-01-24 14:32:12 -080027import org.junit.Test;
28import org.junit.runner.RunWith;
29
30@RunWith(AndroidJUnit4.class)
31public class RcsGroupThreadIconChangedEventTest {
32
33 @Test
34 public void testCanUnparcel() {
Leland Millerc39f23c2019-02-06 10:07:38 -080035 int rcsGroupThreadId = 1;
36 int rcsParticipantId = 2;
Sahin Caliskanf00a8762019-01-24 14:32:12 -080037 Uri newIconUri = Uri.parse("content://new_icon");
38
Leland Millerc39f23c2019-02-06 10:07:38 -080039 RcsGroupThreadIconChangedEventDescriptor iconChangedEventDescriptor =
40 new RcsGroupThreadIconChangedEventDescriptor(1234567890, rcsGroupThreadId,
41 rcsParticipantId, newIconUri);
Sahin Caliskanf00a8762019-01-24 14:32:12 -080042
43 Parcel parcel = Parcel.obtain();
Leland Millerc39f23c2019-02-06 10:07:38 -080044 iconChangedEventDescriptor.writeToParcel(
45 parcel, iconChangedEventDescriptor.describeContents());
Sahin Caliskanf00a8762019-01-24 14:32:12 -080046
47 parcel.setDataPosition(0);
48
Leland Millerc39f23c2019-02-06 10:07:38 -080049 iconChangedEventDescriptor =
50 RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel);
51
52 RcsGroupThreadIconChangedEvent iconChangedEvent =
53 iconChangedEventDescriptor.createRcsEvent();
54
55
Sahin Caliskanf00a8762019-01-24 14:32:12 -080056
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}