def test_tc_6_1_1(self): """ Media 1 |---------| |----------------> Timer 1 |----------S (Systemaction) Timer 2 |-----------------R t |----M1---|----T1----|-----------------|-----------------> t0 t1 t2 t3 t4 t5 t6 Player play Shutdown """ # ------------ setup player ------------ player = MockPlayer() playlist = player._buildPlaylist(["Media M1"], VIDEO) player.play(playlist) player.setDefaultVolume(100) player.setVolume(80) schedulderaction = SchedulerAction(player) # ------------ setup timers ------------ # Timer 1 (T1) timer1 = Timer(1) timer1.s_label = "Timer 1" timer1.i_end_type = END_TYPE_DURATION timer1.td_duration = timedelta(minutes=self._t3 - self._t1) timer1.i_media_action = MEDIA_ACTION_START_STOP timer1.s_path = "Media T1" timer1.s_mediatype = VIDEO timer1.b_repeat = False timer1.b_resume = True timer1.i_fade = FADE_OUT_FROM_CURRENT timer1.i_vol_min = 50 timer1.i_vol_max = 100 timer1.i_system_action = SYSTEM_ACTION_SHUTDOWN_KODI timer1.b_active = False timer1.b_notify = False timer1.periods = [ Period(timedelta(minutes=self._t1), timedelta(minutes=self._t3)) ] # Timer 2 (T2) timer2 = Timer(2) timer2.s_label = "Timer 2" timer2.i_end_type = END_TYPE_DURATION timer2.td_duration = timedelta(minutes=self._t5 - self._t3) timer2.i_media_action = MEDIA_ACTION_START_STOP timer2.s_path = "Media T2" timer2.s_mediatype = VIDEO timer2.b_repeat = False timer2.b_resume = True timer2.i_fade = FADE_OFF timer2.i_vol_min = 0 timer2.i_vol_max = 100 timer2.i_system_action = SYSTEM_ACTION_NONE timer2.b_active = False timer2.b_notify = False timer2.periods = [ Period(timedelta(minutes=self._t3), timedelta(minutes=self._t5)) ] timers = [timer1, timer2] # ------------ t0 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t0)) self.assertEqual(timers[0].b_active, False) self.assertEqual(timers[1].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], "Media M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset() # ------------ t1 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t1)) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().i_timer, timers[0].i_timer) self.assertEqual( schedulderaction._getTimerToPlayAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 80) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual( player._getResumeStatus(VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual( player._getResumeStatus(VIDEO)._state.playlist[0]["file"], "Media M1") schedulderaction.reset() # ------------ t2 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t2)) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 65) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 65) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual( player._getResumeStatus(VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual( player._getResumeStatus(VIDEO)._state.playlist[0]["file"], "Media M1") schedulderaction.reset() # ------------ t3 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t3)) self.assertEqual(timers[0].b_active, False) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 1) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual( schedulderaction._getTimerToStopAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual( schedulderaction._getTimerToStopSlideshow().getTimer().i_timer, timers[0].i_timer) self.assertEqual( schedulderaction._getTimerWithSystemAction().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._volume, 100) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 100) self.assertEqual(player._getResumeStatus(AUDIO), None) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus(PICTURE), None) schedulderaction.reset()
def test_tc_5_1_2(self): """ TC 1.5.2 Single timer w/ resume and w/ former media Media 1 |---+---+---+---+---+---+---+---+---+---+----> (Audio) Timer 1 |-----+----+------R (Picture) t |----M1---|-------M1/T1-----|--------M1------> t0 t1 t2 t3 t4 Player play resume Fader 80 T1(80)-----------T1(50) """ # ------------ setup player ------------ player = MockPlayer() schedulderaction = SchedulerAction(player) playlist = player._buildPlaylist(["Audio M1"], AUDIO) player.play(playlist) player.setVolume(80) # ------------ setup timers ------------ # Timer 1 (T1) timer1 = Timer(1) timer1.s_label = "Timer 1" timer1.i_end_type = END_TYPE_DURATION timer1.td_duration = timedelta(minutes=self._t3 - self._t1) timer1.i_media_action = MEDIA_ACTION_START_STOP timer1.s_path = "Pictures T1" timer1.s_mediatype = PICTURE timer1.b_repeat = False timer1.b_resume = True timer1.i_fade = FADE_OUT_FROM_CURRENT timer1.i_vol_min = 50 timer1.i_vol_max = 100 timer1.i_system_action = SYSTEM_ACTION_NONE timer1.b_active = False timer1.b_notify = False timer1.periods = [ Period(timedelta(minutes=self._t1), timedelta(minutes=self._t3)) ] timers = [timer1] # ------------ t0 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t0)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], "Audio M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) schedulderaction.reset() # ------------ t1 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t1)) self.assertEqual(timers[0].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().s_label, timers[0].s_label) self.assertEqual( schedulderaction._getTimerToPlaySlideshow().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerToStopSlideshow(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], timers[0].s_path) self.assertNotEqual(player._getResumeStatus(PICTURE), None) self.assertEqual(player._getResumeStatus(PICTURE).getState(), None) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], "Audio M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) schedulderaction.reset() # ------------ t2 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t2)) self.assertEqual(timers[0].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().s_label, timers[0].s_label) self.assertEqual(schedulderaction._getTimerToPlaySlideshow(), None) self.assertEqual(schedulderaction._getTimerToStopSlideshow(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 65) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], timers[0].s_path) self.assertNotEqual(player._getResumeStatus(PICTURE), None) self.assertEqual(player._getResumeStatus(PICTURE).getState(), None) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], "Audio M1") self.assertEqual(player.getVolume(), 65) self.assertEqual(player._getResumeStatus(AUDIO), None) schedulderaction.reset() # ------------ t3 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t3)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 1) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlaySlideshow(), None) self.assertEqual( schedulderaction._getTimerToStopSlideshow().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, False) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], "Audio M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) schedulderaction.reset() # ------------ t4 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t3)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlaySlideshow(), None) self.assertEqual(schedulderaction._getTimerToStopSlideshow(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, False) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], "Audio M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) schedulderaction.reset()
def test_tc_1_4(self): """ TC 1.1. Single slideshow timer w/ resume but w/o former media Timer 1 |-----------------R (Slideshow) t |---------|-------T1--------|----------------> t0 t1 t2 t3 t4 Player play stop Fader 100 T1(100)-----------T1(50) """ # ------------ setup player ------------d player = MockPlayer() schedulderaction = SchedulerAction(player) player.setVolume(100) # ------------ setup timers ------------ # Timer 1 (T1) timer1 = Timer(1) timer1.s_label = "Timer 1" timer1.i_end_type = END_TYPE_DURATION timer1.td_duration = timedelta(minutes=self._t3 - self._t1) timer1.i_media_action = MEDIA_ACTION_START_STOP timer1.s_path = "Slideshow T1" timer1.s_mediatype = PICTURE timer1.b_repeat = False timer1.b_resume = True timer1.i_fade = FADE_OUT_FROM_CURRENT timer1.i_vol_min = 50 timer1.i_vol_max = 100 timer1.i_system_action = SYSTEM_ACTION_NONE timer1.b_active = False timer1.b_notify = False timer1.periods = [ Period(timedelta(minutes=self._t1), timedelta(minutes=self._t3)) ] timers = [timer1] # ------------ t0 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t0)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToPlaySlideshow(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerToStopSlideshow(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player._getResumeStatus(PICTURE), None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset() # ------------ t1 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t1)) self.assertEqual(timers[0].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().s_label, timers[0].s_label) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual( schedulderaction._getTimerToPlaySlideshow().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 100) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], timers[0].s_path) self.assertNotEqual(player._getResumeStatus(PICTURE), None) self.assertEqual( player._getResumeStatus(PICTURE)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(PICTURE)._state, None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset() # ------------ t2 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t2)) self.assertEqual(timers[0].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer().s_label, timers[0].s_label) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 75) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], timers[0].s_path) self.assertNotEqual(player._getResumeStatus(PICTURE), None) self.assertEqual( player._getResumeStatus(PICTURE)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(PICTURE)._state, None) self.assertEqual(player.getVolume(), 75) schedulderaction.reset() # ------------ t3 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t3)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 1) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual( schedulderaction._getTimerToStopSlideshow().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 100) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 100) self.assertEqual(player._getResumeStatus(AUDIO), None) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus(PICTURE), None) schedulderaction.reset() # ------------ t4 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t4)) self.assertEqual(timers[0].b_active, False) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 0) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player._getResumeStatus(PICTURE), None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset()