Commit Graph

2389 Commits

Author SHA1 Message Date
Dimitri Schoolwerth
ff79db8ac1 wxGrid: Add test for auto-wrapped multi-line cells
Check that a row's height doesn't change when auto-sizing a column with
an auto-wrapping cell containing newlines.

Also currently will cause an infinite loop which will be fixed in the
next commit.

See #15943.
2020-12-28 00:13:17 +01:00
Maarten Bent
a530d645d1 Replace tabs with spaces 2020-12-23 17:03:10 +01:00
Vadim Zeitlin
d47fa718cd Add wxDataViewCtrl::ExpandChildren()
This convenient method allows to expand all children of the item
recursively.

This is directly supported by both native implementations, so it makes
sense to have this in wxDataViewCtrl itself, even if it could be also
(less efficiently) implemented in the user code.
2020-12-05 16:37:13 +01:00
Vadim Zeitlin
859193fb65 Merge branch 'connect-overloaded-c++17'
Make Connect() work with overloaded event handlers in C++17.

See https://github.com/wxWidgets/wxWidgets/pull/2126
2020-12-04 20:02:46 +01:00
Vadim Zeitlin
dc33f27e10 Merge branch 'printf-out-of-mem'
Fix crash in wxString::PrintfV() due to integer overflow/running out of
memory.

See https://github.com/wxWidgets/wxWidgets/pull/2131
2020-12-04 20:01:30 +01:00
Vadim Zeitlin
a7dfedf602 Skip URL test if it fails when running on AppVeyor
Failing it is not useful, this results in the CI failure when in 99% of
the cases the transient network problem which resulted in this test
failure has nothing to do with the changes being tested.
2020-12-04 19:29:59 +01:00
Vadim Zeitlin
344cc940a0 Impose upper limit on memory allocation in wxString::PrintfV()
Don't loop indefinitely until we run out of memory, possibly after
wrapping around INT_MAX, but impose an arbitrary limit of 128MiB for the
max allocation done by wxString::PrintfV() when the provided format
string or one of the arguments are invalid.

This notably fixes a crash when trying to use "%c" to output an invalid
Unicode character.

Also improve comment explaining DoStringPrintfV() logic and change the
size type to size_t from int.

Co-Authored-By: Arrigo Marchiori <ardovm@yahoo.it>
2020-12-01 21:53:55 +01:00
Vadim Zeitlin
8fb4ab99f1 Always return -1 but set errno in our wxVsnprintf() on error
This makes it more compatible with the standard behaviour of vswprintf()
and allows to use the same logic in the builds using our version of this
function and the normal ones in DoStringPrintfV(), simplifying its
(already rather hairy) logic.

Update the tests to not require any particular return value in case of
buffer overflow, as this differs between Unicode and non-Unicode builds.
When we finally drop the latter, we should just check that it always
returns -1 in this case.

Note that ideal would be to return the actually needed size of the
buffer in case of the error due to buffer being too small, but this
isn't that simple to do and it's probably not worth spending time on
improving this code as long as we still need to use the buffer doubling
strategy in DoStringPrintfV() when using the standard vswprintf().
2020-12-01 21:53:55 +01:00
Vadim Zeitlin
7a2786bf11 Get rid of CppUnit macros in wxVsnprintf() tests too
Use CATCH macros directly.

Also remove some unnecessary casts and wxT().
2020-12-01 00:53:07 +01:00
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