audio: Create a custom AudioControls widget

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-09-02 13:48:02 -04:00
parent ca47bd052f
commit ef1d3f0985
2 changed files with 30 additions and 0 deletions

View File

@ -122,6 +122,16 @@ class MenuButton(Gtk.ToggleButton):
self.set_active(False)
class AudioControls(Gtk.Box):
def __init__(self, player, apscale):
Gtk.Box.__init__(self)
self.add_css_class("linked")
self.append(PreviousButton(player))
self.append(PlayPauseButton(player))
self.append(NextButton(player))
self.append(MenuButton(player, apscale))
class Controls(Gtk.Box):
def __init__(self):
Gtk.Box.__init__(self)

View File

@ -168,6 +168,26 @@ class TestControlsMenuButton(unittest.TestCase):
self.assertEqual(menu.popover.get_parent(), menu)
class TestAudioControls(unittest.TestCase):
def test_audio_controls(self):
fake = FakePlayer()
apscale = scale.AutoPauseScale()
ctrl = controls.AudioControls(fake, apscale)
self.assertIsInstance(ctrl, Gtk.Box)
self.assertEqual(ctrl.get_orientation(), Gtk.Orientation.HORIZONTAL)
self.assertTrue(ctrl.has_css_class("linked"))
child = ctrl.get_first_child()
self.assertIsInstance(child, controls.PreviousButton)
child = child.get_next_sibling()
self.assertIsInstance(child, controls.PlayPauseButton)
child = child.get_next_sibling()
self.assertIsInstance(child, controls.NextButton)
child = child.get_next_sibling()
self.assertIsInstance(child, controls.MenuButton)
class TestControls(unittest.TestCase):
def test_controls_init(self):
ctrl = controls.Controls()