Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.example.android.systemupdatersample.util; |
| 18 | |
| 19 | import static org.junit.Assert.assertArrayEquals; |
| 20 | |
koushik panuganti | d5c7fb5 | 2018-12-12 10:39:44 -0800 | [diff] [blame] | 21 | import androidx.test.filters.SmallTest; |
| 22 | import androidx.test.runner.AndroidJUnit4; |
Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 23 | |
| 24 | import com.example.android.systemupdatersample.UpdateConfig; |
| 25 | |
Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 26 | import org.junit.Rule; |
| 27 | import org.junit.Test; |
| 28 | import org.junit.rules.ExpectedException; |
| 29 | import org.junit.runner.RunWith; |
| 30 | |
| 31 | import java.util.Arrays; |
| 32 | import java.util.List; |
| 33 | |
| 34 | /** |
| 35 | * Tests for {@link UpdateConfigs} |
| 36 | */ |
| 37 | @RunWith(AndroidJUnit4.class) |
| 38 | @SmallTest |
| 39 | public class UpdateConfigsTest { |
| 40 | |
Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 41 | @Rule |
| 42 | public final ExpectedException thrown = ExpectedException.none(); |
| 43 | |
Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 44 | @Test |
| 45 | public void configsToNames_extractsNames() { |
| 46 | List<UpdateConfig> configs = Arrays.asList( |
Zhomart Mukhamejanov | 963e3ee | 2018-04-26 21:07:05 -0700 | [diff] [blame] | 47 | new UpdateConfig("blah", "http://", UpdateConfig.AB_INSTALL_TYPE_NON_STREAMING), |
| 48 | new UpdateConfig("blah 2", "http://", UpdateConfig.AB_INSTALL_TYPE_STREAMING) |
Zhomart Mukhamejanov | f4d280c | 2018-04-17 13:20:22 -0700 | [diff] [blame] | 49 | ); |
| 50 | String[] names = UpdateConfigs.configsToNames(configs); |
| 51 | assertArrayEquals(new String[] {"blah", "blah 2"}, names); |
| 52 | } |
| 53 | } |