Family v2: profiles for everyone, a four-step add, a page per person, Kids channels full screen
Settings › Family now shows everyone with Add someone; each person can be renamed, given a picture, switched between Adult and Kids, have Personalise turned off or what Orbit has learnt cleared, or be removed (their Continue watching and Taste go with them; the last grown-up stays). Kids channels open full screen with big tiles. Who's watching asks whenever more than one grown-up has a profile. 0.108.98. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
/** Family v2: anyone can be added, renamed, switched between Adult and Kids or removed, but the last grown-up stays. */
|
||||
class FamilyTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
@Test fun newPeopleGetTheirOwnIdAndKidsStartSafe() {
|
||||
val taken = DefaultProfiles.map { it.id }.toSet()
|
||||
val wife = newProfile(" Sarah Jane ", ProfileKind.Grown, "sil-pink", taken, java.util.Random(1))
|
||||
assertEquals("Sarah Jane", wife.name); assertTrue(wife.id !in taken); assertTrue(wife.channels.isEmpty())
|
||||
val child = newProfile("", ProfileKind.Kids, "ollie", taken + wife.id, java.util.Random(1))
|
||||
assertEquals("Someone", child.name); assertNotEquals(wife.id, child.id)
|
||||
assertEquals(KidsStartChannels, child.channels); assertFalse(child.driveIn)
|
||||
assertEquals(20, cleanProfileName("x".repeat(40)).length)
|
||||
}
|
||||
|
||||
@Test fun theLastGrownUpCantBeRemoved() {
|
||||
val wife = newProfile("Wife", ProfileKind.Grown, "sil-pink", emptySet())
|
||||
val all = DefaultProfiles + wife
|
||||
assertEquals(listOf("grown", "kids"), profilesWithout(all, wife.id)!!.map { it.id })
|
||||
assertNull(profilesWithout(DefaultProfiles, "grown"))
|
||||
assertEquals(listOf("grown"), profilesWithout(DefaultProfiles, "kids")!!.map { it.id })
|
||||
assertNull("unknown id changes nothing", profilesWithout(DefaultProfiles, "nobody"))
|
||||
}
|
||||
|
||||
@Test fun switchingTypeResetsWhatKidsSee() {
|
||||
val adult = newProfile("Paul", ProfileKind.Grown, "rocket", emptySet())
|
||||
val asKids = adult.asKind(ProfileKind.Kids)
|
||||
assertEquals(KidsStartChannels, asKids.channels); assertFalse(asKids.driveIn)
|
||||
assertTrue(asKids.asKind(ProfileKind.Grown).channels.isEmpty())
|
||||
// Saved and read back, every profile keeps its id, type and channels.
|
||||
val back = Profiles.decode(Profiles.encode(DefaultProfiles + adult + asKids.copy(id = "pkids2")))
|
||||
assertEquals(4, back.size); assertEquals(ProfileKind.Kids, back.last().kind); assertEquals(KidsStartChannels, back.last().channels)
|
||||
}
|
||||
|
||||
@Test fun removingSomeoneClearsTheirOwnDataOnly() {
|
||||
val dir = tmp.newFolder("schedule")
|
||||
java.io.File(dir, "continue-pwife01.json").writeText("[]"); java.io.File(dir, "continue-grown.json").writeText("[]")
|
||||
java.io.File(dir, "taste").mkdirs()
|
||||
java.io.File(dir, "taste/pwife01.events.jsonl").writeText("x"); java.io.File(dir, "taste/pwife01.state.json").writeText("{}")
|
||||
java.io.File(dir, "taste/grown.events.jsonl").writeText("y")
|
||||
forgetProfileData(dir, "pwife01")
|
||||
assertFalse(java.io.File(dir, "continue-pwife01.json").exists()); assertFalse(java.io.File(dir, "taste/pwife01.events.jsonl").exists())
|
||||
assertTrue(java.io.File(dir, "continue-grown.json").exists()); assertTrue(java.io.File(dir, "taste/grown.events.jsonl").exists())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user