Commit Graph

411 Commits

Author SHA1 Message Date
Emmanuele Bassi
23aec81f1a reftest: Avoid assertions being compiled out
Calling functions inside a g_assert() means those functions will be
compiled out when building with G_DISABLE_ASSERT.

This fixes the release job in the CI pipeline.
2022-01-18 14:07:37 +00:00
Emmanuele Bassi
20ad839075 tests: Don't drop chdir()'s return value on the floor
Avoid a compile time warning, and ensure that the test suite is actually
doing its job.
2022-01-08 15:17:25 +00:00
Benjamin Otte
981ed22dff label: Add gtk_label_set_natural_wrap_mode()
Allows influencing natural size requests so that labels can request more
width than necessary for a given height.

Related: !4245
Related: #4535
2021-12-20 02:28:37 +01:00
Benjamin Otte
5face79cd0 label: word-char wrapping should word-wrap for natural size
Testcase added

Fixes #4535
2021-12-13 14:49:39 +01:00
Benjamin Otte
4de5d225db reftests: Add center-center reftests without GtkOverlay 2021-12-08 22:16:52 +03:00
Benjamin Otte
7741df9963 reftests: Rename a bunch of tests
They use a GtkOverlay, so reflect that in the name.
2021-12-08 22:16:52 +03:00
Ivan Molodetskikh
7ef54e9c53 picture: Return natural size 0 for size 0
It was returning the full natural size (same as -1) due to default value
handling in the code below.

Tests have been updated to match this output.
2021-12-08 19:20:24 +01:00
Benjamin Otte
07cfdd8ca0 label: Don't set ellipsized size as natural size
Natural size should never ellipsize.

Tests added.
2021-11-30 15:10:02 +01:00
Benjamin Otte
c025bc5098 paned: Compute the right handle size
Testcase included

Fixes #4469
2021-11-21 01:49:40 +01:00
Benjamin Otte
170bc0a8de window: properly compute desired size
Previously, the code did not expand the size properly when a default
size was already set.

Reftest included.
2021-11-21 01:31:06 +01:00
Benjamin Otte
a0ca936e8d sizerequestcache: Increase size
This is a quickfix to avoid infinite runtime in nested boxes with
wrapped labels.

Test included
2021-11-20 06:04:10 +01:00
Benjamin Otte
50e0893497 widget: force adjustment method is one size is FILL
If halign=fill, force adjustment to height-for-width.
If valign=fill, force adjustment to width-for-height.
Otherwise look at request mode.

This way we don't try to adapt the filled dimension and only adjust
the one that is not set to fill.
2021-11-20 06:04:10 +01:00
Benjamin Otte
7459d430eb widget: Don't forget margins when adjusting
This could lead to the wrong values being passed and computing invalid
sizes which would then lead to very unhappy code.

Test included.
2021-11-19 23:46:59 +01:00
Matthias Clasen
c86789427d Don't spam debug messages into TAP output
g_log_writer_standard_streams just puts all the logs
out onto stderr and stdout if we don't stop it. Pango
recently grew a bunch of g_debug calls, and those were
now showing up, making all the reftests fail.
2021-11-16 18:45:34 -05:00
Benjamin Otte
300a88922e build: Disable gcc warnings as warnings, too
We use -Werror in the build, so even if some warnings are just warnings,
they'd be errors.
2021-11-15 15:35:10 +01:00
Benjamin Otte
46f8600b6a css: Don't crash when color stop offsets descend
Testcase included.

Fixes #4424
2021-11-10 17:28:14 +01:00
Benjamin Otte
1e47b1c610 label: Handle width-chars > text width
This was broken in wrapping labels.

Testcase included.
2021-11-09 18:34:35 +01:00
Benjamin Otte
76c4673944 boxlayout: Fix broken min-size-for-opposite-size
Assume a vbox with 2 wrapping labels saying
  Hello World
  Hi Ho
being measured for their minimum width for 3 rows of text.
This should be layouted like
  Hello
  World
  Hi Ho
and measured accordingly.

However, previously this was layouted as
  Hello World
  Hi Ho
with 1.5 lines being assigned to both labels.
That will obviously not compute the above wrapping which clearly
results in a smaller min width.

A reftest testing exactly this was included.
2021-11-09 03:41:43 +01:00
Benjamin Otte
81169d18c3 label: max-width-chars should be ignored sometimes
When a widget is neither wrappable nor ellipsizable, we cannot modify
the label to fit into any size. So we cannot respect max-width-chars.
2021-11-09 03:41:43 +01:00
Benjamin Otte
cce6a603a6 label: max-width-chars has no effect on smaller text
Having a short text and a large max-width-chars should request the
natural width of the text, not the limit from max-width-chars.

This caused huge message dialogs.

Reftests added.
2021-11-09 03:41:43 +01:00
Benjamin Otte
577d520006 reftests: Add reftest for last 2 issues
Use a label that is long enough to require wrapping and force it into a
hardcoded width. Use a sentence where all the words have the same size
to not get unwanted wrapping behavior.

Also append a 2nd row to check that the first row gets the proper height
allocated.

Found by Marco Melorio.
2021-11-06 04:30:50 +01:00
Benjamin Otte
5c9ae28937 boxlayout: Compute opposite size properly
For size -1 in the opposite orientation, GtkBoxLayout used to measure
the children based on their min size in the box's orientation instead of
-1. That wasn't really intended, but was a side effect of how the sizing
code did (not) distribute extra size above the minimum size.

This is clearly not what we want.
What we want is measuring the orientation as is for size -1. Then we
want to just take the maximum of all children and use that.

A reftest is incldued that ensures a vbox wraps a label just like an
hbox does.
2021-11-05 20:30:49 +01:00
Benjamin Otte
8e27fc7f9b label: Redo measure() code
The old code couldn't properly do height-for-width because it only
computed the widest and smallest layout instead of looking at the actual
passed in for-size.

The label-sizing reftest has been adapted as the label code is now smart
enough to always display the whole text and no longer requests a too
small width-for-single-row when wrapping.
2021-11-05 20:29:42 +01:00
Benjamin Otte
53acff167b Revert "label: Never measure more than max-width-chars"
This reverts commit ba44e7a228.

The change was meant to revert to old GTK3 behavior but it actually
broke new GTK4 behavior that is in use where max-width-chars is used to
determine an ideal size, but where we don't want to limit the width to
that size.

So what happens is the reintroduction of GTK3-style lots of whitepsace
bugs, and we really don't want those.

We also don't want to break backwards compat if we can avoid it.

So let's revert this.

The reftest that was made for this purpose has been adapted.

Fixes #4399
2021-11-05 06:12:33 +01:00
Matthias Clasen
e017e4252b reftest: No blinking, please
Blinking cursors aren't helpful when we want to
compare renderings pixel-by-pixel. Turn them off.
2021-11-03 20:43:01 -04:00
Matthias Clasen
97365a8ffe reftest: Stop setting GDK_RENDERING
That environment variable isn't used anymore.
2021-11-03 20:40:22 -04:00
Benjamin Otte
ac8c4245b2 css: Don't throw warnings on broken URL in image css
If a URL can't be loaded, we might end up with a NULL file. Handle that
case properly by creating an invalid image instead and don't crash or
complain to stderr when files are NULL.

This was broken since 0886ade182

A new reftest has been included. We need a reftest instead of a
CSS parser test, because the error only becomes visible when
compute()ing the actual image.

Fixes #4373
2021-10-26 23:52:38 +02:00
Benjamin Otte
2113a18a18 testsuite: Add lots of reftests for picture sizing
Have square images in the following sizes:
  * 20
  * 100
  * 150
  * 200
  * 300
and place them in a can-shrink Picture allocated at the sizes:
  * 200x100
  * 100x200
and set align to center/center.

That's 10 combinations and they should all do the right thing.
2021-10-22 17:51:41 +02:00
Benjamin Otte
438bf8596e reftests: Don't crash if no node
If we have no node, don't crash when trying to save the node file.

Instead, write an empty file.
2021-10-22 17:51:40 +02:00
Benjamin Otte
192e554f3e testsuite: don't XFAIL label-sizing anymore
It's fixed now.
2021-10-19 01:10:59 +02:00
Benjamin Otte
00214cbb4a testsuite: Add test specifically for recent fix
label-sizing.ui tests this, too - but that test tests lots of other
things, and if this ever happens again, we want to debug it in a small
test.
2021-10-19 01:10:59 +02:00
Benjamin Otte
cad979b734 reftest: On failure, save the node files, too
Doesn't hurt to have them available, so it's easy to figure out if a
failure is due to the renderer or if we're generating wrong node files.
2021-10-19 01:01:36 +02:00
Benjamin Otte
30164d5b46 css: Render the background-clip area, not the background-origin
Testcase included

Fixes #4324
2021-10-07 19:59:44 +02:00
Matthias Clasen
c4069fdcee builder: Fix handling of <binding>
We were only applying <binding> elements when the
object is constructed, which can be triggered by
various things (e.g. a <style> element). Defer
this until we reach </object>, so we can be sure
that we pick up all the bindings.

Testcase included.

Fixes: #4147
2021-09-28 15:09:49 -04:00
Matthias Clasen
ec62402908 builder: Fix parsing of mixed declarations
The GtkBuilder parser constructs the object e.g.
when handling a <binding> element. There may be
more <property> elements after it, which we were
just not applying. Fix that by always applying
property when we see </object>. To do that, we
need to track the applied status per property.

Test included.

Fixes: #4208
2021-09-27 17:47:24 -04:00
Benjamin Otte
1ef000b1ab reftests: Add tests that check default-size is computed correctly
Related: #4136
2021-09-21 02:52:30 +00:00
Benjamin Otte
cf3830704b icontheme: Fix variable mixup leading to crashes
Note: Don't have 2 variables named "icon" and "gicon", you will screw
them up.

reftests included.

Fixes #4269
2021-09-17 17:41:13 +00:00
Benjamin Otte
83ea623775 reftests: Use the default (aka NGL) renderer
All tests pass with the renderer now, so we can remove useof the
fallback.
2021-09-16 23:59:37 +02:00
Benjamin Otte
345faa7250 reftests: XFAIL border-half-pixel test
the GL renderer can't deal with non-integers
2021-09-16 23:59:37 +02:00
Benjamin Otte
08df891070 reftests: Use colors without rounding errors
Color values must be divisible by 15 to be convertible into U8 and U16
values with the same result. 0x80 is not one of these values, so switch
it to 0x99.
2021-09-16 23:59:37 +02:00
Benjamin Otte
7cf5e5546b testsuite: Switch color from khaki to yellow
llvmpipe doesn't loike compositing semitransparent khaki onto solid
khaki without rounding errors.
2021-09-16 23:59:37 +02:00
Benjamin Otte
58f66ebd07 reftests: Make image-compare use textures
All image comparisons are done on textures now.
2021-09-16 23:59:37 +02:00
Benjamin Otte
47330598fb reftests: Use 0.6 instead of 0.5 for alpha
See previous commit about rounding
2021-09-16 23:59:37 +02:00
Benjamin Otte
90ed7b92b2 reftests: Use 0.6 alpha, not 0.5
0.5 leads to some GL renderers computing 0.5 * 0xFF as 0x7F and
others 0x80, while 0.6 * 0xFF (255 is divisible by 5) is always 0x99.
2021-09-16 23:59:37 +02:00
Benjamin Otte
0dfab46c15 reftests: Use GdkTexture instead of cairo_surface_t
This also switches the rendering code from using gsk_render_node_draw()
to gsk_renderer_render_texture().

Some tests are broken with the GL renderer, so this patch forces the
Cairo renderer until they get fixed.
2021-09-16 23:59:37 +02:00
Benjamin Otte
3a8ec683d3 reftests: Make diff pixels always opaque
We had pixels that did not differ in alpha and we then set 0 alpha
difference hich made the pixel invisible. Oops.
2021-09-16 23:59:37 +02:00
Benjamin Otte
de53b0c7a3 testsuite: remove box-order test
The test used to test that GtkBox ordered it's children left-to-right in
CSS, no matter the text direction or pack-type.

But there is neither a pack-type anymore nor does GTK4 do that.

So that test has been broken for yers, it just didn't render anything
wrong.
2021-09-16 23:59:37 +02:00
Simon McVittie
16b9a30655 reftest-compare: Treat colour channels as undefined if alpha is zero
If the alpha channel is zero, it doesn't matter what the values of the
red, green and blue channels are: the pixel is still fully transparent.
On most architectures, fully transparent pixels end up all-zeroes
(fully transparent black), matching what's in the reference PNG file;
but on mips*el the blend-difference and blend-normal tests get all-ones
(fully transparent white) and a test failure.

Resolves: https://gitlab.gnome.org/GNOME/gtk/-/issues/4227
Signed-off-by: Simon McVittie <smcv@debian.org>
2021-09-02 22:34:48 +01:00
Matthias Clasen
733fb527fa Revert "reftests: Enforce default settings"
This reverts commit 4e4f57e091.

This should not be necessary, since we have GDK_DEBUG=default-settings.
2021-08-30 11:01:22 -04:00
Matthias Clasen
e5e7f5dd88 ci: Disable treeview-headers-hidden reftest
Somebody needs to figure out why it fails in ci so
frequently.
2021-08-05 12:41:04 -04:00