Loading src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java +2 −3 Original line number Diff line number Diff line Loading @@ -53,12 +53,11 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController protected void setHeaderProperties() { Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription (mContext.getResources(), mCachedDevice); int summaryResourceId = mCachedDevice.getConnectionSummary(); String summaryText = mCachedDevice.getConnectionSummary(); mHeaderController.setLabel(mCachedDevice.getName()); mHeaderController.setIcon(mContext.getDrawable(pair.first)); mHeaderController.setIconContentDescription(pair.second); mHeaderController.setSummary( summaryResourceId > 0 ? mContext.getString(summaryResourceId) : null); mHeaderController.setSummary(summaryText); } @Override Loading src/com/android/settings/bluetooth/BluetoothDevicePreference.java +2 −8 Original line number Diff line number Diff line Loading @@ -117,14 +117,8 @@ public final class BluetoothDevicePreference extends GearPreference implements * any preference info has changed from the previous value. */ setTitle(mCachedDevice.getName()); int summaryResId = mCachedDevice.getConnectionSummary(); if (summaryResId != 0) { setSummary(summaryResId); } else { setSummary(null); // empty summary for unpaired devices } // Null check is done at the framework setSummary(mCachedDevice.getConnectionSummary()); Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription(mResources, mCachedDevice); Loading tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java +6 −6 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public class BluetoothDetailsControllerTestBase { private String address; private int majorDeviceClass; private boolean connected; private int connectionSummary; private String connectionSummary; public DeviceConfig setName(String newValue) { this.name = newValue; Loading @@ -97,8 +97,8 @@ public class BluetoothDetailsControllerTestBase { this.connected = newValue; return this; } public DeviceConfig setConnectionSummary(int newValue) { this.connectionSummary = newValue; public DeviceConfig setConnectionSummary(String connectionSummary) { this.connectionSummary = connectionSummary; return this; } Loading @@ -118,18 +118,18 @@ public class BluetoothDetailsControllerTestBase { return connected; } public int getConnectionSummary() { public String getConnectionSummary() { return connectionSummary; } } protected static DeviceConfig makeDefaultDeviceConfig() { protected DeviceConfig makeDefaultDeviceConfig() { return new DeviceConfig() .setName("Mock Device") .setAddress("B4:B0:34:B5:3B:1B") .setMajorDeviceClass(BluetoothClass.Device.Major.AUDIO_VIDEO) .setConnected(true) .setConnectionSummary(R.string.bluetooth_connected); .setConnectionSummary(mContext.getString(R.string.bluetooth_connected)); } /** Loading tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java +18 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.bluetooth; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.spy; Loading @@ -23,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.graphics.drawable.Drawable; import android.support.v7.preference.Preference; import com.android.settings.R; import com.android.settings.applications.LayoutPreference; Loading @@ -33,7 +34,6 @@ import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.SettingsShadowBluetoothDevice; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import org.junit.After; import org.junit.Test; Loading @@ -43,8 +43,6 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.robolectric.annotation.Config; import java.util.ArrayList; @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows={SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class}) Loading Loading @@ -73,6 +71,15 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro ShadowEntityHeaderController.reset(); } /** * Test to verify the current test context object works so that we are not checking null * against null */ @Test public void testContextMock() { assertThat(mContext.getString(R.string.bluetooth_connected)).isEqualTo("Connected"); } @Test public void header() { showScreen(mController); Loading @@ -86,17 +93,19 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro @Test public void connectionStatusChangesWhileScreenOpen() { ArrayList<LocalBluetoothProfile> profiles = new ArrayList<>(); InOrder inOrder = inOrder(mHeaderController); when(mCachedDevice.getConnectionSummary()).thenReturn(R.string.bluetooth_connected); when(mCachedDevice.getConnectionSummary()).thenReturn( mContext.getString(R.string.bluetooth_connected)); showScreen(mController); inOrder.verify(mHeaderController).setSummary(mContext.getString(R.string.bluetooth_connected)); inOrder.verify(mHeaderController).setSummary( mContext.getString(R.string.bluetooth_connected)); when(mCachedDevice.getConnectionSummary()).thenReturn(0); when(mCachedDevice.getConnectionSummary()).thenReturn(null); mController.onDeviceAttributesChanged(); inOrder.verify(mHeaderController).setSummary((CharSequence) null); when(mCachedDevice.getConnectionSummary()).thenReturn(R.string.bluetooth_connecting); when(mCachedDevice.getConnectionSummary()).thenReturn( mContext.getString(R.string.bluetooth_connecting)); mController.onDeviceAttributesChanged(); inOrder.verify(mHeaderController).setSummary( mContext.getString(R.string.bluetooth_connecting)); Loading tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont @Test public void disconnectedDeviceOneProfile() { setupDevice(makeDefaultDeviceConfig().setConnected(false).setConnectionSummary(0)); setupDevice(makeDefaultDeviceConfig().setConnected(false).setConnectionSummary(null)); addFakeProfile(R.string.bluetooth_profile_a2dp, true); showScreen(mController); verifyProfileSwitchTitles(getProfileSwitches(true)); Loading Loading
src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java +2 −3 Original line number Diff line number Diff line Loading @@ -53,12 +53,11 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController protected void setHeaderProperties() { Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription (mContext.getResources(), mCachedDevice); int summaryResourceId = mCachedDevice.getConnectionSummary(); String summaryText = mCachedDevice.getConnectionSummary(); mHeaderController.setLabel(mCachedDevice.getName()); mHeaderController.setIcon(mContext.getDrawable(pair.first)); mHeaderController.setIconContentDescription(pair.second); mHeaderController.setSummary( summaryResourceId > 0 ? mContext.getString(summaryResourceId) : null); mHeaderController.setSummary(summaryText); } @Override Loading
src/com/android/settings/bluetooth/BluetoothDevicePreference.java +2 −8 Original line number Diff line number Diff line Loading @@ -117,14 +117,8 @@ public final class BluetoothDevicePreference extends GearPreference implements * any preference info has changed from the previous value. */ setTitle(mCachedDevice.getName()); int summaryResId = mCachedDevice.getConnectionSummary(); if (summaryResId != 0) { setSummary(summaryResId); } else { setSummary(null); // empty summary for unpaired devices } // Null check is done at the framework setSummary(mCachedDevice.getConnectionSummary()); Pair<Integer, String> pair = Utils.getBtClassDrawableWithDescription(mResources, mCachedDevice); Loading
tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsControllerTestBase.java +6 −6 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public class BluetoothDetailsControllerTestBase { private String address; private int majorDeviceClass; private boolean connected; private int connectionSummary; private String connectionSummary; public DeviceConfig setName(String newValue) { this.name = newValue; Loading @@ -97,8 +97,8 @@ public class BluetoothDetailsControllerTestBase { this.connected = newValue; return this; } public DeviceConfig setConnectionSummary(int newValue) { this.connectionSummary = newValue; public DeviceConfig setConnectionSummary(String connectionSummary) { this.connectionSummary = connectionSummary; return this; } Loading @@ -118,18 +118,18 @@ public class BluetoothDetailsControllerTestBase { return connected; } public int getConnectionSummary() { public String getConnectionSummary() { return connectionSummary; } } protected static DeviceConfig makeDefaultDeviceConfig() { protected DeviceConfig makeDefaultDeviceConfig() { return new DeviceConfig() .setName("Mock Device") .setAddress("B4:B0:34:B5:3B:1B") .setMajorDeviceClass(BluetoothClass.Device.Major.AUDIO_VIDEO) .setConnected(true) .setConnectionSummary(R.string.bluetooth_connected); .setConnectionSummary(mContext.getString(R.string.bluetooth_connected)); } /** Loading
tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java +18 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.settings.bluetooth; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.spy; Loading @@ -23,7 +25,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.graphics.drawable.Drawable; import android.support.v7.preference.Preference; import com.android.settings.R; import com.android.settings.applications.LayoutPreference; Loading @@ -33,7 +34,6 @@ import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.shadow.SettingsShadowBluetoothDevice; import com.android.settings.testutils.shadow.ShadowEntityHeaderController; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.bluetooth.LocalBluetoothProfile; import org.junit.After; import org.junit.Test; Loading @@ -43,8 +43,6 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.robolectric.annotation.Config; import java.util.ArrayList; @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows={SettingsShadowBluetoothDevice.class, ShadowEntityHeaderController.class}) Loading Loading @@ -73,6 +71,15 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro ShadowEntityHeaderController.reset(); } /** * Test to verify the current test context object works so that we are not checking null * against null */ @Test public void testContextMock() { assertThat(mContext.getString(R.string.bluetooth_connected)).isEqualTo("Connected"); } @Test public void header() { showScreen(mController); Loading @@ -86,17 +93,19 @@ public class BluetoothDetailsHeaderControllerTest extends BluetoothDetailsContro @Test public void connectionStatusChangesWhileScreenOpen() { ArrayList<LocalBluetoothProfile> profiles = new ArrayList<>(); InOrder inOrder = inOrder(mHeaderController); when(mCachedDevice.getConnectionSummary()).thenReturn(R.string.bluetooth_connected); when(mCachedDevice.getConnectionSummary()).thenReturn( mContext.getString(R.string.bluetooth_connected)); showScreen(mController); inOrder.verify(mHeaderController).setSummary(mContext.getString(R.string.bluetooth_connected)); inOrder.verify(mHeaderController).setSummary( mContext.getString(R.string.bluetooth_connected)); when(mCachedDevice.getConnectionSummary()).thenReturn(0); when(mCachedDevice.getConnectionSummary()).thenReturn(null); mController.onDeviceAttributesChanged(); inOrder.verify(mHeaderController).setSummary((CharSequence) null); when(mCachedDevice.getConnectionSummary()).thenReturn(R.string.bluetooth_connecting); when(mCachedDevice.getConnectionSummary()).thenReturn( mContext.getString(R.string.bluetooth_connecting)); mController.onDeviceAttributesChanged(); inOrder.verify(mHeaderController).setSummary( mContext.getString(R.string.bluetooth_connecting)); Loading
tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsProfilesControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont @Test public void disconnectedDeviceOneProfile() { setupDevice(makeDefaultDeviceConfig().setConnected(false).setConnectionSummary(0)); setupDevice(makeDefaultDeviceConfig().setConnected(false).setConnectionSummary(null)); addFakeProfile(R.string.bluetooth_profile_a2dp, true); showScreen(mController); verifyProfileSwitchTitles(getProfileSwitches(true)); Loading