Add schedule sync and schedule-aware playback

This commit is contained in:
NeilClack
2026-09-11 19:14:55 -05:00
parent a043ec84d8
commit f37beaf07e
23 changed files with 893 additions and 32 deletions
+48
View File
@@ -347,6 +347,54 @@ TEST(DatabaseManagerTest, SyncAudioFilesClearsEverythingWhenEmpty) {
EXPECT_EQ(fx.db.getAudioFiles().size(), 0u);
}
TEST(DatabaseManagerTest, ReplaceAndReadScheduleBlocks) {
DbFixture fx("test_rw_db_schedule.db");
ScheduleBlockRecord morning;
morning.id = "b1";
morning.start_minutes = 360;
morning.end_minutes = 480;
morning.overnight = false;
morning.duration_minutes = 120;
morning.dynamic_audio = false;
morning.proclamation_ids = {"p2", "p1"};
ScheduleBlockRecord night;
night.id = "b2";
night.start_minutes = 1260;
night.end_minutes = 540;
night.overnight = true;
night.duration_minutes = 720;
night.dynamic_audio = true;
night.proclamation_ids = {"p3"};
ASSERT_TRUE(fx.db.replaceScheduleBlocks({morning, night}));
auto rows = fx.db.getScheduleBlocks();
ASSERT_EQ(rows.size(), 2u);
EXPECT_EQ(rows[0].id, "b1");
EXPECT_EQ(rows[0].start_minutes, 360);
EXPECT_EQ(rows[0].end_minutes, 480);
EXPECT_FALSE(rows[0].overnight);
EXPECT_EQ(rows[0].duration_minutes, 120);
EXPECT_FALSE(rows[0].dynamic_audio);
// Play order is preserved, not sorted.
ASSERT_EQ(rows[0].proclamation_ids.size(), 2u);
EXPECT_EQ(rows[0].proclamation_ids[0], "p2");
EXPECT_EQ(rows[0].proclamation_ids[1], "p1");
EXPECT_EQ(rows[1].id, "b2");
EXPECT_TRUE(rows[1].overnight);
EXPECT_TRUE(rows[1].dynamic_audio);
ASSERT_EQ(rows[1].proclamation_ids.size(), 1u);
EXPECT_EQ(rows[1].proclamation_ids[0], "p3");
// A re-sync replaces the whole schedule.
ASSERT_TRUE(fx.db.replaceScheduleBlocks({}));
EXPECT_EQ(fx.db.getScheduleBlocks().size(), 0u);
}
TEST(DatabaseManagerTest, PalettesSeededAndRead) {
DbFixture fx("test_rw_db_palette.db");