This commit is contained in:
ponzischeme89
2026-08-11 23:41:10 +12:00
parent 0e183cf560
commit 5fed3360c2
42 changed files with 1340 additions and 130 deletions
@@ -32,6 +32,14 @@ class SubtitlePreferenceTest {
assertEquals("klingon", normalizeSubtitleLanguage("Klingon"))
}
@Test
fun `subtitle labels include a country flag when the language is known`() {
assertEquals("🇮🇹 Italian", subtitleLabelWithFlag("ita", "Italian"))
assertEquals("🇬🇧 English", subtitleLabelWithFlag("en-GB", "English"))
assertEquals("🇧🇷 Português", subtitleLabelWithFlag("pt-BR", "Português"))
assertEquals("Klingon", subtitleLabelWithFlag("tlh", "Klingon"))
}
@Test
fun `subtitles turned off means nothing is selected`() {
val tracks = listOf(track("1", "eng", default = true))
@@ -16,4 +16,10 @@ class ProfileInitialsTest {
assertEquals("AL", profileInitials("alwyn"))
assertEquals("?", profileInitials(" "))
}
@Test
fun `profile destination names the signed in viewer`() {
assertEquals("Matt Cohen", profileDestinationLabel(" Matt Cohen "))
assertEquals("User", profileDestinationLabel(" "))
}
}
@@ -50,7 +50,7 @@ class UserSwitcherNavigationTest {
fun `both pinned actions are reachable below the profiles`() {
val profileCount = 3
// …the last profile, then My Alerts, then Manage users, and no further.
// …the last profile, then Notifications, then Manage users, and no further.
assertEquals(3, userSwitcherNextIndex(2, profileCount, UserSwitcherDirection.DOWN, 2))
assertEquals(4, userSwitcherNextIndex(3, profileCount, UserSwitcherDirection.DOWN, 2))
assertEquals(4, userSwitcherNextIndex(4, profileCount, UserSwitcherDirection.DOWN, 2))
@@ -31,11 +31,11 @@ class AlertsFormatTest {
}
@Test
fun `the summary counts alerts, and names the new ones only when there are some`() {
fun `the summary counts notifications, and names the new ones only when there are some`() {
assertEquals("Nothing waiting for you", alertsSummary(total = 0, unread = 0))
assertEquals("1 alert", alertsSummary(total = 1, unread = 0))
assertEquals("4 alerts", alertsSummary(total = 4, unread = 0))
assertEquals("4 alerts · 2 new", alertsSummary(total = 4, unread = 2))
assertEquals("1 alert · 1 new", alertsSummary(total = 1, unread = 1))
assertEquals("1 notification", alertsSummary(total = 1, unread = 0))
assertEquals("4 notifications", alertsSummary(total = 4, unread = 0))
assertEquals("4 notifications · 2 new", alertsSummary(total = 4, unread = 2))
assertEquals("1 notification · 1 new", alertsSummary(total = 1, unread = 1))
}
}
@@ -16,7 +16,7 @@ import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode
/**
* Renders My Alerts to PNGs under `build/screenshots/my-alerts/`, so the page can be looked
* Renders Notifications to PNGs under `build/screenshots/my-alerts/`, so the page can be looked
* at without deploying to a TV.
*
* ```powershell
@@ -0,0 +1,36 @@
package com.ponzischeme89.memby.ui.player
import com.ponzischeme89.memby.data.playback.AudioPassthroughMode
import com.ponzischeme89.memby.data.playback.AudioPassthroughPreference
import com.ponzischeme89.memby.data.playback.SurroundCodec
import org.junit.Assert.assertEquals
import org.junit.Test
class AudioPassthroughOsdTest {
@Test
fun `summary distinguishes automatic off and manual formats`() {
assertEquals("Auto", passthroughOsdSummary(AudioPassthroughPreference.AUTOMATIC))
assertEquals(
"Off",
passthroughOsdSummary(AudioPassthroughPreference(AudioPassthroughMode.MANUAL)),
)
assertEquals(
"Dolby Digital",
passthroughOsdSummary(
AudioPassthroughPreference(
AudioPassthroughMode.MANUAL,
setOf(SurroundCodec.AC3),
),
),
)
assertEquals(
"2 formats",
passthroughOsdSummary(
AudioPassthroughPreference(
AudioPassthroughMode.MANUAL,
setOf(SurroundCodec.AC3, SurroundCodec.DTS),
),
),
)
}
}
@@ -41,9 +41,9 @@ class SubtitleMenuScreenshotTest {
name = "subtitles-menu-track-selected",
tracks = listOf(
entry("Off"),
entry("English", selected = true),
entry("English · SDH"),
entry("Italian · Forced"),
entry("🇬🇧 English", selected = true),
entry("🇬🇧 English · SDH"),
entry("🇮🇹 Italian · Forced"),
),
focused = 1,
)
@@ -54,7 +54,7 @@ class SubtitleMenuScreenshotTest {
fun `subtitles off`() {
capture(
name = "subtitles-menu-off",
tracks = listOf(entry("Off", selected = true), entry("English"), entry("Français")),
tracks = listOf(entry("Off", selected = true), entry("🇬🇧 English"), entry("🇫🇷 Français")),
focused = 0,
)
}
@@ -64,7 +64,7 @@ class SubtitleMenuScreenshotTest {
fun `text size focused`() {
capture(
name = "subtitles-menu-text-size",
tracks = listOf(entry("Off"), entry("English", selected = true)),
tracks = listOf(entry("Off"), entry("🇬🇧 English", selected = true)),
focusedSize = 2,
)
}
@@ -79,14 +79,14 @@ class SubtitleMenuScreenshotTest {
name = "subtitles-menu-long-list",
tracks = listOf(
entry("Off"),
entry("English", selected = true),
entry("English · SDH"),
entry("Français"),
entry("Deutsch · Forced"),
entry("Italiano"),
entry("Español · Default"),
entry("Português (Brasil)"),
entry("Nederlands · SDH · Burned in"),
entry("🇬🇧 English", selected = true),
entry("🇬🇧 English · SDH"),
entry("🇫🇷 Français"),
entry("🇩🇪 Deutsch · Forced"),
entry("🇮🇹 Italiano"),
entry("🇪🇸 Español · Default"),
entry("🇧🇷 Português (Brasil)"),
entry("🇳🇱 Nederlands · SDH · Burned in"),
),
focused = 1,
)
@@ -101,7 +101,7 @@ class SubtitleMenuScreenshotTest {
fun `download offered with nothing suitable in the list`() {
capture(
name = "subtitles-menu-download-offered",
tracks = listOf(entry("Off", selected = true), entry("Deutsch")),
tracks = listOf(entry("Off", selected = true), entry("🇩🇪 Deutsch")),
downloads = SubtitleDownloadState(
available = true,
entries = listOf(entry("Search for subtitles…", prominent = true)),
@@ -134,16 +134,16 @@ class SubtitleMenuScreenshotTest {
fun `download results`() {
capture(
name = "subtitles-menu-download-results",
tracks = listOf(entry("Off", selected = true), entry("Deutsch")),
tracks = listOf(entry("Off", selected = true), entry("🇩🇪 Deutsch")),
downloads = SubtitleDownloadState(
available = true,
expanded = true,
entries = listOf(
entry("Search again", prominent = true),
entry("English · 98% match"),
entry("English · Hearing impaired · 96% match"),
entry("English · Forced · 91% match"),
entry("Italian · 84% match"),
entry("🇬🇧 English · 98% match"),
entry("🇬🇧 English · Hearing impaired · 96% match"),
entry("🇬🇧 English · Forced · 91% match"),
entry("🇮🇹 Italian · 84% match"),
),
),
focusedDownload = 1,
@@ -3,6 +3,7 @@ package com.ponzischeme89.memby.ui.settings
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import java.time.ZoneId
class VersionHistoryTest {
@@ -69,4 +70,19 @@ class VersionHistoryTest {
releases.map { it.version },
)
}
@Test
fun `release dates are shown day first`() {
assertEquals("11 Aug 2026", formatReleaseDate("2026-08-11"))
assertEquals("unknown", formatReleaseDate("unknown"))
}
@Test
fun `device activity is shown in local day first format`() {
assertEquals(
"11 Aug 2026, 10:05 pm",
formatDeviceLastSeen("2026-08-11T10:05:00Z", ZoneId.of("Pacific/Auckland")),
)
assertEquals("not-a-date", formatDeviceLastSeen("not-a-date", ZoneId.of("UTC")))
}
}
@@ -1,6 +1,10 @@
package com.ponzischeme89.memby.ui.whatsnew
import com.ponzischeme89.memby.ui.MEMBY_UPDATE_NOTIFICATION_ID
import com.ponzischeme89.memby.ui.membyUpdateNotification
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Test
class WhatsNewTest {
@@ -49,4 +53,14 @@ class WhatsNewTest {
assertEquals(WhatsNewDecision.Nothing, decide(installed = " "))
}
@Test
fun `an installed update becomes a local Notifications entry`() {
val alert = membyUpdateNotification("0.2.52", "2026-08-11T10:00:00Z", read = false)!!
assertEquals(MEMBY_UPDATE_NOTIFICATION_ID, alert.id)
assertEquals("Memby updated", alert.title)
assertEquals("This TV is now running Memby 0.2.52.", alert.message)
assertFalse(alert.readAt != null)
assertNull(membyUpdateNotification(" ", null, read = false))
}
}