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 package com.android.settings.bluetooth;
17 
18 import static com.google.common.truth.Truth.assertThat;
19 
20 import static org.mockito.Mockito.when;
21 
22 import android.bluetooth.BluetoothDevice;
23 import android.net.Uri;
24 
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.Mock;
29 import org.mockito.MockitoAnnotations;
30 import org.robolectric.RobolectricTestRunner;
31 import org.robolectric.RuntimeEnvironment;
32 
33 @RunWith(RobolectricTestRunner.class)
34 public class BluetoothFeatureProviderImplTest {
35     private static final String SETTINGS_URI = "content://test.provider/settings_uri";
36     private BluetoothFeatureProvider mBluetoothFeatureProvider;
37 
38     @Mock
39     private BluetoothDevice mBluetoothDevice;
40 
41     @Before
setUp()42     public void setUp() {
43         MockitoAnnotations.initMocks(this);
44 
45         mBluetoothFeatureProvider = new BluetoothFeatureProviderImpl(
46                 RuntimeEnvironment.application);
47     }
48 
49     @Test
getBluetoothDeviceSettingsUri_containCorrectMacAddress()50     public void getBluetoothDeviceSettingsUri_containCorrectMacAddress() {
51         when(mBluetoothDevice.getMetadata(
52                 BluetoothDevice.METADATA_ENHANCED_SETTINGS_UI_URI)).thenReturn(
53                 SETTINGS_URI.getBytes());
54         final Uri uri = mBluetoothFeatureProvider.getBluetoothDeviceSettingsUri(mBluetoothDevice);
55         assertThat(uri.toString()).isEqualTo(SETTINGS_URI);
56     }
57 }
58