Anna Schumaker
4bce147e45
This is a Gtk.ListItemFactory that creates a Label widget and binds a generic property to it. Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
# Copyright 2023 (c) Anna Schumaker.
|
|
"""Tests our row widgets and factories."""
|
|
import unittest
|
|
import xfstestsdb.gtk.row
|
|
from gi.repository import Gtk
|
|
|
|
|
|
class TestLabelFactory(unittest.TestCase):
|
|
"""Tests our Gtk.Factory to make Gtk.Labels."""
|
|
|
|
def setUp(self):
|
|
"""Set up common variables."""
|
|
self.testcase = xfstestsdb.gtk.model.TestCase("test/case")
|
|
self.listitem = Gtk.ListItem()
|
|
self.listitem.get_item = unittest.mock.Mock(return_value=self.testcase)
|
|
|
|
self.factory = xfstestsdb.gtk.row.LabelFactory("name")
|
|
|
|
def test_init(self):
|
|
"""Test that the factory was initialized correctly."""
|
|
self.assertIsInstance(self.factory, Gtk.SignalListItemFactory)
|
|
self.assertEqual(self.factory.property, "name")
|
|
|
|
def test_setup(self):
|
|
"""Test that the factory implements the 'setup' signal."""
|
|
self.factory.emit("setup", self.listitem)
|
|
self.assertIsInstance(self.listitem.get_child(), Gtk.Label)
|
|
self.assertTrue(self.listitem.get_child().has_css_class("numeric"))
|
|
|
|
def test_bind(self):
|
|
"""Test that the factory implements the 'bind' signal."""
|
|
self.factory.emit("setup", self.listitem)
|
|
self.factory.emit("bind", self.listitem)
|
|
self.assertEqual(self.listitem.get_child().get_text(), "test/case")
|
|
|
|
def test_unbind(self):
|
|
"""Test that the factory implements the 'unbind' signal."""
|
|
self.factory.emit("setup", self.listitem)
|
|
self.factory.emit("bind", self.listitem)
|
|
self.factory.emit("unbind", self.listitem)
|
|
self.assertEqual(self.listitem.get_child().get_text(), "")
|
|
|
|
def test_teardown(self):
|
|
"""Test that the factory implements the 'teardown' signal."""
|
|
self.factory.emit("setup", self.listitem)
|
|
self.factory.emit("teardown", self.listitem)
|
|
self.assertIsNone(self.listitem.get_child())
|