Merge "Controls UI - Do not save empty structures" into rvc-dev am: 55bd691d2b am: 99532ba1d9

Change-Id: I0cf2c23a4a9a0ca5ce05f7b4b67ec5ed9d73f5ed
This commit is contained in:
Automerger Merge Worker
2020-03-10 16:59:07 +00:00
2 changed files with 15 additions and 3 deletions

View File

@@ -493,10 +493,12 @@ private object Favorites {
updatedStructure updatedStructure
} else { s } } else { s }
structures.add(newStructure) if (!newStructure.controls.isEmpty()) {
structures.add(newStructure)
}
} }
if (!replaced) { if (!replaced && !updatedStructure.controls.isEmpty()) {
structures.add(updatedStructure) structures.add(updatedStructure)
} }

View File

@@ -521,7 +521,7 @@ class ControlsControllerImplTest : SysuiTestCase() {
} }
@Test @Test
fun testReplaceFavoritesForStructure_noFavorites() { fun testReplaceFavoritesForStructure_noExistingFavorites() {
controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO) controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO)
delayableExecutor.runAllReady() delayableExecutor.runAllReady()
@@ -530,6 +530,16 @@ class ControlsControllerImplTest : SysuiTestCase() {
controller.getFavoritesForComponent(TEST_COMPONENT)) controller.getFavoritesForComponent(TEST_COMPONENT))
} }
@Test
fun testReplaceFavoritesForStructure_doNotStoreEmptyStructure() {
controller.replaceFavoritesForStructure(
StructureInfo(TEST_COMPONENT, "Home", emptyList<ControlInfo>()))
delayableExecutor.runAllReady()
assertEquals(0, controller.countFavoritesForComponent(TEST_COMPONENT))
assertEquals(emptyList<ControlInfo>(), controller.getFavoritesForComponent(TEST_COMPONENT))
}
@Test @Test
fun testReplaceFavoritesForStructure_differentComponentsAreFilteredOut() { fun testReplaceFavoritesForStructure_differentComponentsAreFilteredOut() {
controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO) controller.replaceFavoritesForStructure(TEST_STRUCTURE_INFO)