tests: add tests for action widget syntax

This commit is contained in:
Gleb Smirnov 2022-02-18 19:04:08 +03:00
parent 736681a841
commit d9ef1d4df9
No known key found for this signature in database
GPG key ID: 559DB6D1D625EFAB
17 changed files with 120 additions and 0 deletions

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Dialog {
[action response=17.9]
Button float_response_button {
}
}

View file

@ -0,0 +1 @@
4,22,4,Response type must be GtkResponseType member or integer, not float

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Dialog {
[action response=cancel]
Button {
label: _("Cancel");
}
}

View file

@ -0,0 +1 @@
4,13,15,Action widget must have ID

View file

@ -0,0 +1,13 @@
using Gtk 4.0;
Dialog {
[action response=yes default]
Button yes_button {
}
[action response=no default]
Button no_button {
}
}

View file

@ -0,0 +1 @@
9,25,7,Default response is already set

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Dialog {
[action response = -179]
Button numeric_response_button {
}
}

View file

@ -0,0 +1 @@
4,24,4,Numeric response type can't be negative

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Dialog {
[some_type response=ok]
Button ok_button {
}
}

View file

@ -0,0 +1 @@
4,16,11,Only action widget can have response ID

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Box {
[action response=ok]
Button ok_button {
}
}

View file

@ -0,0 +1 @@
4,13,11,Gtk.Box is not a Gtk.Dialog, so it doesn't have action widgets

View file

@ -0,0 +1,8 @@
using Gtk 4.0;
Dialog {
[action response=hello-world]
Button hello_world_button {
}
}

View file

@ -0,0 +1 @@
4,22,11,Response type "hello-world" doesn't exist

View file

@ -0,0 +1,18 @@
using Gtk 4.0;
Dialog {
[action response=cancel]
Button cancel_button {
label: _("Cancel");
}
[action reponse=9]
Button custom_response_button {
label: _("Reinstall Windows");
}
[action response=ok default]
Button ok_button {
label: _("Ok");
}
}

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkDialog">
<child type="action">
<object class="GtkButton" id="cancel_button">
<property name="label" translatable="true">Cancel</property>
</object>
</child>
<child type="action">
<object class="GtkButton" id="custom_response_button">
<property name="label" translatable="true">Reinstall Windows</property>
</object>
</child>
<child type="action">
<object class="GtkButton" id="ok_button">
<property name="label" translatable="true">Ok</property>
</object>
</child>
<action-widgets>
<action-widget response="cancel">cancel_button</action-widget>
<action-widget response="9">custom_response_button</action-widget>
<action-widget response="ok" default="True">ok_button</action-widget>
</action-widgets>
</object>
</interface>

View file

@ -115,6 +115,7 @@ class TestSamples(unittest.TestCase):
def test_samples(self):
self.assert_sample("accessibility")
self.assert_sample("action_widgets")
self.assert_sample("binding")
self.assert_sample("child_type")
self.assert_sample("combo_box_text")
@ -145,6 +146,13 @@ class TestSamples(unittest.TestCase):
self.assert_sample_error("a11y_prop_dne")
self.assert_sample_error("a11y_prop_obj_dne")
self.assert_sample_error("a11y_prop_type")
self.assert_sample_error("action_widget_float_response")
self.assert_sample_error("action_widget_have_no_id")
self.assert_sample_error("action_widget_multiple_default")
self.assert_sample_error("action_widget_not_action")
self.assert_sample_error("action_widget_not_in_dialog")
self.assert_sample_error("action_widget_response_dne")
self.assert_sample_error("action_widget_negative_response")
self.assert_sample_error("class_assign")
self.assert_sample_error("class_dne")
self.assert_sample_error("consecutive_unexpected_tokens")