Loading tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java +8 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.settings.password; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.RuntimeEnvironment.application; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.view.View; Loading @@ -37,7 +36,6 @@ import com.android.settings.testutils.shadow.ShadowUtils; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Shadows; Loading @@ -45,12 +43,13 @@ import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadows.ShadowActivity; import org.robolectric.shadows.ShadowAlertDialog; import org.robolectric.shadows.ShadowDialog; import java.util.Collections; import java.util.List; import androidx.appcompat.app.AlertDialog; @RunWith(SettingsRobolectricTestRunner.class) @Config(shadows = { SettingsShadowResources.class, Loading Loading @@ -82,7 +81,6 @@ public class SetupChooseLockPasswordTest { } @Test @Ignore("b/111194289") public void createActivity_withShowOptionsButtonExtra_shouldShowButton() { SetupChooseLockPassword activity = createSetupChooseLockPassword(); Button optionsButton = activity.findViewById(R.id.screen_lock_options); Loading @@ -101,12 +99,11 @@ public class SetupChooseLockPasswordTest { } @Test @Ignore("b/111194289") public void allSecurityOptions_shouldBeShown_When_OptionsButtonIsClicked() { SetupChooseLockPassword activity = createSetupChooseLockPassword(); activity.findViewById(R.id.screen_lock_options).performClick(); AlertDialog latestAlertDialog = ShadowAlertDialog.getLatestAlertDialog(); int count = Shadows.shadowOf(latestAlertDialog).getAdapter().getCount(); AlertDialog latestAlertDialog = (AlertDialog) ShadowDialog.getLatestDialog(); int count = latestAlertDialog.getListView().getCount(); assertThat(count).named("List items shown").isEqualTo(3); } Loading tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public class SettingsShadowResourcesImpl extends ShadowResourcesImpl { // The drawable item in switchbar_background.xml refers to a very recent color attribute // that Robolectric isn't yet aware of. // TODO: Remove this once Robolectric is updated. if (id == R.drawable.switchbar_background) { if (id == R.drawable.switchbar_background || id == R.color.ripple_material_light) { return new ColorDrawable(); } else if (id == R.drawable.ic_launcher_settings) { // ic_launcher_settings uses adaptive-icon, which is not supported by robolectric, Loading @@ -56,6 +57,7 @@ public class SettingsShadowResourcesImpl extends ShadowResourcesImpl { // progress_horizontal drawable id = android.R.drawable.progress_horizontal; } return super.loadDrawable(wrapper, value, id, density, theme); } } Loading
tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java +8 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.settings.password; import static com.google.common.truth.Truth.assertThat; import static org.robolectric.RuntimeEnvironment.application; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.view.View; Loading @@ -37,7 +36,6 @@ import com.android.settings.testutils.shadow.ShadowUtils; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Shadows; Loading @@ -45,12 +43,13 @@ import org.robolectric.annotation.Config; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; import org.robolectric.shadows.ShadowActivity; import org.robolectric.shadows.ShadowAlertDialog; import org.robolectric.shadows.ShadowDialog; import java.util.Collections; import java.util.List; import androidx.appcompat.app.AlertDialog; @RunWith(SettingsRobolectricTestRunner.class) @Config(shadows = { SettingsShadowResources.class, Loading Loading @@ -82,7 +81,6 @@ public class SetupChooseLockPasswordTest { } @Test @Ignore("b/111194289") public void createActivity_withShowOptionsButtonExtra_shouldShowButton() { SetupChooseLockPassword activity = createSetupChooseLockPassword(); Button optionsButton = activity.findViewById(R.id.screen_lock_options); Loading @@ -101,12 +99,11 @@ public class SetupChooseLockPasswordTest { } @Test @Ignore("b/111194289") public void allSecurityOptions_shouldBeShown_When_OptionsButtonIsClicked() { SetupChooseLockPassword activity = createSetupChooseLockPassword(); activity.findViewById(R.id.screen_lock_options).performClick(); AlertDialog latestAlertDialog = ShadowAlertDialog.getLatestAlertDialog(); int count = Shadows.shadowOf(latestAlertDialog).getAdapter().getCount(); AlertDialog latestAlertDialog = (AlertDialog) ShadowDialog.getLatestDialog(); int count = latestAlertDialog.getListView().getCount(); assertThat(count).named("List items shown").isEqualTo(3); } Loading
tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResourcesImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public class SettingsShadowResourcesImpl extends ShadowResourcesImpl { // The drawable item in switchbar_background.xml refers to a very recent color attribute // that Robolectric isn't yet aware of. // TODO: Remove this once Robolectric is updated. if (id == R.drawable.switchbar_background) { if (id == R.drawable.switchbar_background || id == R.color.ripple_material_light) { return new ColorDrawable(); } else if (id == R.drawable.ic_launcher_settings) { // ic_launcher_settings uses adaptive-icon, which is not supported by robolectric, Loading @@ -56,6 +57,7 @@ public class SettingsShadowResourcesImpl extends ShadowResourcesImpl { // progress_horizontal drawable id = android.R.drawable.progress_horizontal; } return super.loadDrawable(wrapper, value, id, density, theme); } }