Bluetooth: add metrics for pairing with devices without names am: 5b017f7b05

am: d9de1ecc03

Change-Id: I34a61269d955ffd9aa073aa1c514c3f3e148adbc
This commit is contained in:
Jack He
2017-09-07 23:54:21 +00:00
committed by android-build-merger
2 changed files with 28 additions and 4 deletions

View File

@@ -42,6 +42,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -98,11 +99,29 @@ public class BluetoothDevicePreferenceTest {
when(mCachedBluetoothDevice.isConnected()).thenReturn(false);
when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
when(mCachedBluetoothDevice.startPairing()).thenReturn(true);
when(mCachedBluetoothDevice.hasHumanReadableName()).thenReturn(true);
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
verify(mMetricsFeatureProvider, never()).action(mContext,
MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
}
@Test
public void onClicked_deviceNotBonded_shouldLogBluetoothPairEventAndPairWithoutNameEvent() {
when(mCachedBluetoothDevice.isConnected()).thenReturn(false);
when(mCachedBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_NONE);
when(mCachedBluetoothDevice.startPairing()).thenReturn(true);
when(mCachedBluetoothDevice.hasHumanReadableName()).thenReturn(false);
mPreference.onClicked();
verify(mMetricsFeatureProvider).action(
mContext, MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR);
verify(mMetricsFeatureProvider).action(mContext,
MetricsEvent.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
}
@Test