def test_tc_5_1_1(self): """ TC 1.5.1 Single timer w/ resume and w/ former media Media 1 |---+---+---+---+---+---+---+---+---+---+----> (Picture) Timer 1 |-----+----+------R (Audio) t |----M1---|-------M1/T1-----|--------M1------> t0 t1 t2 t3 t4 Player play resume Fader 100 T1(50)-----------T1(100) """ # ------------ setup player ------------ player = MockPlayer() schedulderaction = SchedulerAction(player) playlist = player._buildPlaylist(["Pictures"], PICTURE) player.play(playlist) 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 = "Audio T1" timer1.s_mediatype = AUDIO timer1.b_repeat = False timer1.b_resume = True timer1.i_fade = FADE_IN_FROM_MIN 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(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], "Pictures") self.assertEqual(player.getVolume(), 100) self.assertEqual(player._getResumeStatus(PICTURE), 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._getTimerToPlayAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 50) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], "Pictures") self.assertEqual(player._getResumeStatus(PICTURE), None) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 50) self.assertNotEqual(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._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 75) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], "Pictures") self.assertEqual(player._getResumeStatus(PICTURE), None) # Audio self.assertEqual(AUDIO in apwpl, True) self.assertEqual(apwpl[AUDIO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 75) self.assertNotEqual(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._getTimerToPlayAV(), None) self.assertEqual( schedulderaction._getTimerToStopAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 100) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], "Pictures") self.assertEqual(player._getResumeStatus(PICTURE), None) # Audio self.assertEqual(AUDIO in apwpl, False) self.assertEqual(player.getVolume(), 100) 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() # Picture self.assertEqual(PICTURE in apwpl, True) self.assertEqual(apwpl[PICTURE].playlist[0]["file"], "Pictures") self.assertEqual(player._getResumeStatus(PICTURE), None) # Audio self.assertEqual(AUDIO in apwpl, False) self.assertEqual(player.getVolume(), 100) schedulderaction.reset()
def test_tc_4_2(self): """ Media 1 |---------| |----------------> Timer 1 |-------------------------R Timer 2 |------R t |----M1---|--T1--|--T2--|---T1------|------M1--------> t0 t1 t2 t3 t4 t5 t6 t7 t8 Player play play resume resume """ # ------------ setup player ------------ player = MockPlayer() player.setSeekDelayedTimer(True) playlist = player._buildPlaylist(["Media M1"], VIDEO) player.play(playlist) player.setDefaultVolume(100) player.setShuffled(True) player.setRepeat(REPEAT_ALL) 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._t7 - self._t1) timer1.i_media_action = MEDIA_ACTION_START_STOP timer1.s_path = "Media T1.1 (0:45)|Media T1.2 (1:55)|Media T1.3 (0:55)|Media T1.4 (1:13)|Media T1.5 (2:39)" timer1.s_mediatype = VIDEO timer1.b_repeat = False timer1.b_shuffle = False timer1.b_resume = True timer1.i_fade = FADE_IN_FROM_MIN timer1.i_vol_min = 30 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._t7)) ] # 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 = True timer2.b_shuffle = True timer2.b_resume = True timer2.i_fade = FADE_OUT_FROM_MAX 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) self.assertEqual(apwpl[VIDEO].shuffled, True) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_ALL) schedulderaction.reset() # ------------ t1 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t1)) player._td_now = 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(), timer1) 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, 30) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path.split("|")[0]) self.assertEqual(player.getVolume(), 30) 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") self.assertEqual(apwpl[VIDEO].shuffled, False) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_OFF) schedulderaction.reset() # ------------ t2 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t2)) player._td_now = 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(), timer1) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 41) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path.split("|")[0]) self.assertEqual(player.getVolume(), 41) 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") self.assertEqual(apwpl[VIDEO].shuffled, False) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_OFF) schedulderaction.reset() # ------------ t3 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t3)) player._td_now = timedelta(minutes=self._t3) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer(), timer1) self.assertEqual( schedulderaction._getTimerToPlayAV().getTimer().i_timer, timers[1].i_timer) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 53) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[1].s_path) self.assertEqual(player.getVolume(), 53) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual( player._getResumeStatus(VIDEO)._timer.i_timer, timers[1].i_timer) self.assertEqual( player._getResumeStatus(VIDEO)._state.playlist[0]["file"], "Media M1") self.assertEqual(apwpl[VIDEO].shuffled, True) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_ALL) schedulderaction.reset() # ------------ t4 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t4)) player._td_now = timedelta(minutes=self._t4) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 2) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader().getTimer(), timer1) 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[1].s_path) self.assertEqual(player.getVolume(), 65) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual( player._getResumeStatus(VIDEO)._timer.i_timer, timers[1].i_timer) self.assertEqual( player._getResumeStatus(VIDEO)._state.playlist[0]["file"], "Media M1") self.assertEqual(apwpl[VIDEO].shuffled, True) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_ALL) schedulderaction.reset() # ------------ t5 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t5)) player._td_now = timedelta(minutes=self._t5) 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()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 1) self.assertEqual(schedulderaction._getFader().getTimer(), timer1) 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, 76) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].position, 3) self.assertEqual(apwpl[VIDEO].time, 1500) self.assertEqual(apwpl[VIDEO].playlist[3]["file"], timers[0].s_path.split("|")[3]) self.assertEqual(player.getVolume(), 76) 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") self.assertEqual(apwpl[VIDEO].shuffled, False) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_OFF) schedulderaction.reset() # ------------ t6 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t6)) player._td_now = timedelta(minutes=self._t6) 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(), timer1) self.assertEqual(schedulderaction._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 88) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[3]["file"], timers[0].s_path.split("|")[3]) self.assertEqual(player.getVolume(), 88) 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") self.assertEqual(apwpl[VIDEO].shuffled, False) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_OFF) schedulderaction.reset() # ------------ t7 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t7)) player._td_now = timedelta(minutes=self._t7) 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()), 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._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"], "Media M1") self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(apwpl[VIDEO].shuffled, True) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_ALL) schedulderaction.reset() # ------------ t8 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t8)) player._td_now = timedelta(minutes=self._t8) 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) self.assertEqual(apwpl[VIDEO].shuffled, True) self.assertEqual(apwpl[VIDEO].repeat, REPEAT_ALL) schedulderaction.reset()
def test_tc_1_3(self): """ TC 1.3. Single timer w/o resume and w/ former media Media 1 |---------| (tested w/ PVR and Playlist) Timer 1 |-----------------X (tested w/ PVR and Playlist) t |----M1---|-------T1--------|----------------> t0 t1 t2 t3 t4 Player play stop Fader 80 T1(=)-----------T1(40) """ # ------------ setup player ------------ player = MockPlayer() playlist = player._buildPlaylist(["Media M1"], VIDEO) player.play(playlist) 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 = False timer1.i_fade = FADE_OUT_FROM_CURRENT timer1.i_vol_min = 40 timer1.i_vol_max = None 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(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(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().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(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), 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._getTimerToPlayAV(), None) self.assertEqual(schedulderaction._getTimerToStopAV(), None) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(player.getVolume(), 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(apwpl[VIDEO].playlist[0]["file"], timers[0].s_path) self.assertEqual(player.getVolume(), 60) self.assertEqual(player._getResumeStatus(VIDEO), 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._getTimerToPlayAV(), None) self.assertEqual( schedulderaction._getTimerToStopAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 80) 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.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset()
def test_tc_6_1_3(self): """ Media 1 |---------| Timer 1 |------------------X Timer 2 X-----------------S t |----M1---|----T1----|-----------------|----------------> t0 t1 t2 t3 t4 t5 t6 t7 t8 Player play stop play """ # ------------ setup player ------------ player = MockPlayer() playlist = player._buildPlaylist(["Media M1"], VIDEO) player.setVolume(80) player.play(playlist) 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._t5 - 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_NONE timer1.b_active = False timer1.b_notify = False timer1.periods = [ Period(timedelta(minutes=self._t1), timedelta(minutes=self._t5)) ] # Timer 2 (T2) timer2 = Timer(2) timer2.s_label = "Timer 2" timer2.i_end_type = END_TYPE_DURATION timer2.td_duration = timedelta(minutes=self._t7 - self._t3) timer2.i_media_action = MEDIA_ACTION_STOP_START 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._t7)) ] 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, 72) 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(), 72) 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, True) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) 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().getTimer().i_timer, timers[1].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 65) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 65) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset() # ------------ t4 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t4)) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].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().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, 57) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 57) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset() # ------------ t5 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t5)) self.assertEqual(timers[0].b_active, False) self.assertEqual(timers[1].b_active, True) 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._getTimerToStopAV().getTimer().i_timer, timers[0].i_timer) self.assertEqual(schedulderaction._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, 80) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset() # ------------ t6 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t6)) self.assertEqual(timers[0].b_active, False) self.assertEqual(timers[1].b_active, True) 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.getVolume(), 80) self.assertEqual(player._getResumeStatus(VIDEO), None) schedulderaction.reset() # ------------ t7 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t7)) 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()), 1) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual( schedulderaction._getTimerToPlayAV().getTimer().i_timer, timers[1].i_timer) 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"], timers[1].s_path) self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus(PICTURE), None) schedulderaction.reset() # ------------ t8 ------------ schedulderaction.initFromTimers(timers, timedelta(minutes=self._t8)) 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"], timers[1].s_path) self.assertEqual(player.getVolume(), 80) self.assertEqual(player._getResumeStatus(AUDIO), None) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus(PICTURE), None)
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()
def test_tc_4_1(self): """ Timer 1 |-------------------------R Timer 2 |------R t |---------|--T1--|--T2--|---T1------|----------> t0 t1 t2 t3 t4 t5 t6 t7 t8 Player play play resume """ # ------------ setup player ------------ player = MockPlayer() player.setSeekDelayedTimer(True) schedulderaction = SchedulerAction(player) player.setVolume(100) 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._t7 - self._t1) timer1.i_media_action = MEDIA_ACTION_START_STOP timer1.s_path = "Media T1 (8:00)" timer1.s_mediatype = VIDEO timer1.b_repeat = False timer1.b_resume = True timer1.i_fade = FADE_OFF timer1.i_vol_min = 0 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._t7))] # 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 (3:00)" 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(len(apwpl), 0) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset() # ------------ t1 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t1)) player._td_now = 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(), None) 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, None) 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(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t2 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t2)) player._td_now = 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(), 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"], timers[0].s_path) self.assertEqual(player.getVolume(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t3 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t3)) player._td_now = timedelta(minutes=self._t3) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 1) self.assertEqual(len(schedulderaction._getRunningTimers()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 0) self.assertEqual(schedulderaction._getFader(), None) self.assertEqual(schedulderaction._getTimerToPlayAV( ).getTimer().i_timer, timers[1].i_timer) 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"], timers[1].s_path) self.assertEqual(player.getVolume(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[1].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t4 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t4)) player._td_now = timedelta(minutes=self._t4) self.assertEqual(timers[0].b_active, True) self.assertEqual(timers[1].b_active, True) self.assertEqual(len(schedulderaction._getBeginningTimers()), 0) self.assertEqual(len(schedulderaction._getRunningTimers()), 2) 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"], timers[1].s_path) self.assertEqual(player.getVolume(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[1].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t5 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t5)) player._td_now = timedelta(minutes=self._t5) 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()), 1) self.assertEqual(len(schedulderaction._getEndingTimers()), 1) self.assertEqual(schedulderaction._getFader(), None) 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, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(VIDEO in apwpl, True) self.assertEqual(apwpl[VIDEO].playlist[0] ["file"], timers[0].s_path) self.assertEqual(apwpl[VIDEO].time, 14400) self.assertEqual(player.getVolume(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t6 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t6)) player._td_now = timedelta(minutes=self._t6) 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(), 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"], timers[0].s_path) self.assertEqual(player.getVolume(), 100) self.assertNotEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player._getResumeStatus( VIDEO)._timer.i_timer, timers[0].i_timer) self.assertEqual(player._getResumeStatus(VIDEO)._state, None) schedulderaction.reset() # ------------ t7 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t7)) player._td_now = timedelta(minutes=self._t7) 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()), 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._getTimerWithSystemAction(), None) self.assertEqual(schedulderaction._volume, None) schedulderaction.perform() apwpl = player.getActivePlayersWithPlaylist() self.assertEqual(len(apwpl), 0) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset() # ------------ t8 ------------ schedulderaction.initFromTimers( timers, timedelta(minutes=self._t8)) player._td_now = timedelta(minutes=self._t8) 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(len(apwpl), 0) self.assertEqual(player._getResumeStatus(VIDEO), None) self.assertEqual(player.getVolume(), 100) schedulderaction.reset()