For #27055: handle legacy wallpaper naming case

This commit is contained in:
MatthewTighe 2022-09-22 12:59:18 -07:00 committed by mergify[bot]
parent 444f663143
commit 5811b06679
2 changed files with 12 additions and 2 deletions

View File

@ -132,11 +132,14 @@ data class Wallpaper(
/**
* Check if a wallpaper name matches the default. Considers empty strings to be default
* since that likely means a wallpaper has never been set.
* since that likely means a wallpaper has never been set. The "none" case here is to deal
* with a legacy case where the default wallpaper used to be Wallpaper.NONE. See
* commit 7a44412, Wallpaper.NONE and Settings.currentWallpaper (legacy name) for context.
*
* @param name The name to check.
*/
fun nameIsDefault(name: String): Boolean = name.isEmpty() || name == defaultName
fun nameIsDefault(name: String): Boolean =
name.isEmpty() || name == defaultName || name.lowercase() == "none"
}
/**

View File

@ -25,4 +25,11 @@ class WallpaperTest {
assertFalse(result)
}
@Test
fun `GIVEN the legacy wallpaper default name none WHEN checking whether the current wallpaper should be default THEN return true`() {
val result = Wallpaper.nameIsDefault("NONE")
assertTrue(result)
}
}