Merge "Destroy tiles created in tests" into main
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
index bce4c06..3bf59ca 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DeviceControlsTileTest.kt
@@ -172,6 +172,9 @@
@Test
fun testNotAvailableControls() {
featureEnabled = false
+
+ // Destroy previous tile
+ tile.destroy()
tile = createTile()
assertThat(tile.isAvailable).isFalse()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
index a0c1073..954d30ed 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/DreamTileTest.java
@@ -226,6 +226,10 @@
assertTrue(supportedTileOnlySystemUser.isAvailable());
when(mUserTracker.getUserInfo()).thenReturn(nonMainUserInfo);
assertFalse(supportedTileOnlySystemUser.isAvailable());
+
+ destroyTile(unsupportedTile);
+ destroyTile(supportedTileAllUsers);
+ destroyTile(supportedTileOnlySystemUser);
}
@Test
@@ -250,6 +254,8 @@
mTestableLooper.processAllMessages();
assertEquals(QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_screen_saver_undocked),
dockedTile.getState().icon);
+
+ destroyTile(dockedTile);
}
private void setScreensaverEnabled(boolean enabled) {
@@ -257,6 +263,11 @@
DEFAULT_USER);
}
+ private void destroyTile(QSTileImpl<?> tile) {
+ tile.destroy();
+ mTestableLooper.processAllMessages();
+ }
+
private DreamTile constructTileForTest(boolean dreamSupported,
boolean dreamOnlyEnabledForSystemUser) {
return new DreamTile(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
index df6993d..440270b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/RotationLockTileTest.java
@@ -216,7 +216,7 @@
public void testSecondaryString_rotationResolverDisabled_isEmpty() {
mTestableResources.addOverride(com.android.internal.R.bool.config_allowRotationResolver,
false);
- mLockTile = new RotationLockTile(
+ RotationLockTile otherTile = new RotationLockTile(
mHost,
mUiEventLogger,
mTestableLooper.getLooper(),
@@ -232,10 +232,12 @@
new FakeSettings()
);
- mLockTile.refreshState();
+ otherTile.refreshState();
mTestableLooper.processAllMessages();
- assertEquals("", mLockTile.getState().secondaryLabel.toString());
+ assertEquals("", otherTile.getState().secondaryLabel.toString());
+
+ destroyTile(otherTile);
}
@Test
@@ -258,6 +260,12 @@
assertEquals(state.icon, QSTileImpl.ResourceIcon.get(R.drawable.qs_auto_rotate_icon_on));
}
+
+ private void destroyTile(QSTileImpl<?> tile) {
+ tile.destroy();
+ mTestableLooper.processAllMessages();
+ }
+
private void enableAutoRotation() {
when(mRotationPolicyWrapper.isRotationLocked()).thenReturn(false);
}