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