Commit graph

207 commits

Author SHA1 Message Date
Vadim Zeitlin
19aee81c1d Update nanosvg to the latest upstream version
This notably fixes crash with SVGs using 1 stop gradients.

Relax the check in a test added in #24064 as it doesn't quite pass with
the new version -- this is somewhat suspicious but as it wasn't really
clear where did the original tolerance of 3 come from, it doesn't seem
to be a huge problem to increase it to 4 neither.

Closes #24213.
2024-01-19 21:17:43 +01:00
Vadim Zeitlin
9cc5e5d276 Add wxBitmap::CreateWithLogicalSize()
This function should be used instead of CreateWithDIPSize() in portable
code, the latter is currently often used to do what this function is
doing, but this only works correctly in wxOSX and wxGTK3 but not wxMSW.
2024-01-09 03:15:56 +01:00
Paul Cornett
f1731fd672 Return index of first added image in wxImageList::Add()
This is what MSW does. Broken in c374eefd34 (Fold wxOSX-specific wxImageList into
generic version, 2018-10-30)
See #10013
2023-12-28 12:49:47 -08:00
Tim Eliseo
06e3e26ead Add checks to BitmapBundle::FromSVG-alpha test to catch lack of SVG premultiply. 2023-11-28 13:36:06 -08:00
Tim Eliseo
a160e788ae Add test BitmapBundle::FromSVG-alpha to verify SVG alpha premultiply fix.
See #24064.
2023-11-26 13:29:41 -08:00
Tim Eliseo
fce4941404 Add wxHAS_PREMULTIPLIED_ALPHA to abstract if wxBitmap pixels are premultiplied.
All previous relevant platform-specific tests have been changed to use this
symbol. Also, samples/image now premultiplies conditionally, correcting a
visual anomaly on wxGTK.
2023-11-26 13:23:52 -08:00
Vadim Zeitlin
5a184d423b Merge branch 'qt-uiaction-tests' of https://github.com/AliKet/wxWidgets
Enable automatic tests using wxUIActionSimulator under wxQt.

See #24015.
2023-11-17 01:05:56 +01:00
Vadim Zeitlin
53b4f4ddf2 Use physical size in wxImageList
This seems to be the only way to fix using this class, which is
fundamentally incompatible with high DPI support, with bitmaps of
different logical but identical physical sizes.

By using physical size we ensure that the code chopping up the provided
bitmap in multiple images doesn't do it with the bitmap having the same
physical size but a different logical size from all the other bitmaps.
And, conceptually, logical size of the bitmaps in it really shouldn't
matter to the image list as it doesn't have a scaling factor and so
can't do anything useful with the logical size.

Moreover, we can't add wxImageList::SetScaleFactor() neither because
this class is, by design, supposed to be shareable between different
controls which may use different scale factors, so it doesn't make sense
to speak of the scale factor of the image list itself.

This undoes the changes made in the generic implementation back in
c374eefd34 (Fold wxOSX-specific wxImageList into generic version,
2018-10-30) and also eb52e86553 (Take into account scale factor of
images added to wxImageList, 2021-04-03).

Also update a couple of places where wxImageList is still used to use
physical sizes. Unfortunately some others can't be easily fixed, e.g.
global wxFileIconsTable would have to be completely rewritten.

Finally, add a unit test checking that things work as expected now:
previously the size of 24x24 bitmap in the image list containing
(scaled) 32x32 bitmaps would be 21x21 due to sub-bitmap extraction
kicking in.

Closes #23994.
2023-11-06 21:18:34 +01:00
ali kettab
aa4a19cb1d Fix or skip other failures in the tests under wxQt 2023-11-01 00:39:19 +01:00
Vadim Zeitlin
8f3331e8c1 Fix assert checking input size in wxOSX GetSubBitmap()
Extend the just added GetSubBitmap() unit test to check for this too.
2023-10-29 01:48:29 +02:00
Vadim Zeitlin
2cf77c2596 Fix GetSubBitmap() returned value size when rounding is required
When using non-integer scale factor, we need to round the result of the
multiplication by it instead of truncating it for consistency with the
behaviour of wxBitmap::CreateWithDIPSize() and the other places where we
do this, including wxOSX version of this function.

Add a simple unit test checking that this works correctly (it would fail
with wxGTK before).
2023-10-29 01:48:27 +02:00
Vadim Zeitlin
4048542d54 Move test not depending on it outside wxHAS_RAW_BITMAP check
No real changes, just don't put the test not using raw bitmap access
inside the section guarded by "#if wxHAS_RAW_BITMAP".

This commit is best viewed with Git --color-moved option.
2023-10-29 01:48:11 +02:00
ali kettab
1f606cd925 Skip test which work locally, but not when run on GitHub CI under wxQt 2023-10-15 00:10:02 +01:00
Vadim Zeitlin
fa5964c100 Use WaitFor() and new YieldForAWhile() helpers in the tests
Reuse the existing function (and another new one, which is even simpler)
instead of duplicating its code in many places in the tests.

No real changes.
2023-10-02 15:10:36 +02:00
Vadim Zeitlin
55e074f5bc Rename tests/waitforpaint.h into just waitfor.h
No changes yet, just prepare for adding more "waiting" helpers.
2023-10-01 21:25:46 +02:00
ali kettab
d986aed5cd Fixup! get rid of unnecessary hacks
The discrepancy with the other ports was fixed by the previous two commits.
2023-09-19 00:58:47 +01:00
ali kettab
160d171077 Fix wxGraphicsBitmap creation after recent changes to wxBitmap under wxQt 2023-09-13 21:11:26 +01:00
ali kettab
d9e3efcf20 Update bitmap tests for wxQt 2023-09-13 20:40:39 +01:00
Vadim Zeitlin
4d48e47811 Fix regression in destroying wxArtProvider objects
Don't delete the art provider object in Remove() as this contradicted
its contract and do restore the call to Remove() from wxArtProvider dtor
as it's actually documented to work.

This fixes a regression due to the changes of 4a294caacd (Stop using
macro-based wxList in wxArtProvider code, 2023-04-11).

Closes #23513.

Closes #23529.
2023-05-08 15:13:35 +01:00
Vadim Zeitlin
363f0988cf Replace wxScopedPtr with std::unique_ptr in the tests
Just use the standard class instead of the wx one, as they can be used
in exactly the same way.
2023-03-06 23:34:44 +01:00
Artur Wieczorek
6674ce7fe6 Apply workaround to fix drawing glitches caused by
wxGraphicsContext::ResetClip (wxOSX)

Using native CGContextResetClip() to reset the clip causes some
drawing glitches - especially with drawing text with CT - see
https://github.com/wxWidgets/wxWidgets/issues/22629#issuecomment-1399554002
For the time being we have to revert to the previous code
with emulated resetting based on restoring the graphics context state.
We also have to disable a unit tests that fails with emulated
resetting the clip.

See #22629.
2023-01-31 22:32:41 +01:00
Artur Wieczorek
0e2fee1755 Enable wxPaintDC-related tests under wxOSX
With delay after refreshing testing window added in 808bbe8341 ("Fix
executing wxPaintDC-related tests under wxGTK", 2023-01-04) wxPaintDC
tests work also under wxOSX.
2023-01-04 21:59:10 +01:00
Artur Wieczorek
808bbe8341 Fix executing wxPaintDC-related tests under wxGTK
First child window has fixed size so we need to create a second window
and use it for wxPaintDC tests.
2023-01-04 19:59:32 +01:00
Artur Wieczorek
09521f81e9 Test whether wxDC attributes are unchanged by clipping operations 2022-12-29 12:39:27 +01:00
Artur Wieczorek
227cd581f8 Add tests of wxDCClipper 2022-12-29 12:39:27 +01:00
Artur Wieczorek
41a390317c Enable wxPaintDC test under wxGTK3
Test should pass now.
2022-12-22 18:42:57 +01:00
Artur Wieczorek
6ba55b96b8 Skip all wxPaintDC tests for clipping on wxOSX
All test are known to fail because there is a problem with effectively
repainting a window in the testing environment.
2022-12-18 17:18:03 +01:00
Artur Wieczorek
e09bf951b9 Skip test known to fail on wxGTK3 2022-12-18 17:18:03 +01:00
Artur Wieczorek
9af0f9f463 Replace wxClientDC tests with wxPaintDC ones 2022-12-18 17:18:03 +01:00
Artur Wieczorek
2b4ee50f34 Reimplement tests with Catch
Use Catch instead of CppUnit for all unit tests here.
2022-12-07 20:52:33 +01:00
Artur Wieczorek
32041aa279 Refactor tests to utilize sections
The structure of tests is more clear now.
2022-12-06 22:32:35 +01:00
Artur Wieczorek
809b2ab7d9 Don't log warnings if RTL feature is not available for testing
If wxDC just doesn't support RTL the tests should be silently skipped.

Closes #23020.
2022-12-06 22:31:23 +01:00
Artur Wieczorek
c3eb9cbaa5 Try to ensure that testing window is shown
wxClientDC tests are reliable only if testing window is visible.
2022-12-01 19:29:52 +01:00
Artur Wieczorek
1baecca49a Add tests to check clipping for wxGCDC
Tests to check clipping when origin of the parent wxDC is shifted
and has negative coordinates.
2022-11-29 18:39:42 +01:00
Vadim Zeitlin
5c6bce627b Check wxImageList validity in all of its methods
Some of wxImageList methods asserted when called on an invalid image
list while others just failed silently.

Assert in all of them now for consistency and to help detecting problems
in the code using invalid wxImageList objects.

Extend the documentation and the tests.
2022-11-26 23:29:13 +01:00
Artur Wieczorek
f67077a66d Add tests to check clipping for wxGraphicsContext
More tests to check clipping when origin of the parent wxDC is shifted
and has negative coordinates.

See #22990.
2022-11-24 22:45:45 +01:00
Artur Wieczorek
3981139f3b Enable all tests of destroying clipping region for wxGTK 2022-10-28 11:37:58 +02:00
Artur Wieczorek
ed6c25beed Skip tests known not to work under wxGTK 2022-10-25 11:24:07 +02:00
Artur Wieczorek
7d3f776ec3 Extend tests to check clipping on wxGCDC when origin of its parent wxDC is shifted
See #22914.
See #22480.
2022-10-25 10:44:09 +02:00
Artur Wieczorek
9a2d594d9d Use logical 'and' operator in logical expressions 2022-10-25 10:42:47 +02:00
Artur Wieczorek
3c8ca52f0d Enclose test case tags in square brackets 2022-10-25 10:42:17 +02:00
Vadim Zeitlin
4f4c5fcfdf Use nullptr instead of NULL in the code and documentation
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
2022-10-18 01:25:25 +02:00
PB
88d526660f Replace wxOVERRIDE and wxNOEXCEPT with override and noexcept
Don't use deprecated macros in wxWidgets itself.
2022-10-15 18:10:45 +02:00
Vadim Zeitlin
691f78371b Fix build without SVG support after the last change
Only define the test using wxBitmapBundle::FromSVGFile() when wxHAS_SVG
is on.

This fixes the build breakage after the parent commit.

This commit is best viewed with --color-moved Git option.
2022-10-02 02:09:26 +02:00
Vadim Zeitlin
a952ad4f94 Add a simple pseudo-test allowing to test loading SVG file
This can be used to check if an SVG file can be loaded easily and is
similar to "wxImage::LoadPath" test and others like it.
2022-10-02 01:34:53 +02:00
Vadim Zeitlin
72f851f6f4 Remove the size parameter of wxBitmapBundle::GetConsensusSizeFor()
It doesn't seem to be useful and wasn't really specified in 2 out of 3
existing calls to this function and was probably wrongly specified in
the remaining one, so just remove it for now, it can always be added
later if we decide what exactly should it do.
2022-06-05 03:23:41 +02:00
Vadim Zeitlin
907e4ea862 Add wxBitmapBundle::GetConsensusSizeFor(double) and test it
Add an overload of the existing function which can be easily tested in
the unit tests and add a trivial new test for it.
2022-06-05 03:06:10 +02:00
Vadim Zeitlin
538eafc78b Fix bug with wrong GetIndexToUpscale() return value
Only assign known good values of the index to "indexLast" as otherwise
we could end up returning an invalid index value from it if "indexBest"
was never set and the last index wasn't a valid one, as it happened in
wxBitmapBundleImplSet containing an original bitmap and a x2 scaled copy
of it, which shouldn't be used for further scaling.

Add a unit test checking that this bug is fixed now.
2022-06-03 00:44:59 +01:00
Vadim Zeitlin
6d5bd15d12 Use non-integer scale that is exact multiple of an available one
Always rounding non-integer scale when upscaling is wrong, as we could
be able to upscale an existing x1.5 image to e.g. 300% DPI scaling with
relatively good results, so only do it if there is no available scale
that exactly divides the requested one.

Add a previously failing unit test which passes now.
2022-06-02 23:09:05 +01:00
Vadim Zeitlin
2d782443a4 Choose the best bitmap to rescale to the target size
It's not necessarily the largest bitmap, but one which may be scaled
using an integer factor.

Fix the tests to expect the correct results, now that they actually
pass.
2022-06-02 01:37:24 +01:00