From 40b1d1789d8d53d8de598aafcdd511851dca55f5 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 29 Aug 2023 17:17:34 -0400 Subject: [PATCH] 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 --- tests/gtk/test_view.py | 16 +++++++++++++++- tests/test_gtk.py | 7 +++++++ xfstestsdb/gtk/__init__.py | 3 +++ xfstestsdb/gtk/view.py | 5 +++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/gtk/test_view.py b/tests/gtk/test_view.py index 5c9abb6..6fc912b 100644 --- a/tests/gtk/test_view.py +++ b/tests/gtk/test_view.py @@ -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) diff --git a/tests/test_gtk.py b/tests/test_gtk.py index ff02eb9..d7ba0d6 100644 --- a/tests/test_gtk.py +++ b/tests/test_gtk.py @@ -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) diff --git a/xfstestsdb/gtk/__init__.py b/xfstestsdb/gtk/__init__.py index 5fa0ab9..afc09c8 100644 --- a/xfstestsdb/gtk/__init__.py +++ b/xfstestsdb/gtk/__init__.py @@ -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") diff --git a/xfstestsdb/gtk/view.py b/xfstestsdb/gtk/view.py index a6a0449..558b612 100644 --- a/xfstestsdb/gtk/view.py +++ b/xfstestsdb/gtk/view.py @@ -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)