Files
Muse 54c60188f0 X* monitor family (15 widgets): MonitorWidget + palette 547 -> 562
New btop-style live monitor widgets (registry 547-561, archetype
Monitor, family X, section Misc / X): XHistoryGraph, XCoreGrid,
XNetGraph, XTempHistory, XUsageBar, XStackBar, XVerticalBar,
XTachometer, XArcGauge, XDonutGauge, XProcessList, XLoadBadge,
XMonitorButton, XMonitorGrid, XSysBox. Drawn with Cairo on a
Gtk.DrawingArea like the rest of the set; sample data is runtime
state only (demo sine data until push()/refresh()/poll() feeds
real data). Checks are stdlib only: /proc scan, systemctl
is-active, socket to localhost. 35 new tests; full suite 363 green.
2026-12-05 16:48:47 +00:00

121 lines
4.2 KiB
Python

"""Tests for lightgui.xframe.palette: 562 widgets, 11 sections, 36 legacy."""
import unittest
from lightgui.xframe import palette
EXPECTED_SECTIONS = {
"Windows & Dialogs": 28,
"Containers & Layout": 34,
"Buttons": 24,
"Display": 33,
"Text & Entry": 28,
"Choosers": 10,
"Views & Lists": 17,
"Menus & Toolbars": 16,
"Misc / X": 19,
"Stock Market": 287,
"Instrumentation": 66,
}
class PaletteTests(unittest.TestCase):
def test_562_entries(self):
self.assertEqual(len(palette.PALETTE), 562)
def test_11_sections_in_c_palette_order(self):
self.assertEqual(list(palette.SECTIONS),
list(EXPECTED_SECTIONS))
self.assertEqual(len(palette.SECTIONS), 11)
def test_section_counts_match_c_palette_header(self):
for section, count in EXPECTED_SECTIONS.items():
self.assertEqual(len(palette.by_section(section)), count,
section)
def test_indices_are_0_to_561(self):
self.assertEqual(sorted(e.index for e in palette.PALETTE),
list(range(562)))
def test_names_unique(self):
names = [e.name for e in palette.PALETTE]
self.assertEqual(len(set(names)), 562)
def test_default_sizes_positive(self):
for entry in palette.PALETTE:
self.assertGreater(entry.default_w, 0, entry.name)
self.assertGreater(entry.default_h, 0, entry.name)
def test_find_and_by_index(self):
entry = palette.find("GtkButton")
self.assertEqual(entry.index, 10)
self.assertEqual(entry.section, "Buttons")
self.assertEqual(entry.archetype, "Button")
self.assertEqual(palette.by_index(10), entry)
self.assertIsNone(palette.find("GtkNoSuchWidget"))
self.assertIsNone(palette.by_index(999))
def test_archetypes_are_known(self):
from lightgui.xframe import core
for entry in palette.PALETTE:
self.assertIn(entry.archetype, core.ARCHETYPE_CLASSES,
entry.name)
def test_legacy_types_36_and_not_placeable(self):
self.assertEqual(len(palette.LEGACY_TYPES), 36)
self.assertEqual(palette.LEGACY_TYPES[0][0], "Button")
self.assertEqual(palette.LEGACY_TYPES[-1][0], "Plot")
for key, _pal_id, _w, _h in palette.LEGACY_TYPES:
self.assertIsNone(palette.find(key),
"legacy key must not be a registry kind")
def test_total_entries_598(self):
self.assertEqual(len(palette.PALETTE) + len(palette.LEGACY_TYPES),
598)
if __name__ == "__main__":
unittest.main()
class Task3MinSizesTests(unittest.TestCase):
"""Task 3: placement sizes are max(registry default, content minimum)
so the outer border encloses the widget's fixed content."""
MIN_SIZES = {
"GtkAboutDialog": (520, 260),
"GtkAssistant": (320, 280),
"GtkColorChooserDialog": (340, 240),
"GtkFileChooserDialog": (360, 240),
"GtkFontChooserDialog": (340, 240),
"GtkPrintUnixDialog": (360, 300),
"GtkShortcutsWindow": (320, 300),
"TCalendarDialog": (320, 280),
"TColorDialog": (520, 300),
"TFindDialog": (380, 260),
"TFontDialog": (320, 420),
"TOpenPictureDialog": (480, 240),
"TPageSetupDialog": (320, 400),
"TPrintDialog": (320, 300),
"TReplaceDialog": (360, 260),
"TSavePictureDialog": (480, 240),
"TSelectDirectoryDialog": (360, 260),
"TTaskDialog": (340, 280),
"GtkCalendar": (260, 200),
"TCalendar": (260, 200),
"GtkTreeView": (320, 200),
"TListView": (320, 200),
"TStringGrid": (360, 200),
"GtkAppChooserWidget": (320, 240),
"GtkColorChooserWidget": (340, 260),
"GtkFileChooserWidget": (340, 260),
"GtkFontChooserWidget": (340, 260),
}
def test_min_sizes(self):
by_name = {e.name: e for e in palette.PALETTE}
self.assertEqual(len(self.MIN_SIZES), 27)
for name, (w, h) in self.MIN_SIZES.items():
entry = by_name[name]
self.assertEqual((entry.default_w, entry.default_h), (w, h), name)