lib: Give Tags a stacked() function
This will be called when a tag is added to the tag stack to check if the current track pointer needs to be reset. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
d51ee8e0e2
commit
7037483508
|
@ -98,6 +98,11 @@ class Tag:
|
|||
self.tracks.remove(track)
|
||||
self.TrackRemoved.publish(self, track)
|
||||
|
||||
def stacked(self):
|
||||
with self.lock:
|
||||
if self.current >= len(self.tracks):
|
||||
self.current = -1
|
||||
|
||||
|
||||
class SuperTag(Tag):
|
||||
def __init__(self, parent, name, sort=None):
|
||||
|
|
|
@ -167,6 +167,18 @@ class TestTag(unittest.TestCase):
|
|||
self.assertEqual(t.next(), 0)
|
||||
self.assertEqual(t.next(), 1)
|
||||
|
||||
def test_tag_stacked(self):
|
||||
t = tag.Tag("test")
|
||||
t.tracks = [ 0, 1, 2 ]
|
||||
|
||||
t.current = 3
|
||||
t.stacked()
|
||||
self.assertEqual(t.current, -1)
|
||||
|
||||
t.current = 1
|
||||
t.stacked()
|
||||
self.assertEqual(t.current, 1)
|
||||
|
||||
|
||||
class TestSuperTag(unittest.TestCase):
|
||||
def test_super_tag(self):
|
||||
|
|
Loading…
Reference in New Issue