From 8bacd261163a772b7f4017cfa5b1e73e86c3a1f0 Mon Sep 17 00:00:00 2001 From: MatthewTighe Date: Thu, 22 Sep 2022 12:59:18 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/27055: handle legacy wallpaper naming case --- .../main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt | 7 +++++-- .../java/org/mozilla/fenix/wallpapers/WallpaperTest.kt | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt index 0b635d62b3..d53c1478fb 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt @@ -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" } /** diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperTest.kt index 142474fd32..2dc0464872 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperTest.kt @@ -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) + } }