• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.android.settings.development;
18 
19 import android.content.Context;
20 
21 import androidx.test.InstrumentationRegistry;
22 import androidx.test.filters.SmallTest;
23 import androidx.test.runner.AndroidJUnit4;
24 
25 import com.android.settings.R;
26 
27 import org.hamcrest.CoreMatchers;
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 
33 import java.util.Arrays;
34 
35 @RunWith(AndroidJUnit4.class)
36 @SmallTest
37 public class BluetoothMaxConnectedAudioDevicesPreferenceControllerInstrumentationTest {
38 
39     private Context mTargetContext;
40     private String[] mListValues;
41     private String[] mListEntries;
42     private String mDefaultMaxConnectedAudioDevices;
43 
44     @Before
setUp()45     public void setUp() throws Exception {
46         mTargetContext = InstrumentationRegistry.getTargetContext();
47         // Get XML values without mock
48         mListValues = mTargetContext.getResources()
49                 .getStringArray(R.array.bluetooth_max_connected_audio_devices_values);
50         mListEntries = mTargetContext.getResources()
51                 .getStringArray(R.array.bluetooth_max_connected_audio_devices);
52         mDefaultMaxConnectedAudioDevices = String.valueOf(mTargetContext.getResources()
53                 .getInteger(
54                         com.android.internal.R.integer
55                                 .config_bluetooth_max_connected_audio_devices));
56     }
57 
58     @Test
verifyResource()59     public void verifyResource() {
60         // Verify normal list entries and default preference entries have the same size
61         Assert.assertEquals(mListEntries.length, mListValues.length);
62         Assert.assertThat(Arrays.asList(mListValues),
63                 CoreMatchers.hasItem(mDefaultMaxConnectedAudioDevices));
64     }
65 }
66