2838 Commits

Author SHA1 Message Date
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
Vadim Zeitlin
3414e6a1d4 Extend wxBitmapBundle unit tests for bitmap scaling
Check not only that the resulting bitmap has the right size, but also
that it was obtained by scaling the correct bitmap.

Define the required machinery to allow using CATCH CHECK_THAT() macro to
succinctly verify both.

Note that this doesn't change the existing tests, but just rewrites them
in a new form and also adds more tests for a bundle with 3 bitmaps.
2022-06-02 01:37:24 +01:00
Vadim Zeitlin
30fb836136 Break the tie in favour of smaller bitmaps at 1.5x factor
Prefer to use 1x bitmap to 2x one at 150% scaling, as it seems better to
use smaller (but still readable) bitmaps than overlarge ones in this
case.
2022-06-02 01:37:24 +01:00
Vadim Zeitlin
0b0e95296a Upscale images by integer factors only
Doing anything else results in really poor results, so don't even try
scaling images by 2.25, for example -- scaling by 2 looks much better
and the size difference is relatively insignificant and definitely not
worth the difference in quality.
2022-06-02 01:37:24 +01:00
Artur Wieczorek
b9cb57eceb Test wxPropertyGrid headers compilation without implicit wxString conversion
Add wxPropertyGrid headers to the list of headers compiled with
wxNO_IMPLICIT_WXSTRING_ENCODING.

See #22102.
2022-05-30 19:06:37 +02:00
Vadim Zeitlin
8169464516 Suppress harmless MSVC warnings in atomic unit test
The changes of 50bc3ceb04 (Get rid of CppUnit boilerplate in atomic unit
test, 2022-05-11) resulted in warnings about possibly uninitialized
variables in this test, so do initialize them for MSVC even if it isn't
really necessary.
2022-05-23 15:05:47 +01:00
Vadim Zeitlin
15705b3350 Simplify bitmap size checks in wxImageList tests
Also don't hardcode 32*32 size but make it a constant that could be
changed later.
2022-05-23 15:05:47 +01:00
Vadim Zeitlin
2373b4ca24 Construct the test bitmaps directly in wxImageList test code
Don't use external image files, this makes it simpler to run the test
(it can be now done from any directory) and also experiment with it
(e.g. by making the test image fully transparent or fully opaque).

Remove the now unneeded .ico file but keep the .png one still used by
another test.
2022-05-23 15:05:47 +01:00
Vadim Zeitlin
1ed13da86e Factor out common initialization code in wxImageList tests
No changes, just stop duplicating exactly the same initialization code
for the tests with and without masks.
2022-05-18 15:43:31 +01:00
Vadim Zeitlin
2ba9007d0e Add wxCHECK_CXX_STD() and use it to test for C++17 and C++20
Unlike direct tests of __cplusplus, using this macro also works with
(recent enough, i.e. MSVS 2015.3 or later) MSVC versions, even if
/Zc:__cplusplus is not used.

This simplifies some checks and makes some other ones (notably the check
for C++20 used before wxALLOW_COMBINING_ENUMS macro definition) work
with MSVC versions with C++20 support as intended.
2022-05-11 16:57:18 +01:00
Vadim Zeitlin
a7eee933c6 Merge branch 'tsan-warnings'
Fix a harmless warning from thread sanitizer and make wxAtomicInc() more
useful.

See #22417.
2022-05-11 02:37:26 +02:00
Vadim Zeitlin
cf66ce5f94 Return the new value from wxAtomicInc() too
This is easy to do and can be useful when using an atomic initialization
counter.

The only platform where not returning the new value might be more
efficient than returning it is Solaris which is not really relevant any
more and on all the other platforms the functions we were already using
provided this value already (or almost, in case of using gcc builtins,
when we just have to use a different one).
2022-05-11 00:16:47 +02:00
Vadim Zeitlin
e82290f0da Use wxVector instead of array macro in atomic unit test
No real changes.
2022-05-11 00:08:52 +02:00
Vadim Zeitlin
50bc3ceb04 Get rid of CppUnit boilerplate in atomic unit test
Also use a single test function with different sections instead of using
a helper function with 4 wrappers calling it for simplicity.
2022-05-11 00:08:03 +02:00
Vadim Zeitlin
a2e68f43ea Avoid direct access to an atomic variable in the test
This (correctly) results in a warning about data race from TSAN, so
don't do it and use the return value of wxAtomicDec() instead.
2022-05-10 23:55:25 +02:00
Vadim Zeitlin
44131b044d Use the same number of iterations in atomic unit test
Use reasonably, but not too, big number, so that the test doesn't run
too long, even when TSAN is used.

This also simplifies the code.
2022-05-10 23:54:21 +02:00
Vadim Zeitlin
6feeed9fe9 Handle transparency to the best of our ability in wxImageList
Don't take the value of "mask" parameter of wxImageList constructor too
prescriptively, it predates support for alpha in wxWidgets by many years
and was never meant to actually suppress using it.

Instead, do the best thing we can in all cases, i.e. use alpha if it's
specified and supported and use mask otherwise. But only create the mask
from light grey colour if we have nothing else if "mask" is true in
wxImageList constructor, as this is a potentially destructive action
that must not be performed if the user has explicitly decided to set
this parameter to false.

Incidentally fix handling of alpha with comctl32.dll v5 (which is used
in the absence of any manifest) by converting it to a mask in this case:
this is not ideal, but better than just using black background as it
happened before, and restores pre-3.1.5 behaviour.

Also simplify the generic version which just has to create the default
mask if necessary and doesn't have to do anything at all in all the
other cases.

Note that these changes required relaxing some of the existing unit
tests as wxMSW implementation now can add alpha channel to the bitmaps
that didn't have it -- but this is a more useful behaviour, and so it
makes more sense to adapt the tests to it rather than doing a less
useful thing just to conform to the tests.

This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-spac options.

Closes #22349.
2022-05-06 02:12:54 +01:00
Vadim Zeitlin
3cc55d5b66 Add a workaround for failing test under Wine
Debugging confirms that DPtoLP() simply returns wrong (i.e. different
from that returned under actual MSW) result when using Wine, so just
account for it in the test as it seems to be better than just skipping
the test entirely under Wine and there doesn't seem to be anything else
to do.
2022-05-02 22:42:42 +02:00
Frode Roxrud Gill
f646e8b11c Allow cloning client data stored in wxGrid attributes etc
Add wxSharedClientDataContainer class storing ref-counted client data
and use it instead of plain wxClientDataContainer in wxGridCellAttr,
wxGridCellEditor and wxGridCellRenderer classes.

This allows to keep the same client data associated with many grid cells
without having to make many copies of it.
2022-04-28 00:28:58 +02:00
Vadim Zeitlin
5d5591816d Update to bakefile 0.2.13 to fix DLL directory creation
Fix the bug introduced in ec0734f96f (Install DLLs in bindir, not
libdir, when using MSW toolchains, 2021-01-09): the directory where the
DLLs were installed wasn't created any more, resulting in errors if it
didn't exist.

Update to latest bakefile version adding the missing mkdir command to
fix this and also use a released bakefile version for the wx makefiles.

Regenerate configure to match the new version.

See #14601.
2022-04-23 23:11:31 +02:00
Vadim Zeitlin
da05a3770f Use address of www.wxwidgets.org instead of its name in HTTP URLs
The name resolves to Cloudflare proxy which redirects all HTTP URLs to
HTTPS, which breaks the existing tests using HTTP, so prevent this from
happening by using the actual IP address instead.
2022-04-23 18:03:25 +01:00
Vadim Zeitlin
9c4fe82242 Cache the results of network availability check
It's unlikely to change while the tests are running, so don't redo it
needlessly.
2022-04-23 17:55:24 +01:00
Vadim Zeitlin
239bbd6b82 Check that we can actually read from network and not just connect
When using Cloudflare, as we do for www.wxwidgets.org, the connection
succeeds as long as Cloudflare itself works, but reading later fails if
the real server behind Cloudflare proxy does not, so check if we can
read something from it.
2022-04-23 17:55:24 +01:00
Vadim Zeitlin
860dd39fab Check connection to www.wxwidgets.org and not www.google.com
Our tests use the former and not the latter, so check connection to the
site we're actually interested in.
2022-04-23 16:16:01 +01:00
Vadim Zeitlin
668563f2b0 Rewrite ImageTestCase using CATCH macros
Get rid of the ugly WX_ASSERT_MESSAGE() and also use REQUIRE/CATCH
directly instead of CppUnit compatibility macros.

Also use sections to execute the next loop iteration(s) even if the
current one fails.

This commit is best viewed ignoring whitespace-only changes.
2022-04-23 16:08:14 +01:00
Vadim Zeitlin
89a7a070ea Use WARN() instead of wxLogWarning() in the unit tests
The latter isn't shown at all by default while the former one is.
2022-04-23 15:36:40 +01:00
Vadim Zeitlin
684dd4a5a6 Use wxScopedPtr in wxImage unit test
Don't manage memory manually, this resulted in error leaks if any checks
failed.
2022-04-23 15:35:22 +01:00
Vadim Zeitlin
bf3b653492 Merge branch 'auibook-help'
Fix infinite recursion when processing wxEVT_HELP for wxAuiNotebook
pages.

See #22323.

Closes #22309.
2022-04-19 00:38:39 +02:00
Stefan Csomor
7fc2024f0e support required compilation failure for comboboxtest on platforms with wxUSE_COMBOBOX==0 2022-04-18 19:29:45 +02:00
Vadim Zeitlin
02434dcc1f Workaround a crash with MSYS2 gcc 9.1 again
The changes of 2144ca38d2 (Get rid of CppUnit boilerplate in
DynamicLibraryTestCase, 2022-04-17) accidentally undid the workaround
from 054cb35b39 (Workaround for a crash with gcc 9.1 from MSYS2 MinGW
32bit, 2019-08-03), so work around the same problem again by avoiding
using CHECK() with function pointers.
2022-04-18 14:36:52 +02:00
Vadim Zeitlin
61e24f6be0 Give more information if wxFont unit tests fail
Use INFO() to provide extra information instead of the ugly
WX_ASSERT_MESSAGE().
2022-04-18 14:29:53 +02:00
Vadim Zeitlin
b66d4488e1 Merge branch 'fn-long-path'
Fix wxPATH_NORM_LONG with UNC paths and slightly optimize long path
normalization.

See #22307.
2022-04-17 18:51:09 +02:00
Vadim Zeitlin
2144ca38d2 Get rid of CppUnit boilerplate in DynamicLibraryTestCase
Use CATCH macros directly, this is simpler and more clear.

Also use narrow strings instead of wide ones and get rid of wxT() too.

No real changes.

This commit is best viewed ignoring whitespace-only changes.
2022-04-17 18:44:51 +02:00
Vadim Zeitlin
f3b4ee3b5f Skip dynamic library file existence check under Darwin
Under Monterrey (macOS 10.12) we can actually load the file using
wxDynamicLibrary even though it does _not_ exist on the disk, so don't
skip the test just because of this.
2022-04-17 18:38:08 +02:00
Vadim Zeitlin
c6b3b4a39c Make the warning in DynamicLibraryTestCase actually visible
Using wxLogWarning() doesn't work as logs are suppressed by default, but
using CATCH WARN() macro does work.
2022-04-17 18:35:34 +02:00
Vadim Zeitlin
6a48431ca1 Add missing wxLogWarning() argument to wxDynamicLibrary test
The argument corresponding to the "%s" format specifier was missing,
which resulted in a crash if the dynamic library tested didn't actually
exist.
2022-04-17 18:30:42 +02:00
Vadim Zeitlin
fac4822ab3 Make wxAuiNotebook::FindPage() work correctly
Make this function virtual in the base class so that it could be
overridden to do the right thing in wxAuiNotebook, instead of just
always returning NULL as before and add a unit test checking that it
works.

Explain that wxBookCtrlBase::m_pages may not be used in the derived
classes, but that in this case they must override all the methods using
it.

Finally, "soft-deprecate" wxAuiNotebook::GetPageIndex(), which is
identical to FindPage() now.

This fixes infinite recursion when handling wxEVT_HELP in wxAuiNotebook
in wxUniv too, see #22309.

Closes #15932.
2022-04-16 23:01:57 +01:00
Vadim Zeitlin
35d08e6a87 Don't corrupt UNC paths when normalizing with wxPATH_NORM_LONG
After the fixes to UNC paths handling, Normalize(wxPATH_NORM_LONG)
started adding an extra colon after the UNC paths.

Fix this by using wxGetVolumeString() instead of constructing this thing
manually and add a unit test checking for this.

Closes #22275.
2022-04-15 00:32:35 +01:00
Vadim Zeitlin
e50c7b2e2f Add GetDOSPath() helper to wxFileName unit test
No real changes.
2022-04-15 00:13:07 +01:00
Vadim Zeitlin
0ba4cf8ac9 Avoid spurious MSVC warning about uninitialized variable
Use wxDUMMY_INITIALIZE() to suppress a warning in wxDVC unit test.
2022-04-14 17:46:39 +01:00
Vadim Zeitlin
4e6e1ce054 Show debug log messages on the console in the test when enabled
Using LogEnabler in wxFileSystemWatcher test case still didn't show
anything even in case of unexpected failures because debug messages
didn't appear in the test output.

Fix this by using a custom log target which shows the debug (and trace)
messages on stderr, instead of using the debug output for them, even
under MSW.

Also make LogEnabler public, and rename it to a more unique name, as it
could be useful in the other tests too.
2022-04-14 17:37:32 +01:00
Vadim Zeitlin
ce46d77360 Merge branch 'bitmap-dc-ctor'
Add wxBitmap ctors taking wxDC to all ports and set the scale factor
correctly in the existing ctors taking wxDC in wxMSW.

See #22297.
2022-04-13 15:57:35 +02:00
Vadim Zeitlin
24970061fa Add wxBitmap(wxImage, wxDC) ctor to all ports
This ctor was previously present only in wxMSW, make it available in all
ports to allow the same code to compile everywhere.

In most of them wxDC argument is simply ignored, but in wxGTK and wxOSX
it is used to assign the appropriate scale factor for the new bitmap.

Enable previously wxMSW-only unit test checking for this.
2022-04-12 19:08:56 +01:00
Vadim Zeitlin
b185186ebf Handle scale factor in another wxMSW wxBitmap ctor taking wxDC
This is similar to db6d565fad (Handle wxDC scale factor in wxBitmap ctor
taking wxDC in wxMSW, 2022-04-10), but for the constructor taking
wxImage and wxDC -- it should also use the DC scale factor, even if it
is not used for scaling the bitmap size in this case.

Add a unit test checking for this.
2022-04-12 17:57:49 +01:00
Vadim Zeitlin
558a300996 Create bitmaps from image and a wxDC without an HDC in wxMSW
This is similar to 7382e99bbb (Create bitmaps even when given a wxDC
without an HDC in wxMSW, 2022-04-10) and does the same change to
wxBitmap ctor from wxImage and wxDC -- and also extends the unit test to
check for this under wxMSW, which is the only port in which this ctor is
currently available.
2022-04-12 17:30:42 +01:00
Maarten Bent
87465898f3 Fix unused variable warnings 2022-04-10 23:41:44 +02:00