247 Commits
Author SHA1 Message Date
Blake-Madden 06e1449e33 Add basic wxSVGFileDC unit tests
Add them directly to test_gui instead of using a separate test as before
to keep things simple.

Closes #27022.
2026-09-20 22:23:17 +02:00
Vadim Zeitlin c8003a0a06 Use make_unique<>() instead of "new" in the tests
No real changes, just avoid explicit "new" calls.
2026-09-04 15:24:34 +02:00
Scott Talbert b1ebdc45ee Use client size, not outer size, when sizing test window in ClippingBoxTestCase::wxPaintDC
The test computed the top-level window's target size by adding a fixed
50px margin to its outer (SetSize/GetSize) dimensions, assuming that
would leave enough room for window decorations plus the 260x300
child. But on platforms with substantial client-side decorations
(e.g. GTK3 under GNOME/Wayland, where title bar + resize margins can
total ~90px vertically), that margin isn't enough, so the child
window ends up clipped below its expected size. Comparing against and
setting the client size instead makes the requested area correct
regardless of how large the actual decoration overhead is.
2026-08-31 19:30:10 -04:00
Vadim Zeitlin ccc264fdb7 Convert wxAffineMatrix2D tests to use Catch directly
These tests use several fixtures deriving from each other and running the
same tests, so define the test cases for all of them using a helper macro.

Also merge setUp() and tearDown() into the fixture ctor and dtor.

No real changes.

Assisted-by: Claude Opus 5
2026-08-24 18:46:44 +02:00
Vadim Zeitlin 87ecf894e9 Convert simple GUI unit tests to use Catch directly
Get rid of the CppUnit compatibility macros in the GUI test files not
requiring any special handling: replace the test suite classes with Catch
fixtures, setUp()/tearDown() with the ctor/dtor and CPPUNIT_ASSERT_XXX()
with CHECK().

Tests using wxUIActionSimulator don't use WXUISIM_TEST() any more but
check EnableUITests() at the beginning of the test itself instead.

The pseudo test PseudoTest_Inversed in the wxSlider tests is replaced with
GENERATE() rerunning the tests for both normal and inversed sliders.

No real changes.

Assisted-by: Claude Opus 5
2026-08-24 18:46:44 +02:00
Richard abcca3c5f9 tests/graphics: Compare restored DC font with realized font
Some DC implementations can normalize the requested font when it is selected
into the DC. Save the font actually returned by the DC after applying the
font changer, and verify that clipping restores that realized font.
2026-08-13 21:42:14 -06:00
Vadim Zeitlin c95ec21feb Allow using spaces in named colours names again
After the changes of 55be0ed986 (Stop using GDK functions for parsing
colours names, 2024-12-16) we didn't find non-legacy named colours with
spaces in their names any longer, as we matched the name exactly (except
for the case) but the new colour names don't always use spaces.

Fix this by allowing to use spaces anywhere in the colour name and just
stripping all of them before looking the colour up.

Closes #26782.
2026-08-06 22:24:44 +02:00
Vadim Zeitlin fe360d4d01 Handle invalid wxColour better in unit test assertions
Show invalid colour as "invalid" instead of "" and don't trigger a wx
assertion when comparing with it.
2026-08-06 22:15:55 +02:00
Blake-Madden ee4fbdfb88 Add getters to wxSVGAttributes, add unit tests
Closes #26479.
2026-05-21 22:45:09 +02:00
Vadim Zeitlin 1bebb41046 Merge branch 'msw-rtl-fixes' of github.com:AliKet/wxWidgets
Don't mirror coordinates passed to GDI functions in RTL layout as they
already mirror them internally, resulting in incorrect coordinates being
used. As a consequence, wxDC::LogicalToDevice() now always returns
unmirrored coordinates, even in RTL layout, which is consistent with
wxGTK3 and wxQt.

Also fix scaling even in LTR layout by using ::ScaleWindowExtEx().

See #26398.
2026-05-19 03:15:07 +02:00
Vadim Zeitlin e1c72e28fc Add wxSVGGraphicsContext
Allow using wxGraphicsContext API for SVG generation.

Also add wxSVGFileDC::Begin/EndLayer() and wxSVGLayer RAII helper.

Closes #26395.
2026-05-19 03:01:39 +02:00
AliKet 8a59e5a7f2 Update OneDevRegionRTL test after recent changes 2026-05-16 14:12:50 +01:00
ali kettab e57681d773 Update OneDevRegionRTL test after recent changes 2026-05-06 18:22:44 +01:00
Vadim Zeitlin f736265bb9 Generalize Wine workaround to TransformedWithMatrixAndStd() too
Previously this was only needed in TransformedWithMatrixAndStdEx() which
verified that conversion actually worked, but not in the non-Ex version
using individual coordinates as it only verified that the conversions
failed, which they also did under Wine.

But now that they should work (and do, under native Windows), we need
the same workaround there as well.

Also make sure that we output the warning message about the workaround
not being needed any longer only once and only if it's really not needed
(if it's used for some values, we still have to keep it, even if it's
not used for the other ones).
2026-04-04 23:35:31 +02:00
Vadim Zeitlin 5d28a30c50 Reimplement wxDC X/Y transformations in terms of wxPoint/wxSize
Both DeviceToLogical{X,Y}() and DeviceToLogical() taking wxPoint were
virtual, with the latter implemented in terms of the former by default,
which meant that overriding only that function, but not the ones taking
X/Y coordinates individually, could result in inconsistent behaviour,
which is exactly what happened in wxMSW.

Make it impossible for this to happen by only allowing to override the
functions taking wxPoint (or wxSize for "relative" variant) and
reimplementing the functions working with individual components in terms
of the virtual functions.

The same goes for LogicalToDevice() and "Rel" variants.

As an important side effect, this fixes a bug in wxDC::StretchBlit() in
wxMSW when using RTL layout as the code there used LogicalToDevice{X,Y}
functions that didn't return the correct values before this commit.

Update the tests to not test for the wrong behaviour of per-coordinate
translation functions now that they behave correctly. Also remove the
tests checking that per-coordinate translation doesn't work when the
transformation matrix includes a rotational component.

Update the documentation to emphasize that converting both coordinates
at once is preferred.

See #19344, #26266.
2026-04-04 20:58:14 +02:00
ali kettab d8263f8d6d Ignore BitmapBundle::ArtProvider test failing under xvfb with Qt < 5.12 2026-02-20 23:47:56 +01:00
ali kettab 20437b4973 Fix BitmapBundle::ArtProvider test failing in wxQt after recent changes 2026-02-20 08:11:02 +01:00
Maarten Bent c9798cada1 CMake: Add missing test files
Run GUI resource tests on WXMSW only.
Fix mouse enter/leave events test in wxQt by yielding longer.
2026-01-25 22:08:21 +01:00
ali kettab 553aa06e39 Relax the clip box check in OneDevRegionRTL test case
Due to rounding errors, this test would fail under wxMSW if the region started
at x=2*n, and would fail under wxQt if it started at x=2*n+1. So relax the check
by using 1 as a position tolerance.
2025-11-03 00:33:04 +01:00
AliKet fcae63b695 Fix OneDevRegionRTL test case after the changes done to wxMSW and wxGTK3 2025-10-20 14:44:29 +01:00
Blake-Madden aef78cba70 Migrate some affine matrix tests to Catch2 2025-09-08 10:55:54 -04:00
Vadim Zeitlin 13b6526c5e Make wxGCDC moveable too and test using its move ctor
Modify a test case to use move ctor.
2025-08-26 00:03:33 +02:00
Blake-Madden a1a0d38508 Add functions for testing wxColour opacity
Add IsTransparent(), IsOpaque() and IsTranslucent() as more readable
synonyms for testing the value of GetAlpha() directly.

Closes #25628.
2025-07-12 16:04:01 +02:00
Vadim Zeitlin af61bbe43c Trim trailing whitespace from all sources
This whitespace was annoying as it was getting automatically removed by
the contributors working with the editors respecting the settings in our
own .editorconfig and so resulting in patches that mixed significant and
whitespace-only changes.

Remove it once again (this has been already done before in 8fbca5cb70
(Remove all trailing spaces, 2019-01-30) but apparently only partially)
to avoid the problem.
2025-06-28 14:40:58 +02:00
Vadim Zeitlin 1467303724 Fix bitmap test compilation for some ports when not using PCH
This fixed wxX11 CI build error.
2025-02-18 01:25:08 +01:00
Vadim Zeitlin 7a7610713d Add simple wxColourDatabase unit test
Notably check that the recently added UseScheme() works.
2024-12-14 01:22:54 +01:00
Lauri Nurmi 87c1aae252 Fix double negatives used with 'neither'
Replace most 'neither' words introduced after 2b0ee48ef7
(Fix double negatives used with 'neither', 2023-11-25)
with 'either'.

All changes are to comments only.

Closes #24999.
2024-12-11 17:57:46 +01:00
Lauri Nurmi 463d903b23 Add the wxWARN_UNUSED attribute for wxColour; remove unused 2024-10-10 20:21:06 +03:00
Bill Su 78bc9f24f3 Add unit test for ellipse boundary pixels
Add test verifying that the ellipse is drawn in the expected way, even
if this is not really intuitive because it can overflow its bounding
rectangle.

Closes #24620.
2024-08-11 22:19:12 +02:00
Vadim Zeitlin 31f59355a0 Really fix wxBitmapBundleImpl::GetIndexToUpscale() return value
The changes of 538eafc78b (Fix bug with wrong GetIndexToUpscale() return
value, 2022-06-03) were wrong but happened to work when there were no
down-scaled versions of the bitmap in the bundle.

But in general, we shouldn't use the previous index, but the index just
before the one with the most appropriate scale, so do this, and extend
the unit test to check for this scenario too -- previously it would fail
due to an assert failure when we tried to upscale a previously
downscaled bitmap.
2024-07-16 14:51:07 +02:00
Vadim Zeitlin a6203be954 Fix crash when copying wxBitmaps in wxMSW if DIB creation fails
This shouldn't normally happen, but if it does, e.g. because all the GDI
resources have been exhaused, we still shouldn't crash, so check for
this.

Also add a (disabled by default as it could be potentially dangerous to
run it) test checking that we don't crash in this case.

See #24703.
2024-07-15 23:09:03 +02:00
Vadim Zeitlin 6286fc5ca0 Fix adding smaller bitmap versions to wxBitmapBundle
Smaller bitmap was inserted in a wrong place, resulting in the entries
array not being sorted by bitmap size any longer and completely breaking
the logic of GetBitmap() which relied on it being sorted.

In particular, this meant that we kept recreating smaller version of the
first bitmap in the bundle again and again when the function was called
for the bitmap of the same size, which resulted in unbounded resource
consumption and, eventually, a crash.

Fix this by inserting the bitmap in the right place and add a unit test
checking that the number of GDI objects remains more or less constant
even after creating a lot of bitmaps.

Closes #24703.
2024-07-15 23:09:03 +02:00
Vadim Zeitlin 677af18194 Merge branch 'geom-cleanup-fixes'
Minor geometry classes cleanup and fixes.

See #24608.
2024-06-16 00:11:09 +02:00
Vadim Zeitlin cc6856593e Merge branch 'drawrect-size-1x1-test' of https://github.com/wsu-cb/wxWidgets
Document and test behavior of wxDC::DrawRectangle() with transparent pen

See #24597.
2024-06-16 00:04:55 +02:00
Vadim Zeitlin cae6c0176d Add missing implementations of wxPoint2D multiplicative operators
The overloads taking a scalar were never defined, even though they had
been declared in the very first version of this code back in 72e7876ba5
(wxMSW update for CW, wxMac updated, 1999-12-03).

Closes #24604.
2024-06-13 14:02:20 +02:00
Bill Su ffb5ff6b53 test behavior of wxMemoryDC::DrawRectangle() for wxSize(1, 1) 2024-06-09 22:00:16 -04:00
Vadim Zeitlin 7f5ca30e3e Do not scale the size of bitmap in wxMSW Create(size, dc) overload
The size passed to Create() should be interpreted in the same way as the
size passed to CreateWithLogicalSize() and in wxMSW this means that it
should _not_ be scaled.

This makes the size of the bitmap returned by this function overload
consistent with wxDC::GetSize(), so it looks like the right thing to do,
even if it's a backwards-incompatible change.

Closes #24559.
2024-06-09 12:23:03 +02:00
ali kettab 7e3554671a wxQt: Enable wxGC::GetTextExtent test case 2024-04-26 23:45:17 +01:00
Vadim Zeitlin b692c9ca46 Fix handling of sizes differing in width only in wxBitmapBundle
We assumed that bitmaps with the same height also have the same width,
but this is not necessarily true and if it did happen, GetBitmap()
failed it postcondition of returning the bitmap with the requested size.

Fix this by rescaling the closest bitmap to have the correct width even
if it already has the correct height.

Also enhance the bitmap comparator used for sorting to work correctly
with the bitmaps of the same height but different width.

Closes #24434.
2024-03-22 18:48:10 +01:00
Vadim Zeitlin d94de56783 Fix scale computation in wxBitmapBundle for some bitmap sizes
GetNextAvailableScale() returned wrong result when the bitmap size was
not exactly divisible by the scale, but this didn't matter for square
bitmaps because multiplying the default size by the not quite correct
scale still rounded to the correct size.

This was not the case for non-square bitmaps, however, as all our
computations use only bitmap height and dividing bitmap width by the
exact scale and multiplying it by the scale computed from the scaled and
unscaled height values could result in a value different from the
initial one, as shown by the newly added unit test, which failed before
this commit.

Fix this by computing the ratio of the bitmap to the base one and then
multiplying this ratio by the bitmap scale.

Closes #24433.
2024-03-22 18:48:10 +01:00
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