Add a convenience method to facilitate tests
In app tests (as opposed to RoboTests), we don't have a shadow
BluetoothSettings class and can't mock it because it's final, but we
need a way to mock out the address of a CachedBluetoothDevice. So this
adds a convenience method on CachedBluetoothDevice that can be mocked.
Bug: 62447414
Test: (should be covered by other tests)
Change-Id: If818d3dcc783b4aa03f7c6d7c441ba44ea980ab7
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index e279a09..9c01dac 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -368,6 +368,15 @@
return mDevice;
}
+ /**
+ * Convenience method that can be mocked - it lets tests avoid having to call getDevice() which
+ * causes problems in tests since BluetoothDevice is final and cannot be mocked.
+ * @return the address of this device
+ */
+ public String getAddress() {
+ return mDevice.getAddress();
+ }
+
public String getName() {
return mName;
}