Fix build failed of Settings test cases while importing AndroidX

- API change in AndroidX Preference causes a build breakage
- Apply explicit casting for the new API interface

Test: robotest
Fixes: 121109361
Change-Id: If3e7be9e53c7860252523700d6721ae4956db68a
This commit is contained in:
Jason Chiu
2018-12-17 15:56:56 +08:00
parent 6c403a876d
commit 7aa7ece7a2
5 changed files with 15 additions and 10 deletions

View File

@@ -119,7 +119,8 @@ public class AvailableMediaDeviceGroupControllerTest {
mAvailableMediaDeviceGroupController.onDeviceAdded(mPreference);
assertThat(mPreferenceGroup.isVisible()).isTrue();
assertThat(mPreferenceGroup.findPreference(PREFERENCE_KEY_1)).isEqualTo(mPreference);
assertThat((Preference) mPreferenceGroup.findPreference(PREFERENCE_KEY_1))
.isEqualTo(mPreference);
}
@Test

View File

@@ -100,7 +100,8 @@ public class ConnectedDeviceGroupControllerTest {
mConnectedDeviceGroupController.onDeviceAdded(mPreference);
assertThat(mPreferenceGroup.isVisible()).isTrue();
assertThat(mPreferenceGroup.findPreference(PREFERENCE_KEY_1)).isEqualTo(mPreference);
assertThat((Preference) mPreferenceGroup.findPreference(PREFERENCE_KEY_1))
.isEqualTo(mPreference);
}
@Test

View File

@@ -29,6 +29,7 @@ import android.hardware.usb.UsbPort;
import android.os.Handler;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -122,8 +123,8 @@ public class UsbDetailsPowerRoleControllerTest {
UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE);
assertThat(mPreference.isEnabled()).isFalse();
assertThat(mScreen.findPreference(mDetailsPowerRoleController.getPreferenceKey()))
.isEqualTo(mPreference);
assertThat((Preference) mScreen.findPreference(
mDetailsPowerRoleController.getPreferenceKey())).isEqualTo(mPreference);
}
@Test
@@ -134,7 +135,8 @@ public class UsbDetailsPowerRoleControllerTest {
mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK,
UsbPort.DATA_ROLE_DEVICE);
assertThat(mScreen.findPreference(mDetailsPowerRoleController.getPreferenceKey())).isNull();
assertThat((Preference) mScreen.findPreference(
mDetailsPowerRoleController.getPreferenceKey())).isNull();
}
@Test