xfstestsdb/tests/gtk/test_window.py

67 lines
2.5 KiB
Python

# Copyright 2023 (c) Anna Schumaker.
"""Tests our Window implementation."""
import unittest
import xfstestsdb.gtk.window
from gi.repository import Gtk
from gi.repository import Adw
class TestWindow(unittest.TestCase):
"""Test case for our Window subclass."""
def setUp(self):
"""Set up common variables."""
self.window = xfstestsdb.gtk.window.Window()
def test_init(self):
"""Check that the Window is set up correctly."""
self.assertIsInstance(self.window, Adw.Window)
self.assertEqual(self.window.props.default_height, 1000)
self.assertEqual(self.window.props.default_width, 1600)
self.assertTrue(self.window.has_css_class("devel"))
self.assertIsInstance(self.window.props.content, Gtk.Box)
self.assertEqual(self.window.props.content.get_orientation(),
Gtk.Orientation.VERTICAL)
def test_headerbar(self):
"""Test the headerbar property."""
self.assertIsInstance(self.window.headerbar, Adw.HeaderBar)
self.assertEqual(self.window.props.content.get_first_child(),
self.window.headerbar)
self.assertTrue(self.window.headerbar.has_css_class("flat"))
def test_title_widget(self):
"""Test the title widget property."""
self.assertIsInstance(self.window.title, Adw.WindowTitle)
self.assertEqual(self.window.title.props.title, "xfstestsdb gtk")
self.assertEqual(self.window.headerbar.props.title_widget,
self.window.title)
def test_child(self):
"""Test the window child property."""
self.assertIsInstance(self.window.headerbar.get_next_sibling(),
Adw.Bin)
self.assertIsNone(self.window.child)
self.window.child = Gtk.Label()
self.assertEqual(self.window.headerbar.get_next_sibling().props.child,
self.window.child)
label = Gtk.Label()
window2 = xfstestsdb.gtk.window.Window(child=label)
self.assertEqual(window2.child, label)
self.assertEqual(window2.headerbar.get_next_sibling().props.child,
label)
def test_runid(self):
"""Test the window runid property."""
self.assertEqual(self.window.runid, 0)
self.assertEqual(self.window.title.props.subtitle, "")
self.window.runid = 3
self.assertEqual(self.window.title.props.subtitle, "runid #3")
self.window.runid = 0
self.assertEqual(self.window.title.props.subtitle, "")