summaryrefslogtreecommitdiff
path: root/tests/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-12-28 21:44:27 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-12-28 21:44:27 (GMT)
commita6a88792bc866d8a1d7cabd50a93374da5dd1e7a (patch)
tree748d5a29339f0ccd09b1d5ef691a988c30eb5fca /tests/glibext
parentcd59150b26173fc4caa44b604d9e0989de331b3d (diff)
Improved the API for configuration and its Python documentation.
Diffstat (limited to 'tests/glibext')
-rw-r--r--tests/glibext/configuration.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/glibext/configuration.py b/tests/glibext/configuration.py
new file mode 100644
index 0000000..786fc9e
--- /dev/null
+++ b/tests/glibext/configuration.py
@@ -0,0 +1,71 @@
+
+import gi
+gi.require_version('Gdk', '3.0')
+from gi.repository import Gdk
+
+from chrysacase import ChrysalideTestCase
+from pychrysalide.glibext import ConfigParam
+
+
+class TestConfiguration(ChrysalideTestCase):
+ """TestCase for configuration related items.*"""
+
+
+ def testCfgParamValues(self):
+ """Set and unset configuration parameter values."""
+
+ color = Gdk.RGBA()
+ color.parse('#3465A4')
+
+ param = ConfigParam('config.color', ConfigParam.ConfigParamType.COLOR, color)
+
+ self.assertEqual(param.value, color)
+
+ param.make_empty()
+
+ void = Gdk.RGBA(red=0, green=0, blue=0, alpha=0)
+ self.assertEqual(param.value, void)
+
+ param.value = color
+
+ self.assertEqual(param.value, color)
+
+
+ def testCfgParamStates(self):
+ """Validate all states of an evolving parameter."""
+
+ param = ConfigParam('config.int', ConfigParam.ConfigParamType.INTEGER)
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.EMPTY | ConfigParam.ConfigParamState.DEFAULT)
+
+ param.make_empty()
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.EMPTY | ConfigParam.ConfigParamState.DEFAULT)
+
+ param = ConfigParam('config.int', ConfigParam.ConfigParamType.INTEGER, 0x123)
+
+ self.assertEqual(param.value, 0x123)
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.DEFAULT)
+
+ param.make_empty()
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.EMPTY | ConfigParam.ConfigParamState.CHANGED)
+
+ param.value = 0x1
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.CHANGED)
+
+ param.reset()
+
+ self.assertEqual(param.state, ConfigParam.ConfigParamState.DEFAULT)
+
+
+ def testCfgParamDesc(self):
+ """Export types and states as strings when needed."""
+
+ param = ConfigParam('config.int', ConfigParam.ConfigParamType.INTEGER)
+
+ self.assertTrue('|' in str(param.state))
+
+ self.assertTrue('.' in str(param.type))