For mozilla-mobile#27282: delete WallpaperManager
parent
0cfa44e634
commit
adfed996a2
@ -1,33 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.wallpapers
|
||||
|
||||
import mozilla.components.support.base.log.logger.Logger
|
||||
import org.mozilla.fenix.components.AppStore
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* Provides access to available wallpapers and manages their states.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
class WallpaperManager(
|
||||
private val appStore: AppStore,
|
||||
) {
|
||||
val logger = Logger("WallpaperManager")
|
||||
|
||||
val wallpapers get() = appStore.state.wallpaperState.availableWallpapers
|
||||
val currentWallpaper: Wallpaper get() = appStore.state.wallpaperState.currentWallpaper
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Get whether the default wallpaper should be used.
|
||||
*/
|
||||
fun isDefaultTheCurrentWallpaper(settings: Settings): Boolean = with(settings.currentWallpaperName) {
|
||||
return isEmpty() || equals(defaultWallpaper.name)
|
||||
}
|
||||
|
||||
val defaultWallpaper = Wallpaper.Default
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package org.mozilla.fenix.wallpapers
|
||||
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
class WallpaperManagerTest {
|
||||
|
||||
private val mockSettings: Settings = mockk()
|
||||
|
||||
@Test
|
||||
fun `GIVEN no custom wallpaper set WHEN checking whether the current wallpaper should be default THEN return true`() {
|
||||
every { mockSettings.currentWallpaperName } returns ""
|
||||
|
||||
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
|
||||
|
||||
assertTrue(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN the default wallpaper is set to be shown WHEN checking whether the current wallpaper should be default THEN return true`() {
|
||||
every { mockSettings.currentWallpaperName } returns WallpaperManager.defaultWallpaper.name
|
||||
|
||||
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
|
||||
|
||||
assertTrue(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN a custom wallpaper is set to be shown WHEN checking whether the current wallpaper should be default THEN return false`() {
|
||||
every { mockSettings.currentWallpaperName } returns "test"
|
||||
|
||||
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue