Commit graph

3028 commits

Author SHA1 Message Date
Vadim Zeitlin
a1d9eecc7a Avoid failures in wxKill() unit tests under Windows 11
Apparently notepad can't be killed by sending WM_QUIT to its process
under Windows 11 because the process we launch is not actually the GUI
process showing the notepad window but some helper parent process.

Work around this by launching mspaint, which can still be killed by
wxKill(), instead.

Closes #23365.
2023-04-01 19:14:18 +02:00
Vadim Zeitlin
378f3860d2 Allow setting locale for the tests
This is especially useful to set an UTF-8 locale on the startup to force
using UTF-8-specific code in UTF-8 build.
2023-03-28 13:48:13 +01:00
Vadim Zeitlin
2b5dbd1ec5 Get rid of CppUnit boilerplate in wxString unit test
No real changes, just remove the completely useless StringTestCase and
use Catch macros directly instead of CPPUNIT_ASSERT wrappers.
2023-03-28 13:48:13 +01:00
Vadim Zeitlin
1869f9ec6f Use range for instead of iterators in unit test
No real changes, just simplify the code and ensure that iterating over a
string using range for loop works as expected.
2023-03-26 17:56:55 +01:00
Ryan Norton
e1c3962aa9 Improve wxURI parsing
- Update parsing IPvX addresses to follow RFC and add many more tests.
- Rework authority parsing for RFC edge cases.
- Fix a couple of other extreme edge cases.

Closes #23360.
2023-03-22 18:35:45 +01:00
Vadim Zeitlin
8b2e010841 Stop using macro-based array in wxThread unit test
Use vector of unique_ptr instead.
2023-03-13 01:17:23 +01:00
Vadim Zeitlin
dd8935b07d Fix waiting for threads to exit in wxCondition unit test
Using sleep was not only fragile but also resulted in tons of TSAN
errors, so replace it by the similar approach to the one which was
already used to wait for the threads to start up.

This is horribly inefficient but we don't care about this in the test
and, at least, this does ensure that the threads exit before it ends.
2023-03-13 01:17:23 +01:00
Vadim Zeitlin
345b8ff505 Fix some brokenness in wxThread::Delete() unit test
Don't use sleep in this test as the thread may terminate before it
returns, possibly resulting in crashes that the existing comment warned
about, and definitely resulting in TSAN errors.

Also ensure that the thread doesn't terminate instead of just hoping
that it doesn't do it because it doesn't have time to run 30 iterations
of its entry function by passing the special value of 0 to ctor, which
explicitly prevents the thread from terminating on its own.
2023-03-13 01:17:23 +01:00
Vadim Zeitlin
8f22eb5157 Merge branch 'calendar-locale'
Improve date validation in wxDatePickerCtrlGeneric and a couple of minor
fixes in the related code.

See #23312.
2023-03-09 00:10:43 +01:00
Vadim Zeitlin
d5a90896ae Merge branch 'app-init'
Improvements to wxApp initialization and modernize the code to use
std::unique_ptr<> instead of wxScopedPtr or, worse, macro-based scoped
pointers.

See #23319.
2023-03-07 19:27:10 +01:00
Lotendan
4d62df488b Add support for initializer_list to wx dynamic arrays
While these array classes are deprecated in the user code, they're still
used, for compatibility, in many places in wxWidgets API and allowing to
create them from initializer_list makes using it more ergonomic as it's
now possible to just pass an initializer list of items to fill the
control with, for example, instead of appending them one by one.

Closes #23309.
2023-03-07 17:41:05 +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
Vadim Zeitlin
29a97bb52d Don't needlessly use wxScopedPtr in wxConfig unit test
Just use objects directly instead of pointers.
2023-03-06 23:22:05 +01:00
Vadim Zeitlin
38a0a72b71 Show date format in locale pseudo-test too
In addition to the decimal separator, show the date format for the
current locale too in wxUILocale::ShowSystem pseudo-test to check that
this works as expected.
2023-03-04 23:37:05 +01:00
Vadim Zeitlin
7bad8b1060 Fix more -Wshorten-64-to-32 occurrences and test for them
Add more static casts to avoid harmless warnings about long and/or
size_t to unsigned int conversions and enable -Wshorten-64-to-32 in the
allheaders test to ensure they don't get introduced again in the future.
2023-02-27 13:47:57 +01:00
Vadim Zeitlin
7ae9e9b974 Add test really checking wxGridSizer::Layout()
The existing test with this name only checked wxFlexGridSizer::Layout()
and the base class uses a different implementation, which merits its own
unit test.
2023-02-23 15:37:32 +00:00
Vadim Zeitlin
3ed5e42441 Merge branch 'scintilla-5.0' of https://github.com/MaartenBent/wxWidgets
Update Scintilla to 5.0.

See #23117.
2023-02-20 18:25:35 +01:00
Vadim Zeitlin
c6a18264e1 Fix signed/unsigned comparison warnings in wxPropertyGrid tests
Use size_t for a variable being compared with a size_t expression.
2023-02-19 23:47:08 +01:00
Artur Wieczorek
5b1911523c Add more unit tests of wxPGVIterator 2023-02-19 22:36:40 +01:00
Artur Wieczorek
f1273ce152 Use class enums to implement bitmask types
To improve type safety of flags.
2023-02-19 22:36:21 +01:00
Maarten Bent
b0385e498c
Rebake after bakefile changes 2023-02-14 22:52:26 +01:00
Vadim Zeitlin
6bfabd7afe Fix wxFLEX_GROWMODE_ALL in wxFlexGridSizer with proportions
Setting wxFLEX_GROWMODE_ALL for the non-flexible direction broke
handling of proportions in the flexible direction which were
unexpectedly not taken into account at all any more due to not passing
them to DoAdjustForGrowables().

Fix this by still respecting the proportions in this case and add a test
case to ensure this doesn't get broken again.

Closes #23251.

See #23253.
2023-02-14 00:43:57 +01:00
Vadim Zeitlin
c4b71b3694 Merge branch 'default-locale-improve'
Improvements for handling default locale under macOS and Unix.

See #23119, #23147, #23226.

Closes #23114.
2023-02-08 17:33:19 +01:00
Vadim Zeitlin
b6a42b4ef4 Remove Mac workaround from wxFont unit test not needed any more
After #23144 was fixed, calling DumpFont() doesn't modify the font under
Mac any longer, so we don't need to avoid calling it there.
2023-02-07 10:59:54 +01:00
Vadim Zeitlin
2ca76449bf Fail if environment variables define unknown locale under Unix
Don't always "succeed" in wxUILocale::UseDefault() and, consequently, in
wxLocale::Init(wxLANGUAGE_DEFAULT), under Unix systems, even if the
locale couldn't actually be set, as it can happen if the environment
variables contain a locale which is not supported on the current system,
e.g. a "mixed" locale such as "en_FR", or even a completely invalid
string such as "bloordyblop", which still used to succeed.

For now only fix it for reasonably modern systems with locale_t support,
it could be done even for the ancient ones without it later too if
anybody still cares about them.

Closes #23218.
2023-02-06 00:11:31 +01:00
Vadim Zeitlin
14714856b3 Add wxUILocale::GetSystemLocaleId()
This function replaces the existing GetSystemLocale() as it can
represent the locales that don't have any corresponding wxLanguage
values and for which GetSystemLocale() has no choice but to return
wxLANGUAGE_UNKNOWN.
2023-02-05 16:45:14 +01:00
Vadim Zeitlin
c13b3645a8 Fix wxUILocale::FindLanguageInfo() to work for mixed locales
When looking for the language information, we must recognize the
language independently of the region it is followed by, so en_FR is
still English and fr_DE is still French, even if the full locale is
unknown, but this wasn't the case before.

Fix this by comparing the language part of wxLanguageInfo with just the
language of wxLocaleIdent we're trying to match, instead of comparing it
with its full BCP47 tag, which is never going to match.
2023-02-05 15:51:33 +01:00
Vadim Zeitlin
d6c041e69b Don't assume that wxLocale::Init(wxLANGUAGE_DEFAULT) succeeds
At least under macOS it fails when the system locale is something like
en_DE, for example, as setlocale() doesn't support such locales.

Use wxUILocale::GetSystemLanguage() instead of wxLANGUAGE_DEFAULT.
2023-02-05 15:51:33 +01:00
Vadim Zeitlin
4c23721743 Add a pseudo test to show system locale and language
This can be useful to compare the results of calling
wxUILocale::GetSystemLanguage() and the function with the same name in
wxLocale (which actually corresponds to wxUILocale::GetSystemLocale()).
2023-02-05 15:51:33 +01:00
Pavel Tyunin
de59024f53
Better move constructor test
Previous version didn't actually call the move constructor.
2023-02-05 13:09:08 +02:00
Pavel Tyunin
1a46836e88
Remove unused test variables 2023-02-05 13:09:07 +02:00
Pavel Tyunin
e04a8de87a
Remove duplicated assign() tests and move remaining ones from AssignOp 2023-02-05 13:09:06 +02:00
Pavel Tyunin
62f83858a0
Add tests for wxString assignment operator 2023-02-03 22:09:52 +02:00
Pavel Tyunin
974feb4c39
Add tests for wxString move constructors 2023-02-03 22:09:52 +02:00
Pavel Tyunin
5b951caa79
Add string arrays benchmarks 2023-02-03 22:09:51 +02:00
Vadim Zeitlin
255876075a Merge branch 'xrc-feature'
Add XRC "feature" attribute.

See #23184.
2023-02-03 15:09:55 +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
ec25a5c83c Execute automated tests for wxPropertyGrid
Move existing manually executed tests in propgrid sample to the test
suite executed automatically.
2023-01-30 17:28:17 +01:00
Vadim Zeitlin
3fdebc96cd Add support for XRC "feature" attribute
This is a generalization of the existing "platform" attribute and allows
to only include some XRC elements if and only if an arbitrary "feature"
is enabled by the application before loading the XRC document.
2023-01-29 00:54:42 +00:00
Vadim Zeitlin
7b542ed141 Remove "xrc" tag from XRC test disabled by default
This test is only supposed to be executed by giving its name on the
command line, specifying "[xrc]" shouldn't enable it.
2023-01-27 02:14:57 +00:00
Vadim Zeitlin
6b0c220914 Avoid calling wxFont::GetPixelSize() under wxOSX, it's buggy
Work around a bug in wxOSX which breaks the test if we call DumpFont()
because this function calls wxFont::GetPixelSize() which actually
changes the size of the font if it was specified in pixels.

This should be reverted once the bug is fixed.

See #23144.
2023-01-14 17:26:22 +01:00
Vadim Zeitlin
e9b4b9f7e1 Limit comparison of pixel sizes to the height only
In wxMSW wxFont::GetPixelSize() returns the size that the font was
originally created from while in the other ports it returns the actual
size being used.

wxMSW behaviour is probably wrong and should be changed, but for now
just restrict the comparison to the vertical component to avoid the test
failures.
2023-01-14 15:22:01 +00:00
Vadim Zeitlin
85079ee9da Show font properties if any checks fail
This will make it simpler to debug any failures in the test, especially
in the CI builds where debugger can't be used.
2023-01-14 15:20:52 +00:00
Vadim Zeitlin
e5d5abad0a Avoid duplication in the test by using SECTIONs
No real changes.
2023-01-14 15:19:45 +00:00
Vadim Zeitlin
f337e234c4 Fix fractional point size comparison in the test 2023-01-14 14:01:24 +00:00
PB
87b80995a4 Fix wxFontList::FindOrCreateFont() for pixel and fractional point sizes
wxFontList::FindOrCreateFont() worked properly only for integral point sizes.

Make it work also when a pixel size or fractional point size is used.
2023-01-13 21:41:55 +01:00
Vadim Zeitlin
20489626e8 Remove code restoring errno in StringTestCase::Format()
There doesn't seem to be any need to do this, so don't.
2023-01-07 16:50:28 +01:00
Lauri Nurmi
ed897d9641 Restore value of errno after wxString::ToInt()/Long()/etc.
Such functions modifying errno is undocumented, and may come
as a surprise to the caller. Consequently also a call to
wxString::Format() would modify errno.
2023-01-06 18:04:53 +02:00
Vadim Zeitlin
e89f05faba Remove memory debugging/tracing support and all related options
Drop disabled by default and pretty useless memory tracing code and all
the overlapping and poorly documented build options related to it.

Remove memory.cpp entirely and update all the make/project files, but
preserve the now completely trivial wx/memory.h for compatibility and
also keep including wx/string.h from wx/object.h as it seems like a lot
of existing code actually depends on this, even if it should not.

Replace the options in the propgrid sample with a couple of other
debug-related options that were not used before to avoid leaving the
"Debugging Section" completely empty.
2023-01-05 21:41:38 +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