emmental/playlist/test_sort.py

52 lines
1.9 KiB
Python
Raw Normal View History

# Copyright 2021 (c) Anna Schumaker.
import unittest
from gi.repository import Gtk
from . import sort
class TestUpDownBox(unittest.TestCase):
def move_up(self, button): self.up = True
def move_down(self, button): self.down = True
def test_init(self):
updown = sort.UpDownBox()
self.assertIsInstance(updown, Gtk.Box)
self.assertTrue(updown.has_css_class("linked"))
child = updown.get_first_child()
self.assertIsInstance(child, Gtk.Button)
self.assertEqual(child.get_icon_name(), "go-up-symbolic")
self.assertFalse(child.get_sensitive())
child = child.get_next_sibling()
self.assertIsInstance(child, Gtk.Button)
self.assertEqual(child.get_icon_name(), "go-down-symbolic")
self.assertFalse(child.get_sensitive())
def test_sensitive(self):
updown = sort.UpDownBox()
updown.set_active(True, first=False, last=False)
self.assertTrue(updown.get_first_child().get_sensitive())
self.assertTrue(updown.get_last_child().get_sensitive())
updown.set_active(True, first=True, last=False)
self.assertFalse(updown.get_first_child().get_sensitive())
self.assertTrue(updown.get_last_child().get_sensitive())
updown.set_active(True, first=False, last=True)
self.assertTrue(updown.get_first_child().get_sensitive())
self.assertFalse(updown.get_last_child().get_sensitive())
updown.set_active(False, first=True, last=True)
self.assertFalse(updown.get_first_child().get_sensitive())
self.assertFalse(updown.get_last_child().get_sensitive())
def test_clicks(self):
updown = sort.UpDownBox()
updown.connect("move-up", self.move_up)
updown.connect("move-down", self.move_down)
updown.get_first_child().emit("clicked")
self.assertTrue(self.up)
updown.get_last_child().emit("clicked")
self.assertTrue(self.down)