Commit Graph

2536 Commits

Author SHA1 Message Date
Vadim Zeitlin
388dfb9fad Replace various CMPn() macros with a single CMP() vararg one
Reduce duplication and simplify the test code by using the same macro
for any number of printf() arguments.

Note that this relies on "##__VA_ARGS__" gcc extension to work even for
CMP0(), i.e. when there are no parameters at all. If this ever becomes a
problem, we can always reintroduce a separate CMP_NO_ARGS() macro.
2020-12-01 00:51:35 +01:00
Vadim Zeitlin
db9727ac26 Remove CppUnit test case boilerplate from wxVsnprintf() unit test
Use separate CATCH test cases for different tests.

No real changes, just update and simplify.
2020-11-30 17:17:20 +01:00
Vadim Zeitlin
f4db86cc77 Fix signed/unsigned comparison warnings in wxVsnprintf test
These warnings only appeared in build configurations using our own
implementation, i.e. not in the default build.
2020-11-30 17:10:05 +01:00
Vadim Zeitlin
433480f7d0 Merge branch 'bitness' of https://github.com/lanurmi/wxWidgets
Replace "architecture" with "bitness" for the value indicating whether
the architecture uses 32 or 64 bits.

See https://github.com/wxWidgets/wxWidgets/pull/2122
2020-11-22 00:35:29 +01:00
Vadim Zeitlin
f48099e00a Make Connect() work with overloaded event handlers in C++17
This used to work previously but got broken when using C++17 by
c3810da549 (Allow using noexcept methods with event tables macros,
2020-04-09), as cast added to deal with noexcept handlers relied on
argument type deduction which can't be done for overloaded functions.

Fix this by extracting the event argument type from the function pointer
type and specifying it explicitly, while still letting the compiler
deduce the class.

Add a test case checking that using overloaded event handlers compiles.

See #18721.

Closes #18896.
2020-11-21 20:52:13 +01:00
Lauri Nurmi
b74702543b Rename wxPlatformInfo::*Arch* to *Bitness*, deprecate old names 2020-11-21 19:16:21 +02:00
Bill Su
47078992c6 Fix handling of mask in wxBitmap::ConvertToImage()
Handling mask when converting wxBitmap to wxImage was accidentally
broken by 7e9afad53a (Add real support for monochrome bitmaps to wxMSW,
2020-10-19). Fix this now and reuse the new wxMonoPixelData to make the
code simpler and more readable.

This commit is best viewed ignoring whitespace-only changes, as it
unindents a large block of code.

Closes https://github.com/wxWidgets/wxWidgets/pull/2125

Closes #18974, #18975.
2020-11-21 18:14:02 +01:00
Lauri Nurmi
68ea3c59f1 Explain in wxPlatformInfo docs that it means bitness when it says architecture
In the context of wxPlatformInfo, 'architecture' means either '32 bit' or
'64 bit'. Anywhere outside the context of wxPlatformInfo, this concept is
known as 'bitness'.

For the rest of the world, 'architecture' generally refers to the CPU
instruction set architecture, i.e. something like x86, x86_64, arm64, whereas
'operating system architecture' refers to the design of separating kernel
space, user space, etc.
2020-11-21 18:17:18 +02:00
Vadim Zeitlin
1afd2248d7 Enable C++11-only Bind() unit test for MSVS 2015+ too
This might compile with even earlier MSVS versions, but it definitely
does with the recent ones, so enable the test for this compiler, even if
it still doesn't define __cplusplus to indicate C++11 conformance by
default.
2020-11-20 01:50:35 +01:00
Vadim Zeitlin
5c7da1b357 Get rid of CppUnit boiler plate in wxEvtHandler unit test
No changes, just remove the useless test case class and use individual
test cases instead of its methods.
2020-11-20 01:50:35 +01:00
Vadim Zeitlin
4bd0cd40f4 Merge branch 'persistent-combobox'
Add wxPersistentComboBox class and fix persistent classes compilation
when wxString implicit conversions are disabled.

See https://github.com/wxWidgets/wxWidgets/pull/2123
2020-11-19 23:30:51 +01:00
Vadim Zeitlin
a1d43c9363 Make wxRound() compile for all integer types again
Replace the overloads added in c2e5f3520a (Add a wxRound() overload for
int, 2020-11-05) and 1cf7c47934 (Add more wxRound() compatibility
overloads and improve docs, 2020-11-05) with a template function that
should work for all integer types.

This fixes compilation of existing code using wxRound() with size_t
values: while this doesn't make any sense, it doesn't make much less
sense than using it with int, so let people avoid having to change their
code when upgrading to wx 3.2.

Also add at least some minimal tests for this function.

Closes https://github.com/wxWidgets/wxWidgets/pull/2119
2020-11-19 15:45:22 +01:00
Vadim Zeitlin
7f5d45b9b4 Add wxPersistentComboBox for saving and restoring combobox items
This allows to preserve the history of user input.
2020-11-19 13:06:37 +01:00
Vadim Zeitlin
8469642959 Include persistent controls headers in the all headers test
Check for the absence of warnings when compiling these headers too, they
were simply forgotten (and not intentionally excluded) before.
2020-11-19 13:06:37 +01:00
Vadim Zeitlin
516066939a Add trivial wxVectorContains() helper
This is nicer than using std::find() when only a test for presence is
required.
2020-11-16 16:48:47 +01:00
Vadim Zeitlin
312a760029 Merge branch 'dvc-fix-item-added'
Fix adding items to generic wxDVC again.

See https://github.com/wxWidgets/wxWidgets/pull/2095
2020-10-31 16:29:02 +01:00
Paul Cornett
d59b68c9eb Add some additional values to wxImage::RGBtoHSV test 2020-10-30 09:36:37 -07:00
Stefan Brüns
c3873ea313 Use proper rounding when casting RGB values to int
When doing an RGB->HSV->RGB roundtrip, the original value should be
restored (HSV, being double, has sufficient precision).

For e.g. `RGBValue(1,2,3)`, the equivalent resulting code for blue is
`trunc(int * 255.0 / 255.0)` (cast from double to int truncates).
At least with x87 FP math and its immediate 80bit extended precision
the resulting value is ~trunc(2.9999..), i.e. 2, similar problems may
exist on other architectures with other values.

Using proper rounding avoids the error magnification.

Closes https://github.com/wxWidgets/wxWidgets/pull/2078
2020-10-30 09:32:32 -07:00
Bill Su
7e9afad53a Add real support for monochrome bitmaps to wxMSW
In order to be able to use monochrome bitmaps as wxMask, improve support
for them in various ways:

1. Implement loading and saving of monochrome BMP files.
2. Add wxMonoPixelData for direct access to monochrome bitmap pixels.
3. Implement conversion from wxImage to monochrome wxBitmap.

Closes https://github.com/wxWidgets/wxWidgets/pull/2032
2020-10-20 15:52:55 +02:00
Vadim Zeitlin
c0e3bdaab9 Merge branch 'remove-outdated-gcc-checks'
Remove vestiges of support for gcc < 4 and related checks.

See https://github.com/wxWidgets/wxWidgets/pull/2096
2020-10-20 15:49:20 +02:00
Vadim Zeitlin
426a0ed527 Remove HAVE_W32API_H definition and checks
All still supported versions of MinGW/Cygwin provide w32api.h file, so
there is no need to test for it.

This allows to simplify the code, but also remove the definition of
HAVE_W32API_H from bake- and makefiles and this, in turn, allows to get
rid of extra flags in MinGW format entirely, as we don't support gcc
2.95 for which they were originally needed neither.
2020-10-20 01:47:47 +02:00
Vadim Zeitlin
4abb816f70 Merge branch 'fix-and-run-tests-with-asan'
Fix issues found by address/leak sanitizers in the unit tests and add
Travis CI build running tests built with ASAN to ensure they don't
reappear in the future.

See https://github.com/wxWidgets/wxWidgets/pull/2086
2020-10-19 21:16:27 +02:00
Vadim Zeitlin
fec33079ed Relax French date/time locale unit test to ignore trailing "%Z"
The version of glibc used under Ubuntu 20.04 doesn't have "%Z" in the
French date-time locale, which broke the test there.

Instead of adding even more tests for glibc version, just ignore "%Z" if
it's present, we don't really care about it, we just want to check that
wxLocale::GetInfo() returns something recognizably different from C and
English locale here.
2020-10-19 21:14:27 +02:00
PB
a7df23d43c Remove checks for outdated GCC versions
wxWidgets now supports only GCC 4 and newer, so there is no reason
to keep code specific for older GCC versions.
2020-10-19 19:38:53 +02:00
Ilya Sinitsyn
b95a79d74e Fix global read overrun error in MBConvTestCase
Use null-terminated copy of the input buffer to create the formatted
message instead of "multiBuffer" itself, which isn't.
2020-10-19 13:54:19 +02:00
Ilya Sinitsyn
f7c4677cb2 Fix list contents memory leak in wxAny unit test
Also document the need for using WX_CLEAR_LIST() when converting a
list-valued wxVariant to wxAny.

Note that we intentionally don't fix the problem by clearing the list
automatically, even if it could be done, because this would silently
break the existing code which does already clear the list -- and now
would attempt to clear it twice, with fatal consequences. Instead
document the existing behaviour and explain how to avoid memory leaks.
2020-10-19 13:54:19 +02:00
Ilya Sinitsyn
10c68e9973 Fix wxMemoryFSHandler memory leaks in wxFileSystem unit test
Use wxScopedPtr<> to ensure the handlers we use get freed.
2020-10-19 13:54:19 +02:00
Ilya Sinitsyn
02f697d0c0 Fix memory leaks in wxHtmlParser unit test
Remove the unnecessary, and actually harmful, overridden GetProduct(),
as we must delete the pointer returned by the base class version to
avoid leaking it.

Also use wxScopedPtr to avoid leaking a test wxHtmlContainerCell.
2020-10-19 13:54:19 +02:00
Ilya Sinitsyn
413c05ea85 Fix wxAcceleratorEntry memory leaks in the menu test
Use wxScopedPtr to ensure that all the test accelerator entries are
destroyed instead of just being leaked.
2020-10-19 13:53:52 +02:00
Vadim Zeitlin
c24dddc462 Return empty rectangle from GetItemRect() for collapsed items
GetItemByRow() returned a valid row even for an item which was collapsed
which is clearly inappropriate for its use in GetItemRect(), which is
supposed return an invalid rectangle if the item is not visible. It also
might be inappropriate in other cases, but this is not totally clear and
it seems like it is supposed to return a valid row even for collapsed
items at least sometimes, so just make its behaviour conditional by
adding a new flags parameter to GetItemRect() and to Walker() helper
used by it itself, so that it could skip over collapsed items.

Update the test to show that it succeeds now even when the item is
present in the tree, as it only passed before because the item had never
been expanded at all, and so wasn't really present in the tree
structure and the updated test would have failed without the changes to
the code in this commit.
2020-10-19 01:31:14 +02:00
Vadim Zeitlin
9e4d51dfca Disable tests not working in ANSI build
Most of them can't be expected to work, e.g. non-ASCII file names can't
be supported without Unicode support.

Some others, e.g. test for NULs in wxDataOutputStream, are questionable,
as it seems that it might be possible to fix them in ANSI build too, but
for now just do the simplest thing to make the tests pass on Travis.
2020-10-18 23:47:29 +02:00
Vadim Zeitlin
9824d3bef3 Don't try testing wxNO_IMPLICIT_WXSTRING_ENCODING in ANSI build
This doesn't work and this won't change.
2020-10-18 20:15:14 +02:00
Vadim Zeitlin
fa1b1e700b Initialize variable to avoid a warning in wxCaret unit test
Always initialize the caret pointer in the test added in 88f808e303 (Add
a unit test for wxCaret::Create(), 2020-10-01) to avoid a MSVS warning.
2020-10-17 14:46:41 +02:00
Vadim Zeitlin
98ea7b49c7 Fix harmless signed/unsigned comparison warning in a test
Add a cast to avoid a warning recently added in 1f40a7e4e3 (Document
that wxDataViewCtrl::SetSelections() skips invalid items, 2020-10-12).
2020-10-17 14:45:41 +02:00
Vadim Zeitlin
fcc0e48ade Deprecate wxTransformMatrix to prepare for its removal later
This class is redundant with wxAffineMatrix2D, which is actually used by
the library itself and documented, so it gets to stay, while this one is
scheduled for removal.

Closes https://github.com/wxWidgets/wxWidgets/pull/2083

Closes #13114.
2020-10-16 02:03:38 +02:00
Vadim Zeitlin
b6cff426ce Merge branch 'remove-bcc-support'
Remove support for Borland C++ compiler, it wasn't tested since a long
time and probably didn't work anyhow and there was no interest in
keeping support for it since many years.

See https://github.com/wxWidgets/wxWidgets/pull/2087
2020-10-16 01:58:13 +02:00
PB
68a4e47e4c Remove trailing whitespace 2020-10-15 19:50:37 +02:00
PB
be7e68605e Remove BCC make and project files 2020-10-13 18:54:01 +02:00
PB
a6d4799de9 Remove BCC-specific conditionally compiled code 2020-10-13 18:40:31 +02:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Vadim Zeitlin
1f40a7e4e3 Document that wxDataViewCtrl::SetSelections() skips invalid items
Also add the unit test checking for this.
2020-10-12 18:32:11 +02:00
ali kettab
fedc80eee3 Improve selection and focus events generation in wxGenericLisCtrl
Avoid sending spurious wxEVT_LIST_ITEM_{FOCUSED, SELECTED, DESELECTED}
events and make the generic version consistent with the behaviour of the
native wxMSW one.

Also add/extend the tests and slightly improve the sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2044
2020-10-10 19:13:52 +02:00
PB
952e5f32cd Fix generation of extraneous wxEVT_SLIDER events in wxMSW
Don't send the event when it's redundant, i.e. doesn't really notify
about the change in the slider value.

Also add a test case for wxEVT_SLIDER and show these events in the
widgets sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2080

Closes #18929.
2020-10-10 18:21:27 +02:00
Vadim Zeitlin
7ed330a197 Merge branch 'image-paste-fix'
Fix recent regression resulting in a crash in wxImage::Paste().

See https://github.com/wxWidgets/wxWidgets/pull/2076
2020-10-10 18:12:35 +02:00
Pavel Tyunin
c9dd9e96a1 Allow decoding even shorter strings in fallback encoding
Complete UTF-8 characters (except leading nulls) never appear in failed decoding attempts when the input is fed byte by byte.
2020-10-07 17:31:42 +03:00
Pavel Tyunin
1cbcf24832 Make leading nulls a special case to avoid breaking decoding some short strings in fallback encoding 2020-10-07 17:02:06 +03:00
Hartwig
728f2f958f Fix crash in wxImage::Paste() when using images without alpha
Check for the presence of alpha channel before using it in the fallback
code.

Also add a unit test exercising this branch of the code and which
crashed before.
2020-10-06 00:48:48 +02:00
Vadim Zeitlin
d58f9bea72 Rearrange sections in wxImage::Paste unit test
No real changes, just execute only the tests relevant for the section
being executed instead of always running the code loading PNG images
when running a section not using them at all.

This has the advantages of being a bit faster to execute (and the total
test suite run time does add up) and, more importantly, showing the
right amount of tests when executing a single section: e.g. now it's 1
in the simplest case, as expected, and not 5.

The disadvantage is, of course, slightly more code duplication, but it
doesn't seem a huge problem in practice and making each section code
more self-contained is arguably worth it.

Also, compensate for this somewhat by extracting all XPM definitions at
the function level: those are only initialized once (being static), so
there is no need to duplicate them.

Finally, also call AddHandler() once instead of once per section as
before.
2020-10-06 00:40:59 +02:00
Vadim Zeitlin
cb5e0d221c Fix running new wxImage::Paste() unit tests from build directory
Add new image test files added in 6e8da8641c (Add alpha blending for
wxImage::Paste, 2020-09-23) and 1f0ade29f0 (Fix using mask colour even
if there is no mask in wxImage::Paste, 2020-09-30) to Makefile, so that
they're copied to the build directory and could be found by the test
there, otherwise running wxImage::Paste test when building outside of
the source directory failed.
2020-10-06 00:37:56 +02:00
Pavel Tyunin
4832565e10 Rename IsFallbackEncoding() to IsUsingFallbackEncoding() 2020-10-05 15:32:07 +03:00