blob: 07310bd5746cf3b6dfdf612ff9bf188ae2895b90 [file] [log] [blame]
jackqdyuleic9d6a172017-09-18 18:55:41 -07001/*
2 * Copyright (C) 2017 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 */
16package com.android.settingslib.bluetooth;
17
18import static com.google.common.truth.Truth.assertThat;
19
20import android.bluetooth.BluetoothDevice;
21import android.graphics.drawable.Drawable;
22
23import com.android.settingslib.R;
24import com.android.settingslib.SettingsLibRobolectricTestRunner;
jackqdyuleic9d6a172017-09-18 18:55:41 -070025import com.android.settingslib.graph.BluetoothDeviceLayerDrawable;
jackqdyuleic9d6a172017-09-18 18:55:41 -070026
27import org.junit.Test;
28import org.junit.runner.RunWith;
29import org.robolectric.RuntimeEnvironment;
jackqdyuleic9d6a172017-09-18 18:55:41 -070030
31@RunWith(SettingsLibRobolectricTestRunner.class)
Kunhung Lie7b7cb82018-05-17 11:04:54 +080032public class BluetoothUtilsTest {
jackqdyuleic9d6a172017-09-18 18:55:41 -070033
34 @Test
35 public void testGetBluetoothDrawable_noBatteryLevel_returnSimpleDrawable() {
Kunhung Lie7b7cb82018-05-17 11:04:54 +080036 final Drawable drawable = BluetoothUtils.getBluetoothDrawable(
37 RuntimeEnvironment.application, R.drawable.ic_bt_laptop,
38 BluetoothDevice.BATTERY_LEVEL_UNKNOWN, 1 /* iconScale */);
jackqdyuleic9d6a172017-09-18 18:55:41 -070039
40 assertThat(drawable).isNotInstanceOf(BluetoothDeviceLayerDrawable.class);
41 }
42
43 @Test
44 public void testGetBluetoothDrawable_hasBatteryLevel_returnLayerDrawable() {
Kunhung Lie7b7cb82018-05-17 11:04:54 +080045 final Drawable drawable = BluetoothUtils.getBluetoothDrawable(
46 RuntimeEnvironment.application, R.drawable.ic_bt_laptop,
47 10 /* batteryLevel */, 1 /* iconScale */);
jackqdyuleic9d6a172017-09-18 18:55:41 -070048
49 assertThat(drawable).isInstanceOf(BluetoothDeviceLayerDrawable.class);
50 }
51}