2022-02-01 14:18:31 -05:00
|
|
|
#!/usr/bin/python
|
2022-02-09 12:22:18 -05:00
|
|
|
import re
|
2022-02-01 14:18:31 -05:00
|
|
|
from . import common
|
|
|
|
from . import testchooser
|
2022-02-02 11:10:07 -05:00
|
|
|
from . import testproperties
|
2022-02-01 15:59:50 -05:00
|
|
|
from . import testresults
|
2022-02-03 15:35:32 -05:00
|
|
|
from . import testviewer
|
2022-02-01 14:18:31 -05:00
|
|
|
from gi.repository import GObject
|
|
|
|
from gi.repository import Gtk
|
|
|
|
|
2022-02-03 15:35:32 -05:00
|
|
|
SizeGroup = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL)
|
|
|
|
|
2022-02-01 14:18:31 -05:00
|
|
|
class TestChooser(Gtk.Box):
|
|
|
|
def __init__(self):
|
|
|
|
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
|
|
|
self.stack = testchooser.Stack()
|
2022-02-03 15:35:32 -05:00
|
|
|
self.switcher = Gtk.StackSwitcher(stack=self.stack)
|
|
|
|
SizeGroup.add_widget(self.switcher)
|
|
|
|
self.append(self.switcher)
|
2022-02-01 14:18:31 -05:00
|
|
|
self.append(self.stack)
|
|
|
|
self.stack.connect("test-selected", self.on_test_selected)
|
|
|
|
|
|
|
|
def on_test_selected(self, stack, path):
|
|
|
|
self.emit("test-selected", path)
|
|
|
|
|
|
|
|
@GObject.Signal(arg_types=(testchooser.Path,))
|
|
|
|
def test_selected(self, path): pass
|
2022-02-02 11:10:07 -05:00
|
|
|
|
|
|
|
|
2022-02-03 15:35:32 -05:00
|
|
|
class TestViewer(Gtk.Box):
|
2022-02-02 11:10:07 -05:00
|
|
|
def __init__(self):
|
|
|
|
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
|
|
|
|
self.stack = testproperties.Stack()
|
2022-02-03 15:35:32 -05:00
|
|
|
self.switcher = Gtk.StackSwitcher(stack=self.stack, halign=Gtk.Align.CENTER)
|
2022-02-09 12:22:18 -05:00
|
|
|
self.viewer = testviewer.Viewer()
|
|
|
|
self.search = testviewer.SearchEntry(self.viewer.get_filter())
|
|
|
|
|
2022-02-03 15:35:32 -05:00
|
|
|
self.append(self.switcher)
|
2022-02-02 11:10:07 -05:00
|
|
|
self.append(self.stack)
|
2022-02-03 15:35:32 -05:00
|
|
|
self.append(self.viewer)
|
2022-02-09 12:22:18 -05:00
|
|
|
self.append(self.search)
|
|
|
|
|
2022-02-03 15:35:32 -05:00
|
|
|
SizeGroup.add_widget(self.switcher)
|
2022-02-09 12:22:18 -05:00
|
|
|
self.stack.connect("notrun-selected", self.notrun_selected)
|
2022-02-02 11:10:07 -05:00
|
|
|
|
|
|
|
def set_test_result(self, file):
|
2022-02-09 11:58:06 -05:00
|
|
|
current = self.stack.clear()
|
2022-02-03 15:35:32 -05:00
|
|
|
self.viewer.clear()
|
2022-02-02 11:10:07 -05:00
|
|
|
if file and file.get_is_test_result():
|
|
|
|
results = testresults.TestResults(file.path)
|
2022-02-09 11:58:06 -05:00
|
|
|
self.stack.show_properties(results, current)
|
2022-02-03 15:35:32 -05:00
|
|
|
self.viewer.show_results(results)
|
2022-02-09 12:22:18 -05:00
|
|
|
|
|
|
|
def notrun_selected(self, stack, item):
|
|
|
|
self.search.set_text(re.escape(item.message))
|