NotificationCompatTest.java revision a986dc1df96a380e34d2a91e7986e92165f59eb9
1/*
2 * Copyright (C) 2016 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
17package android.support.v4.app;
18
19import org.junit.Test;
20import org.junit.runner.RunWith;
21
22import android.support.test.runner.AndroidJUnit4;
23import android.test.suitebuilder.annotation.SmallTest;
24
25import static org.junit.Assert.*;
26
27@RunWith(AndroidJUnit4.class)
28public class NotificationCompatTest {
29
30    @SmallTest
31    @Test
32    public void testNotificationActionBuilder_copiesRemoteInputs() throws Throwable {
33        NotificationCompat.Action a = newActionBuilder()
34                .addRemoteInput(new RemoteInput("a", "b", null, false, null)).build();
35
36        NotificationCompat.Action aCopy = new NotificationCompat.Action.Builder(a).build();
37
38        assertSame(a.getRemoteInputs()[0], aCopy.getRemoteInputs()[0]);
39    }
40
41    @SmallTest
42    @Test
43    public void testNotificationActionBuilder_copiesAllowGeneratedReplies() throws Throwable {
44        NotificationCompat.Action a = newActionBuilder()
45                .setAllowGeneratedReplies(true).build();
46
47        NotificationCompat.Action aCopy = new NotificationCompat.Action.Builder(a).build();
48
49        assertEquals(a.getAllowGeneratedReplies(), aCopy.getAllowGeneratedReplies());
50    }
51
52    private NotificationCompat.Action.Builder newActionBuilder() {
53        return new NotificationCompat.Action.Builder(0, "title", null);
54    }
55}