Rename PlaybackState.position to time_position.
This commit is contained in:
parent
eb930a1679
commit
cf5dfccee2
@ -602,7 +602,7 @@ class PlaybackController(object):
|
||||
def _export_state(self):
|
||||
return models.PlaybackState(
|
||||
tlid=self.get_current_tlid(),
|
||||
position=self.get_time_position(),
|
||||
time_position=self.get_time_position(),
|
||||
state=self.get_state())
|
||||
|
||||
def _restore_state(self, state, coverage):
|
||||
@ -616,5 +616,5 @@ class PlaybackController(object):
|
||||
if new_state == PlaybackState.PAUSED:
|
||||
self._start_paused = True
|
||||
if new_state in (PlaybackState.PLAYING, PlaybackState.PAUSED):
|
||||
self._start_at_position = state.position
|
||||
self._start_at_position = state.time_position
|
||||
self.play(tlid=state.tlid)
|
||||
|
||||
@ -60,8 +60,8 @@ class PlaybackState(ValidatedImmutableObject):
|
||||
|
||||
:param tlid: current track tlid
|
||||
:type tlid: int
|
||||
:param position: play position
|
||||
:type position: int
|
||||
:param time_position: play position
|
||||
:type time_position: int
|
||||
:param state: playback state
|
||||
:type state: :class:`validation.PLAYBACK_STATES`
|
||||
"""
|
||||
@ -70,7 +70,7 @@ class PlaybackState(ValidatedImmutableObject):
|
||||
tlid = fields.Integer(min=1)
|
||||
|
||||
# The playback position. Read-only.
|
||||
position = fields.Integer(min=0)
|
||||
time_position = fields.Integer(min=0)
|
||||
|
||||
# The playback state. Read-only.
|
||||
state = fields.Field(choices=validation.PLAYBACK_STATES)
|
||||
|
||||
@ -1141,7 +1141,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
|
||||
self.replay_events()
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tlid=tl_tracks[1].tlid)
|
||||
time_position=0, state='playing', tlid=tl_tracks[1].tlid)
|
||||
value = self.core.playback._export_state()
|
||||
|
||||
self.assertEqual(state, value)
|
||||
@ -1154,7 +1154,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
|
||||
self.assertEqual('stopped', self.core.playback.get_state())
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
time_position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
coverage = ['play-always']
|
||||
self.core.playback._restore_state(state, coverage)
|
||||
self.replay_events()
|
||||
@ -1171,7 +1171,7 @@ class TesetCorePlaybackExportRestore(BaseTest):
|
||||
self.assertEqual('stopped', self.core.playback.get_state())
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
time_position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
coverage = ['other']
|
||||
self.core.playback._restore_state(state, coverage)
|
||||
self.replay_events()
|
||||
|
||||
@ -78,16 +78,16 @@ class MixerStateTest(unittest.TestCase):
|
||||
class PlaybackStateTest(unittest.TestCase):
|
||||
|
||||
def test_position(self):
|
||||
position = 123456
|
||||
result = PlaybackState(position=position)
|
||||
self.assertEqual(result.position, position)
|
||||
time_position = 123456
|
||||
result = PlaybackState(time_position=time_position)
|
||||
self.assertEqual(result.time_position, time_position)
|
||||
with self.assertRaises(AttributeError):
|
||||
result.position = None
|
||||
result.time_position = None
|
||||
|
||||
def test_position_invalid(self):
|
||||
position = -1
|
||||
time_position = -1
|
||||
with self.assertRaises(ValueError):
|
||||
PlaybackState(position=position)
|
||||
PlaybackState(time_position=time_position)
|
||||
|
||||
def test_tl_track(self):
|
||||
tlid = 42
|
||||
|
||||
Loading…
Reference in New Issue
Block a user