Commit Graph

423 Commits

Author SHA1 Message Date
Emmanuele Bassi
ba1a084899 Apply 1 suggestion(s) to 1 file(s) 2022-08-07 18:54:19 +00:00
Hannes Müller
703fc51d8e build: fix for use with glib 2.66.0
Add missing #define g_memdup2() for gdksurface-broadway.c in case of enabled
broadway-backend as used otherwise.

Copy static would_drop() replacement for g_log_writer_default_would_drop()
from gtk-builder-tool.c to gtk-reftest.c
2022-08-06 21:11:08 +02:00
Marco Melorio
6da65b25b6 reftests: Add content-fit picture tests 2022-07-16 17:53:13 +02:00
Marco Melorio
d8a73cbd03 picture: Add content-fit property
It allows to specify the resize mode of the paintable inside the
GtkPicture allocation. This also deprecates the keep-aspect-ratio
property.

Fixes #5027.
2022-07-15 23:01:23 +02:00
Benjamin Otte
2d14372142 reftests: Add an inscription xalign RTL test
This checks mainly that we do the right thing wrt PangoAlignment
weirdness.

0.25 and 0.75 are set to 0.0 and 1.0 currently because of Pango
limitations (and no desire to manually move lines).
But if that were to be fixed, both the ref and the test should update in
the same way and things should just keep working.
2022-06-13 06:49:22 +02:00
Benjamin Otte
4927b6e625 reftests: Add inscription reftest for xalign
Compare with labels again.
2022-06-13 06:49:11 +02:00
Benjamin Otte
4c1fc4f5d7 reftests: Test inscription multiline overflow 2022-06-12 02:42:00 +02:00
Benjamin Otte
4809efd630 reftests: Test overflowing inscription yalign
Overflowing inscriptions should always align to the top, even when half
an extra line is available.
2022-06-11 22:19:17 +02:00
Benjamin Otte
bf5edc6b7c reftests: Add test for the overflow methods
Reference is using labels again
2022-06-11 02:15:08 +02:00
Benjamin Otte
9973a7173f reftests: Add test for inscription markup parsing
Compare with label markup parsing as the reference.
2022-06-11 02:15:08 +02:00
Benjamin Otte
ffd3801b1d testsuite: Add tests for label overdraw
This brings back a subset of what quit-mnemonic.ui tested for, but
trying a lot harder to trigger the label overdrawing its allocation,
which will cause the text to be cut off when clipping is happening.

It should not be an issue at all with GTK4, but keeping that test around
is a good idea.
2022-05-17 00:14:19 +02:00
Matthias Clasen
1b355ff2e0 Drop the quit-mnemonic reftest
I can't quite figure out what this test was meant
to test, and how to make it do so in a way that
does not fall afoul of rendering issues in the GL
renderer and rounding differences in pango.

Can't win with reftests.
2022-05-14 17:03:37 -04:00
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