Minor QS fixes
Fixes: 150940988 Test: atest QSTileHostTest Change-Id: Iae396d53d0d5eb5efe93a2c62c6540614b05c3c4
This commit is contained in:
@@ -117,7 +117,7 @@
|
||||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,dark,work,cast,night,controls,screenrecord
|
||||
wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,hotspot,inversion,saver,dark,work,cast,night,screenrecord
|
||||
</string>
|
||||
|
||||
<!-- The tiles to display in QuickSettings -->
|
||||
|
||||
@@ -274,8 +274,8 @@ public class QSTileHost implements QSHost, Tunable, PluginListener<QSFactory>, D
|
||||
try {
|
||||
tile = createTile(tileSpec);
|
||||
if (tile != null) {
|
||||
tile.setTileSpec(tileSpec);
|
||||
if (tile.isAvailable()) {
|
||||
tile.setTileSpec(tileSpec);
|
||||
newTiles.put(tileSpec, tile);
|
||||
mQSLogger.logTileAdded(tileSpec);
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,9 @@ import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -137,6 +139,8 @@ public class QSTileHostTest extends SysuiTestCase {
|
||||
return new TestTile1(mQSTileHost);
|
||||
} else if ("spec2".equals(spec)) {
|
||||
return new TestTile2(mQSTileHost);
|
||||
} else if ("na".equals(spec)) {
|
||||
return new NotAvailableTile(mQSTileHost);
|
||||
} else if (CUSTOM_TILE_SPEC.equals(spec)) {
|
||||
return mCustomTile;
|
||||
} else {
|
||||
@@ -283,6 +287,12 @@ public class QSTileHostTest extends SysuiTestCase {
|
||||
assertEquals(1, specs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotAvailableTile_specNotNull() {
|
||||
mQSTileHost.onTuningChanged(QSTileHost.TILES_SETTING, "na");
|
||||
verify(mQSLogger, never()).logTileDestroyed(isNull(), anyString());
|
||||
}
|
||||
|
||||
private static class TestQSTileHost extends QSTileHost {
|
||||
TestQSTileHost(Context context, StatusBarIconController iconController,
|
||||
QSFactoryImpl defaultFactory, Handler mainHandler, Looper bgLooper,
|
||||
@@ -369,4 +379,16 @@ public class QSTileHostTest extends SysuiTestCase {
|
||||
super(host);
|
||||
}
|
||||
}
|
||||
|
||||
private class NotAvailableTile extends TestTile {
|
||||
|
||||
protected NotAvailableTile(QSHost host) {
|
||||
super(host);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user