summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoryangfl <yangfl@users.noreply.github.com>2018-04-29 20:08:55 +0800
committerChristoph Reiter <reiter.christoph@gmail.com>2018-05-03 13:20:36 +0000
commitd0b219ca50b52fe219ceb90e80eca833fbba05ab (patch)
treee38876977910239ff4cf99d77477d662e00cee1f /tests
parentdceb3e339149f0bc7e9f004632a6a24f38ca60ad (diff)
downloadpygobject-d0b219ca50b52fe219ceb90e80eca833fbba05ab.tar.gz
Add ActionMap and ActionMap.add_action_entries() to overrides. Fixes #29
Adds ActionMap and ActionMap.add_action_entries() to allow for adding multiple actions as a list of tuples in which each element defines a single action like the GActionEntry C struct. https://bugzilla.gnome.org/show_bug.cgi?id=678655 Original Author: Micah Carrick <micah@quixotix.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_overrides_gio.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_overrides_gio.py b/tests/test_overrides_gio.py
index 79f3085c..b6516f9b 100644
--- a/tests/test_overrides_gio.py
+++ b/tests/test_overrides_gio.py
@@ -310,3 +310,37 @@ def test_list_store_setitem_slice():
with pytest.raises(TypeError):
store[:] = [Item(), object()]
assert len(store) == 0
+
+
+def test_action_map_add_action_entries():
+ actionmap = Gio.SimpleActionGroup()
+
+ test_data = []
+
+ def f(action, parameter, data):
+ test_data.append('test back')
+
+ actionmap.add_action_entries((
+ ("simple", f),
+ ("with_type", f, "i"),
+ ("with_state", f, "s", "'left'", f),
+ ))
+ assert actionmap.has_action("simple")
+ assert actionmap.has_action("with_type")
+ assert actionmap.has_action("with_state")
+ actionmap.add_action_entries((
+ ("with_user_data", f),
+ ), "user_data")
+ assert actionmap.has_action("with_user_data")
+
+ with pytest.raises(TypeError):
+ actionmap.add_action_entries((
+ ("invaild_type_string", f, 'asdf'),
+ ))
+ with pytest.raises(ValueError):
+ actionmap.add_action_entries((
+ ("stateless_with_change_state", f, None, None, f),
+ ))
+
+ actionmap.activate_action("simple")
+ assert test_data[0] == 'test back'