Commit Graph

28 Commits

Author SHA1 Message Date
Philip Withnall
c577bc89cd gsignal: Warn if g_signal_lookup() is called on an invalid signal name
And add a test for it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 11:06:14 +00:00
Philip Withnall
463a75c11e signals: Add tests for constructing signals with invalid names
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 11:06:14 +00:00
Philip Withnall
cce274c0aa signals: Add tests for g_signal_lookup() and g_signal_parse_name()
They’ve never previously been formally tested.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 11:06:14 +00:00
Philip Withnall
fb5cd1828f signals: Use g_assert_*() in signals tests rather than g_assert()
It provides more useful output on failure, and isn’t compiled out when
building with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 11:06:14 +00:00
Philip Withnall
89f955db2d gsignal: Canonicalise signal names at installation time
Rather than adding a canonicalised and non-canonicalised version of the
signal to `g_signal_key_bsa`, just add the canonicalised version. Signal
lookups always use the canonicalised key (since the previous commit).

This saves space in `g_signal_key_bsa`, which should speed up lookups;
and it saves significant space in the global `GQuark` table (a 9.6%
reduction in entries in that table, by a rough test using
gnome-software).

We have to be a little more relaxed on the signal name validation than
we are for property name validation, as GTK installs a
`-gtk-private-changed` signal which violates the signal naming rules.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-11-15 11:06:14 +00:00
Chun-wei Fan
e1e1e8ee1c gobject/tests/signals.c: Fix tests on Windows
On Windows and possibly other platforms the '%p' printf modifier does
not prefix printed values with '0x', so do not expect the warning
message to contain the '0x' prefix for the handler pointer value.
2019-06-25 00:01:02 +08:00
Marco Trevisan (Treviño)
20306597f5 tests, signals: Add tests for g_clear_signal_handler 2019-05-20 13:33:41 -05:00
Matthias Clasen
53d5a9f6fb Fix the signals test
The test setup here is not really independent, so the addition
of the custom-marshaller test was breaking some of the other
tests. Fix things up.
2016-08-27 22:54:39 -04:00
Benjamin Otte
edfbfc1827 tests: Add test showing default marshaller override
https://bugzilla.gnome.org/show_bug.cgi?id=769076
2016-08-25 13:26:58 -04:00
Benjamin Otte
58eae7782a tests: Do last commit's fix for enums, too
We don't want to treat enums as ints but as ints.
2015-09-16 18:45:48 +02:00
Benjamin Otte
605ff1efe7 tests: Make testcase not pass 0 as a flags value
This will not catch the case where we fail in libffi and always use 0.
In fact, be a real annoying person and use (1 << 31) as a flags value to
test signedness, too.

Also update the testcase to actually use flags everywhere and ot uint.

https://bugzilla.gnome.org/show_bug.cgi?id=754882
2015-09-16 18:45:48 +02:00
Iain Lane
261250c46e Test that disconnecting from the wrong thing warns and doesn't crash
This broke in 916297be79 (≥ 2.45.3)
2015-09-01 14:30:37 +01:00
Matthias Clasen
e81e33b35d Add a test for g_signal_get_invocation_hint
This is the sole piece of code in GLib where we make use of the
stack growing direction. And this test proves that we have been
getting the direction wrong all these years...
2013-11-23 20:06:07 -05:00
Stef Walter
27da0799b8 signals: Fix memory leaks in signals unit tests
https://bugzilla.gnome.org/show_bug.cgi?id=627423
2013-11-06 10:14:57 +01:00
Matthias Clasen
07168724d7 Improve signal test coverage 2013-05-29 08:37:19 -04:00
Colin Walters
4447d5ce11 tests/signals: Disable large enumeration value test that is failing on PPC64
Basically due to a combination of va_args semantics around
signed/unsigned ints, this test case fails on ppc64.  At the moment,
we have as yet to find any real-world consumer with such a large
enumeration value.

Unfortunately, the possible fixes for this are extremely invasive;
we would have to define a new enum API.

Given both of these facts, we believe it makes the most sense at the
current time to simply not test this. If we at a later time determine
there is such a real-world consumer, we can look at doing the
necessary fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=686662
2012-10-31 17:45:21 -04:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Ryan Lortie
66b0d95f0b [gsignal] Fix closure invalidation
If the closure is invalidated we drop the ref on the signal handler
node, but if the signal is currently being dispatched, the ref could be
held elsewhere.

Flag that we no longer have an outstanding invalidation handler so that
we don't try to unregister ourselves when the other ref drops.

Add a testcase that catches this situation.
2012-10-09 11:40:45 -04:00
Dan Winship
03be681e08 gobject/tests: plug leaks
https://bugzilla.gnome.org/show_bug.cgi?id=682560
2012-09-03 08:36:10 -04:00
Matthias Clasen
58f0173149 Add tests for signal convenience api 2012-04-23 08:20:22 -04:00
Chun-wei Fan
24fa2ee53c gobject/tests/signals.c: Remove C99ism
Declare variables in start of block.
2012-04-05 15:46:34 +08:00
Alexander Larsson
3d52ee999a Add more tests for signal emissions 2012-03-02 17:13:04 +01:00
Ryan Lortie
38e8ecd62a more 'static' adding in testcases
No dead code found this time...
2011-10-16 21:41:15 -04:00
Dan Williams
6feff14f19 tests: add signal marshalling return tests for int/uint
https://bugzilla.gnome.org/show_bug.cgi?id=659881
2011-09-28 11:01:53 -05:00
Dan Williams
a343904596 tests: fix generic closure marshalling tests
We're testing enums here, not flags, so we need to make sure
we're trying to send enums through the marshalling.

https://bugzilla.gnome.org/show_bug.cgi?id=659881
2011-09-28 11:01:39 -05:00
Dan Williams
adf7e0740c tests: Add some return value torture testcases for the generic marshaller
Ensure that ENUM types are properly marshalled back from libffi types
to glib types, which was failing on ppc64.

https://bugzilla.gnome.org/show_bug.cgi?id=659881
2011-09-28 11:01:14 -05:00
Colin Walters
1df8160fa6 tests: Add a some torture test cases for the generic marshaller
In particular this has a test case for a G_TYPE_ENUM which we were
running into a failure on ppc64.

https://bugzilla.gnome.org/show_bug.cgi?id=659881
2011-09-22 18:51:43 -04:00
Christian Persch
61b0e1c8d4 Add G_SIGNAL_MUST_COLLECT
In some cases, signal arguments have to be collected, even if there are i
no signal handlers connected (e.g. for GVariant parameters, where collection
consumes a floating variant).

Based on a patch by Christian Persch.

Bug #643624.
2011-03-15 01:32:22 -04:00