blob: 4aa8c6453ae5b6556481bfe78306477cb8ca0d8c [file] [log] [blame]
Zhomart Mukhamejanovf4d280c2018-04-17 13:20:22 -07001/*
2 * Copyright (C) 2018 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 com.example.android.systemupdatersample.util;
18
19import static org.junit.Assert.assertArrayEquals;
20
21import android.content.Context;
22import android.support.test.InstrumentationRegistry;
23import android.support.test.filters.SmallTest;
24import android.support.test.runner.AndroidJUnit4;
25
26import com.example.android.systemupdatersample.UpdateConfig;
27
28import org.junit.Before;
29import org.junit.Rule;
30import org.junit.Test;
31import org.junit.rules.ExpectedException;
32import org.junit.runner.RunWith;
33
34import java.util.Arrays;
35import java.util.List;
36
37/**
38 * Tests for {@link UpdateConfigs}
39 */
40@RunWith(AndroidJUnit4.class)
41@SmallTest
42public class UpdateConfigsTest {
43
44 private Context mContext;
45
46 @Rule
47 public final ExpectedException thrown = ExpectedException.none();
48
49 @Before
50 public void setUp() {
51 mContext = InstrumentationRegistry.getTargetContext();
52 }
53
54 @Test
55 public void configsToNames_extractsNames() {
56 List<UpdateConfig> configs = Arrays.asList(
57 new UpdateConfig("blah", "http://", UpdateConfig.TYPE_NON_STREAMING),
58 new UpdateConfig("blah 2", "http://", UpdateConfig.TYPE_STREAMING)
59 );
60 String[] names = UpdateConfigs.configsToNames(configs);
61 assertArrayEquals(new String[] {"blah", "blah 2"}, names);
62 }
63}