gtk: Add the EnvironmentView to the XfstestsView

And set the environment property from the application after creating a
property list.

Signed-off-by: Anna Schumaker <anna@nowheycreamery.com>
This commit is contained in:
Anna Schumaker 2023-08-29 17:17:34 -04:00
parent f44e064c89
commit 40b1d1789d
4 changed files with 30 additions and 1 deletions

View File

@ -298,11 +298,19 @@ class TestXfstestsView(unittest.TestCase):
self.assertIsInstance(self.view, Gtk.Box)
self.assertEqual(self.view.props.orientation, Gtk.Orientation.VERTICAL)
def test_environment_view(self):
"""Check that the XfstestsView sets up an EnvironmentView correctly."""
self.assertIsInstance(self.view._environview,
xfstestsdb.gtk.view.EnvironmentView)
self.assertEqual(self.view.get_first_child(), self.view._environview)
def test_property_view(self):
"""Check that the XfstestsView sets up a PropertyView correctly."""
sep = self.view._environview.get_next_sibling()
self.assertIsInstance(sep, Gtk.Separator)
self.assertIsInstance(self.view._propertyview,
xfstestsdb.gtk.view.PropertyView)
self.assertEqual(self.view.get_first_child(), self.view._propertyview)
self.assertEqual(sep.get_next_sibling(), self.view._propertyview)
def test_testcase_view(self):
"""Check that the XfstestsView sets up a TestCaseView correctly."""
@ -320,6 +328,12 @@ class TestXfstestsView(unittest.TestCase):
xfstestsdb.gtk.view.SummaryView)
self.assertEqual(sep.get_next_sibling(), self.view._summaryview)
def test_environment(self):
"""Test the XfstestsView 'environment' property."""
self.assertIsNone(self.view.environment)
self.view.environment = self.props.environment
self.assertEqual(self.view._environview.model, self.props.environment)
def test_properties(self):
"""Test the XfstestsView 'properties' property."""
self.assertIsNone(self.view.properties)

View File

@ -44,6 +44,7 @@ class TestApplication(unittest.TestCase):
mock_cmd.get_arguments.assert_called()
mock_activate.assert_called()
self.assertEqual(self.application.runid, 0)
self.assertIsNone(self.application.environment)
self.assertIsNone(self.application.properties)
self.assertIsNone(self.application.model)
self.assertIsNone(self.application.summary)
@ -64,6 +65,8 @@ class TestApplication(unittest.TestCase):
xfstestsdb.gtk.model.TestCaseList)
self.assertIsInstance(self.application.summary,
xfstestsdb.gtk.model.SummaryList)
self.assertEqual(self.application.environment,
self.application.properties.environment)
self.assertEqual(self.application.model.runid, 42)
@unittest.mock.patch("xfstestsdb.gtk.gsetup.add_style")
@ -94,6 +97,10 @@ class TestApplication(unittest.TestCase):
self.application.properties = properties
self.assertEqual(self.application.view.properties, properties)
self.application.environment = properties.environment
self.assertEqual(self.application.view.environment,
properties.environment)
model = xfstestsdb.gtk.model.TestCaseList(self.xfstestsdb.sql, 42)
self.application.model = model
self.assertEqual(self.application.view.model, model)

View File

@ -18,6 +18,7 @@ class Application(Adw.Application):
"""Our Adw.Application for displaying xfstests results."""
runid = GObject.Property(type=int)
environment = GObject.Property(type=Gio.ListStore)
properties = GObject.Property(type=model.PropertyList)
summary = GObject.Property(type=model.SummaryList)
model = GObject.Property(type=model.TestCaseList)
@ -42,6 +43,7 @@ class Application(Adw.Application):
case "runid":
self.runid = int(split[1])
self.properties = model.PropertyList(self.sql, self.runid)
self.environment = self.properties.environment
self.model = model.TestCaseList(self.sql, self.runid)
self.summary = model.SummaryList(self.sql, self.runid)
@ -58,6 +60,7 @@ class Application(Adw.Application):
self.win.headerbar.pack_end(self.view.filterbuttons)
self.bind_property("runid", self.win, "runid")
self.bind_property("environment", self.view, "environment")
self.bind_property("properties", self.view, "properties")
self.bind_property("model", self.view, "model")
self.bind_property("summary", self.view, "summary")

View File

@ -169,6 +169,7 @@ class SummaryView(XunitView):
class XfstestsView(Gtk.Box):
"""A widget to display the results of an Xfstests runs."""
environment = GObject.Property(type=Gio.ListModel)
properties = GObject.Property(type=PropertyList)
model = GObject.Property(type=TestCaseList)
summary = GObject.Property(type=SummaryList)
@ -176,14 +177,18 @@ class XfstestsView(Gtk.Box):
def __init__(self):
"""Initialize an XfstestsView."""
super().__init__(orientation=Gtk.Orientation.VERTICAL)
self._environview = EnvironmentView()
self._propertyview = PropertyView()
self._testcaseview = TestCaseView()
self._summaryview = SummaryView()
self.bind_property("environment", self._environview, "model")
self.bind_property("properties", self._propertyview, "model")
self.bind_property("model", self._testcaseview, "model")
self.bind_property("summary", self._summaryview, "model")
self.append(self._environview)
self.append(Gtk.Separator())
self.append(self._propertyview)
self.append(Gtk.Separator())
self.append(self._testcaseview)