2022-02-02 11:10:07 -05:00
|
|
|
#!/usr/bin/python
|
|
|
|
from . import common
|
|
|
|
from gi.repository import GObject
|
|
|
|
from gi.repository import Gio
|
|
|
|
from gi.repository import Gtk
|
|
|
|
|
|
|
|
PROPERTIES = [ "PLATFORM", "TIMESTAMP", "FSTYP", "MOUNT_OPTIONS", "CHECK_OPTIONS",
|
|
|
|
"TEST_DIR", "TEST_DEV", "SCRATCH_DEV", "SCRATCH_MNT" ] #, "RESULTS" ]
|
|
|
|
|
|
|
|
class Property(GObject.GObject):
|
|
|
|
def __init__(self, key, value):
|
|
|
|
GObject.GObject.__init__(self)
|
|
|
|
self.key = key
|
|
|
|
self.value = value
|
|
|
|
|
|
|
|
|
2022-02-08 13:33:27 -05:00
|
|
|
class NotRun(GObject.GObject):
|
|
|
|
def __init__(self, message):
|
|
|
|
GObject.GObject.__init__(self)
|
|
|
|
self.message = message
|
|
|
|
|
|
|
|
def __lt__(self, rhs):
|
|
|
|
return self.message < rhs.message
|
|
|
|
|
|
|
|
|
2022-02-02 11:10:07 -05:00
|
|
|
class Results(Property):
|
|
|
|
def __init__(self, properties):
|
|
|
|
time = properties["TIME"]
|
2022-02-08 13:41:07 -05:00
|
|
|
passed = properties["PASSED"]
|
2022-02-02 11:10:07 -05:00
|
|
|
failed = properties["FAILURES"]
|
|
|
|
skipped = properties["SKIPPED"]
|
2022-02-08 13:41:07 -05:00
|
|
|
total = int(passed) + int(failed) + int(skipped)
|
2022-02-02 11:10:07 -05:00
|
|
|
Property.__init__(self, "RESULTS",
|
|
|
|
f"Ran {total} tests in {time} seconds: " \
|
|
|
|
f"{passed} passed, {failed} failed, {skipped} skipped")
|
|
|
|
|
|
|
|
|
|
|
|
class Model(GObject.GObject, Gio.ListModel):
|
|
|
|
def __init__(self, properties):
|
|
|
|
GObject.GObject.__init__(self)
|
|
|
|
self.properties = [ Property(p, properties[p]) for p in PROPERTIES ]
|
|
|
|
self.properties.append(Results(properties))
|
|
|
|
|
|
|
|
def do_get_item_type(self): return GObject.TYPE_PYOBJECT
|
|
|
|
def do_get_n_items(self): return len(self.properties)
|
|
|
|
def do_get_item(self, i): return self.properties[i]
|
|
|
|
|
|
|
|
|
2022-02-08 13:33:27 -05:00
|
|
|
class NotRunModel(GObject.GObject, Gio.ListModel):
|
|
|
|
def __init__(self, notrun):
|
|
|
|
GObject.GObject.__init__(self)
|
|
|
|
self.notrun = [ NotRun(m) for m in notrun ]
|
|
|
|
self.notrun.sort()
|
|
|
|
|
|
|
|
def do_get_item_type(self): return GObject.TYPE_PYOBJECT
|
|
|
|
def do_get_n_items(self): return len(self.notrun)
|
|
|
|
def do_get_item(self, i): return self.notrun[i]
|
|
|
|
|
|
|
|
|
2022-02-02 11:10:07 -05:00
|
|
|
class Factory(Gtk.SignalListItemFactory):
|
|
|
|
def __init__(self, column):
|
|
|
|
Gtk.SignalListItemFactory.__init__(self)
|
|
|
|
self.column = column
|
|
|
|
self.connect("setup", self.on_setup)
|
|
|
|
self.connect("bind", self.on_bind)
|
|
|
|
self.connect("unbind", self.on_unbind)
|
|
|
|
self.connect("teardown", self.on_teardown)
|
|
|
|
|
|
|
|
def on_setup(self, factory, listitem):
|
|
|
|
listitem.set_child(Gtk.Label(xalign=0))
|
|
|
|
|
|
|
|
def on_bind(self, factory, listitem):
|
|
|
|
label = listitem.get_child()
|
|
|
|
match self.column:
|
|
|
|
case "Property": label.set_text(listitem.get_item().key)
|
|
|
|
case "Value": label.set_text(listitem.get_item().value)
|
|
|
|
case _: label.set_text("=")
|
|
|
|
|
|
|
|
def on_unbind(self, factory, listitem):
|
|
|
|
listitem.get_child().set_text("")
|
|
|
|
|
|
|
|
def on_teardown(self, factory, listitem):
|
|
|
|
listitem.set_child(None)
|
|
|
|
|
|
|
|
|
2022-02-08 13:33:27 -05:00
|
|
|
class NotRunFactory(Gtk.SignalListItemFactory):
|
|
|
|
def __init__(self):
|
|
|
|
Gtk.SignalListItemFactory.__init__(self)
|
|
|
|
self.connect("setup", self.on_setup)
|
|
|
|
self.connect("bind", self.on_bind)
|
|
|
|
self.connect("unbind", self.on_unbind)
|
|
|
|
self.connect("teardown", self.on_teardown)
|
|
|
|
|
|
|
|
def on_setup(self, factory, listitem):
|
|
|
|
listitem.set_child(Gtk.Label(xalign=0))
|
|
|
|
|
|
|
|
def on_bind(self, factory, listitem):
|
|
|
|
listitem.get_child().set_text(listitem.get_item().message)
|
|
|
|
|
|
|
|
def on_unbind(self, factory, listitem):
|
|
|
|
listitem.get_child().set_text("")
|
|
|
|
|
|
|
|
def on_teardown(self, factory, listitem):
|
|
|
|
listitem.set_child(None)
|
|
|
|
|
|
|
|
|
2022-02-02 11:10:07 -05:00
|
|
|
class View(Gtk.ColumnView):
|
|
|
|
def __init__(self, properties):
|
|
|
|
self.selection = Gtk.NoSelection.new(Model(properties))
|
|
|
|
Gtk.ColumnView.__init__(self, model=self.selection)
|
|
|
|
self.add_css_class("data-table")
|
|
|
|
for title in [ "Property", "=", "Value" ]:
|
|
|
|
self.append_column(Gtk.ColumnViewColumn.new(title, Factory(title)))
|
|
|
|
|
|
|
|
|
2022-02-08 13:33:27 -05:00
|
|
|
class NotRunView(Gtk.ListView):
|
|
|
|
def __init__(self, notrun):
|
2022-02-09 12:22:18 -05:00
|
|
|
self.selection = Gtk.SingleSelection(autoselect=False, model=NotRunModel(notrun))
|
2022-02-08 13:33:27 -05:00
|
|
|
Gtk.ListView.__init__(self, model=self.selection, factory=NotRunFactory())
|
|
|
|
self.add_css_class("data-table")
|
|
|
|
|
|
|
|
|
2022-02-02 11:10:07 -05:00
|
|
|
class Stack(Gtk.Stack):
|
|
|
|
def __init__(self):
|
2022-02-09 11:58:06 -05:00
|
|
|
Gtk.Stack.__init__(self)
|
2022-02-02 11:10:07 -05:00
|
|
|
common.SizeGroup.add_widget(self)
|
|
|
|
|
|
|
|
def clear(self):
|
2022-02-09 11:58:06 -05:00
|
|
|
current = self.get_visible_child_name()
|
2022-02-02 11:10:07 -05:00
|
|
|
pages = self.get_pages()
|
|
|
|
children = [ pages.get_item(i).get_child() for i in range(pages.get_n_items()) ]
|
|
|
|
for child in children:
|
|
|
|
self.remove(child)
|
2022-02-09 11:58:06 -05:00
|
|
|
return current
|
2022-02-02 11:10:07 -05:00
|
|
|
|
2022-02-09 11:58:06 -05:00
|
|
|
def show_properties(self, results, current):
|
|
|
|
self.set_transition_type(Gtk.StackTransitionType.NONE)
|
2022-02-02 11:10:07 -05:00
|
|
|
for version in results.versions:
|
2022-02-09 11:58:06 -05:00
|
|
|
self.add_page(View(results.properties[version]), version, Gtk.PolicyType.NEVER, current)
|
|
|
|
self.add_page(NotRunView(results.skipped), "[not run]", Gtk.PolicyType.AUTOMATIC, current)
|
|
|
|
self.set_transition_type(Gtk.StackTransitionType.OVER_LEFT_RIGHT)
|
2022-02-08 13:33:27 -05:00
|
|
|
|
2022-02-09 11:58:06 -05:00
|
|
|
def add_page(self, child, name, policy, current):
|
2022-02-08 13:33:27 -05:00
|
|
|
window = Gtk.ScrolledWindow(vscrollbar_policy=policy, child=child)
|
|
|
|
self.add_titled(window, name, name)
|
2022-02-09 11:58:06 -05:00
|
|
|
if current == name:
|
|
|
|
self.set_visible_child(window)
|
2022-02-09 12:22:18 -05:00
|
|
|
child.selection.connect("selection-changed", self.selection_changed)
|
|
|
|
|
|
|
|
def selection_changed(self, selection, position, n_items):
|
|
|
|
self.emit("notrun-selected", selection.get_selected_item())
|
|
|
|
|
|
|
|
@GObject.Signal(arg_types=(NotRun,))
|
|
|
|
def notrun_selected(self, notrun): pass
|