Commit Graph

1848 Commits

Author SHA1 Message Date
Vadim Zeitlin
dd92a269c3 Add a simple unit test for wxHtmlPrintout pagination logic
Verify that the number of pages to be printed is as expected.
2018-05-23 18:14:07 +02:00
Vadim Zeitlin
2e8516c5fe Merge branch 'MoveOutsideShortInterval' of https://github.com/catalinr/wxWidgets
Allow using positions in the entire int range for window positions under
MSW, and not just those in (slightly less than) short range, that are
supported by the native API.

Closes #4262.

Closes https://github.com/wxWidgets/wxWidgets/pull/779
2018-05-02 23:19:11 +02:00
Cătălin Răceanu
bb29b87a45 Add test case for window positioning beyond Short limit 2018-04-30 00:58:39 +03:00
Vadim Zeitlin
6ae7aa4443 Fix saving/restoring window position for maximized windows
Save both the normal window geometry and its maximized position instead
of saving just its current position. This fixes restoring geometry of
the maximized windows as previously they were always restored on the
primary monitor, as their original position was lost.

Use the native {Get,Set}WindowPlacement() functions for a MSW-specific
wxTLWGeometry implementation to achieve this.

Closes #16335.
2018-04-29 20:35:44 +02:00
Vadim Zeitlin
7c34ca65a0 Add unit test for wxLZMA{Input,Output}Stream classes
Create another generic stream test using BaseStreamTestCase framework.
2018-04-06 15:39:55 +02:00
Vadim Zeitlin
f99d3df9c0 Fix harmless gcc -Wconversion-null warning in menu unit test
Don't compare with NULL inside CPPUNIT_ASSERT() to avoid

	warning: passing NULL to non-pointer argument 1 of
	‘Catch::BinaryExpression<T, (Catch::Internal::Operator)0u, const
	RhsT&> Catch::ExpressionLhs<T>::operator==(const RhsT&) [with
	RhsT = long int, T = wxMenuItem* const&]’ [-Wconversion-null]

gcc warning.
2018-03-07 14:59:40 +01:00
Vadim Zeitlin
cc8fccf0bc Make wxVector reverse iterators conform to iterator requirements
This is similar to a recent commit adding the missing typedefs to wxList
iterators and defines the types required by the iterator concept in
wxVector::reverse_iterator and const_reverse_iterator classes (simple
iterators are just pointers and are already covered by the standard
iterator_traits specialization).
2018-02-23 16:14:03 +01:00
Vadim Zeitlin
fdbe357e4b Make wxList iterators conform to input iterator requirements
Define "pointer", "reference", "difference_type" and "iterator_category"
typedefs to ensure that wxList iterator classes are seen as iterators by
the standard library in C++11 and later, as otherwise standard container
template ctors taking iterators couldn't be used with them because
they're only available if input iterator requirements are satisfied.

This notably fixes creation of std::list from wxList iterators; add a
test which didn't compile before to show it.
2018-02-23 16:00:06 +01:00
Maarten Bent
3d427a1af1 Fix wxWebView::RunScript() with string containing backslashes
Escape backslashes in wxJSScriptWrapper to allow strings with
backslashes in them to work again -- this was broken while implementing
support for returning values from JavaScript to C++.

See https://github.com/wxWidgets/wxWidgets/pull/741
2018-02-22 13:44:00 +01:00
Vadim Zeitlin
2ec2837f6d Update version to 3.1.2
Run misc/scripts/inc_release and rebake.
2018-02-20 00:08:01 +01:00
pavel-t
9c29b6de48
Fix building tests with wxUSE_STL=1 and wxUSE_UNSAFE_WXSTRING_CONV=0 2018-02-08 10:05:21 +02:00
Vadim Zeitlin
ae8bc4e263 Merge branch 'search-events'
Harmonize the behaviour across platforms.

Also fix ChangeValue() for this control.

And finally rename the events to use simpler names.

See https://github.com/wxWidgets/wxWidgets/pull/699
2018-01-30 14:12:30 +01:00
Vadim Zeitlin
f24872f6f4 Add unit test for wxSearchCtrl::ChangeValue()
Verify that it actually does change the value.

See #16998.
2018-01-29 19:35:10 +01:00
Vadim Zeitlin
05ebeb6bac Get rid of CppUnit compatibility macros in wxSearchCtrl unit test
No real changes, just remove all the CppUnit machinery not needed any
longer and replace it with a simple test function.
2018-01-29 19:08:12 +01:00
Vadim Zeitlin
5bc208df3c Correct UTF-8 encoding of U+FFFF
Overlong (and hence invalid) 4-byte encoding was used for this character
instead of the correct 3-byte 0xEF 0xBF 0xBF sequence.

Fix this by using 3 bytes for the code points up to 0xFFFF included,
instead of excluding it as was done before.

Closes #17920.
2018-01-29 00:48:56 +01:00
Vadim Zeitlin
ad03c8475d Revert "Fix crash when deleting all wxTreeListCtrl items with wxGTK3"
This reverts commit 1dd102d741 as it
introduced a crash in the same method when using generic wxDataViewCtrl
implementation, e.g. under MSW, and is not necessary to avoid the crash
with wxGTK3 any longer after the few previous commits.
2018-01-24 23:09:30 +01:00
Tobias Taschner
ddceaab001
Remove MSW wxUxThemeEngine class
This undocumented "private" class was used for various windows UxTheme
functions which are available since WinXP. As wxWidgets 3.1 is XP+ it
does not make sense anymore to load the theme functions dynamically.
2018-01-22 00:51:11 +01:00
Vadim Zeitlin
1dd102d741 Fix crash when deleting all wxTreeListCtrl items with wxGTK3
GTK+ 3 (but not the generic version nor even GTK+ 2, apparently) sends
"selection changed" event from gtk_tree_model_row_deleted() when
deleting the currently selected row, which resulted in sending of
wxEVT_TREELIST_SELECTION_CHANGED events with invalid wxTreeListItem,
containing a dangling pointer, and a crash in the treelist sample when
trying to dump it.

Avoid this by clearing the model (and hence generating these events)
first and deleting the items only afterwards.

Also add a trivial unit test for wxTreeListCtrl::DeleteAllItems(), which
doesn't even allow to reproduce this bug, but is still probably better
to have than not to.

Closes #18045.
2018-01-17 10:44:28 +01:00
Vadim Zeitlin
9df5541c53 Don't show dialogs from OnExceptionInMainLoop() in the tests
Similarly to the previous commit, ensure that the tests can run
unattended under MSW even if an unhandled exception is thrown during
their execution.
2018-01-14 02:25:51 +01:00
Vadim Zeitlin
277937b0c4 Always use stderr for wxMessageOutputBest in the tests
Avoid showing message boxes even if we don't have the associated console
as this prevents the test from completing on its own if an unknown
exception happens.
2018-01-14 02:25:51 +01:00
Vadim Zeitlin
f66fb07ce7 Resize wxDataViewCtrl to fix persistence test with wxGTK
Setting the column sizes fails with wxGTK implementation of
wxDataViewCtrl if the control is not wide enough, apparently, so make
sure it's sufficiently big when creating it to fix the unit test
failures on wxGTK build bot slaves.
2017-12-17 16:13:06 +01:00
Vadim Zeitlin
1b6ec5c538 Merge branch 'linux-spec-files'
wxFile and wxTextFile for working with special/non-seekable files.
2017-12-16 15:26:35 +01:00
Vadim Zeitlin
a03ece4880 Remove st_blocks hack from wxFile::Length() under Linux
This reverts commit 41f6f17d01 ("return 0
(meaning the file is not seekable, as the docs now explain) instead of
4KB for the files in sysfs under Linux") as it seems to be wrong to
return a value different from what "ls -l" or "stat" return here and the
original problem was solved in a better way in the previous commit.

See #9965.

Closes #17818.
2017-12-15 18:46:22 +01:00
Vadim Zeitlin
cc86de1416 Replace file reading code in wxTextFile with wxFile::ReadAll()
There is nothing special about wxTextFile justifying having code for
dealing with non-seekable files in it, so put this code into wxFile
itself and just call its ReadAll() method from here.

This is a better fix than 41f6f17d01
originally applied (and which is going to be reverted next) as it
doesn't break wxFile::Length() for these files and also avoids
triggering an assert if the file we're trying to read was truncated by
another process in the meanwhile -- which can happen and doesn't
indicate a programming error and so shouldn't result in an assert.

Also add a unit test checking that this really works.

See #3802, #8354, #9965.
2017-12-15 18:46:22 +01:00
Vadim Zeitlin
a30bee473e Make wxFile::ReadAll() work for unseekable files too
Calling this function with an unseekable file, such as any file under
/sys on Linux systems, would previously just hang as the loop condition
was never satisfied when length was -1.

Fix this by checking for this case and using a different approach by
extending the buffer we read the data into as we go instead of
preallocating it all at once.

See #9965.
2017-12-15 18:43:26 +01:00
Vadim Zeitlin
e3575d1f9c Use temporary wxConfig for persistence unit tests
This requires slightly more work, but ensures that we don't leave any
traces of running the tests in the system registry or file system, as we
can just call DeleteAll() on the config object after finishing with it.
2017-12-15 14:43:43 +01:00
Vadim Zeitlin
036870ab35 Split wxPersistenceManager-related tests and actually build them
It seems better to organize the tests in different files and just
provide a common fixture-like class to reuse functionality.

Also use this as an opportunity to rewrite the tests to use Catch
directly instead of using CppUnit-compatible macros.

Finally, actually build these tests as part of the test suite.
2017-12-15 14:10:35 +01:00
Vadim Zeitlin
e5b12b5bc8 Merge branch 'dvc-persist' from iwbnwif
See https://github.com/wxWidgets/wxWidgets/pull/541
2017-12-15 14:10:01 +01:00
Vadim Zeitlin
2ad2bccf33 Don't call static wxLocale::GetInfo() via an object
This is just confusing and unnecessary.

No real changes.
2017-12-10 03:28:18 +01:00
Vadim Zeitlin
9036b3dba8 Remove "C" locale date and time formats test
This test didn't make sense at all as it didn't actually test "C" locale
formats as calling setlocale(LC_ALL, "C") didn't actually change the
values returned by wxLocale::GetInfo(), so it still returned the values
corresponding to the French locale set in this test setUp() method and
the test only passed because it used wrong values (i.e. the same ones as
in French locale test).

We also don't have any simple way to test "C" locale formats, we can
only test them for wxLANGUAGE_DEFAULT, but this corresponds to the OS
defaults which can be customized by user (e.g. in the control panel
under MSW) and so we can't expect them to be equal to any fixed values.

The simplest solution is to just drop this test, as it's not very useful
anyhow (French locale test above already covers the same code).
2017-12-10 03:24:47 +01:00
Vadim Zeitlin
e97c020285 Fix wxLocale::GetInfo() test for French locale under macOS 10.12
The date and time format has changed since 10.10 and now contains an extra
" à " in its middle, so adjust the test to deal with this.
2017-12-09 19:04:52 -07:00
Vadim Zeitlin
22e14e7c7b Check for wxXLocale availability without using wxLocale
This extends the changes done 01cd702ee3
to another test case and so makes as much sense as the other commit.

It's still not clear what's really going on here as, somehow, this test
passed under AppVeyor before, which shouldn't have been happening if the
explanation in that commit message was correct. And it also doesn't
explain why did it suddenly fail after a completely unrelated change,
see https://ci.appveyor.com/project/wxWidgets/wxwidgets/build/2502/job/l24gc2j0j7h7huxl
2017-12-09 14:17:34 +01:00
Vadim Zeitlin
ddf3604545 Fix harmless warning in Base64 unit test
Avoid

warning C4245: 'initializing': conversion from 'int' to 'std::size_t', signed/unsigned mismatch

from MSVC with an explicit cast.
2017-12-09 14:15:37 +01:00
ARATA Mizuki
54dfc341ce Add a test for wxFile::ReadAll() with an embedded NUL
See #16490.
2017-12-06 03:10:27 +01:00
Vadim Zeitlin
d83cd91d13 Merge branch 'tz-fixes'
Miscellaneous fixes for time zones and DST handling in wxDateTime.

This still leaves 2 big problems:

1. We have no support for using the correct time zone offset at the
   given date and always use the current time zone offset, which may,
   and often is, wrong.

2. Our code for converting to/from broken down representation doesn't
   handle DST at all, so support for DST is non-existent for the dates
   before 1970-01-01 or after 2038-01-01 (i.e. roughly outside of the
   32 bit time_t range).

See #10445 and the other tickets linked from there.
2017-12-02 16:28:05 +01:00
Vadim Zeitlin
15a97924b6 Simplify wxDateTime ticks test by only using UTC times
Converting to another time zone and dealing with DST is completely
useless here, ticks values are always in UTC, so we can just use UTC
values from the beginning.
2017-12-02 14:38:45 +01:00
Vadim Zeitlin
179dced0e0 Include testdate.h before catch.hpp in unit tests
This ensures that dates are printed out correctly if comparing them
fails.

It might be better to avoid always including this header, but this is
the simplest solution.
2017-12-02 14:38:19 +01:00
Artur Wieczorek
d68bb24333 Fix rescaling images with wxIMAGE_QUALITY_BOX_AVERAGE
Current algorithm used to calculate the bounds of the boxes in the source
image to which the pixels in the target (rescaled) image are mapped to, has
flaws which cause a non-uniform distribution of the boxes in the source
image. And these miscalculations may result in the visible distortions
of the colours in the rescaled image.
New algorithm assures uniform distribution of the boxes in the source image
and thanks to the integer arithmetic is faster than currently used
and not prone to the problems with floating point representation.

Closes #18012.
2017-11-30 22:50:31 +01:00
Vadim Zeitlin
322144299d Use wxDateTime::TimeZone::IsLocal() in the unit test
No real changes, as this doesn't affect this test, but use the new
IsLocal() method instead of comparing the time zone offset with the time
zone, which doesn't work correctly for BST.
2017-11-30 17:53:52 +01:00
Vadim Zeitlin
d49784b0a2 Disable wxDateTime tests failing due to TZ offset changes
wxDateTime timezone-related methods always use the current timezone
offset, while other methods, using CRT, use correct value for the given
date, which may be different.

This discrepancy accounted for test failures in Europe/Minsk time zone
as Belarus has switched from UTC+2 to UTC+3 since 1999 date used in the
test.

It is impossible to really fix the problem easily, so just skip the test
in this case and also mention this bug in the documentation.

See #15370.
2017-11-30 17:44:41 +01:00
Jouk
d17665da3a Update OpenVMS makefile for change from cppunit to catch 2017-11-30 12:23:02 +01:00
Vadim Zeitlin
d3a01e3fe6 Show more information in other DateTimeTestCase tests too
Show the loop variable when doing checks inside a loop to make it more
obvious for which test case the failures occur.

Also use CHECK(), instead of REQUIRE(), to which CPPUNIT_ASSERT_EQUAL
expands, to continue with the other loop iterations after failure.
2017-11-29 23:55:13 +01:00
Vadim Zeitlin
4868ec0893 Show more information if DateTimeTestCase::TestTimeFormat() fails
No real changes, just show the variable values if any checks fail and
also continue running the test for the other data points even if one of
them fails.
2017-11-29 23:19:01 +01:00
Vadim Zeitlin
c7c30504c8 Do nothing when converting wxDateTime to/from local time zone
In particular, do not (unexpectedly) adjust time by the DST.

Closes #16585.

See #10445.
2017-11-29 23:18:57 +01:00
Vadim Zeitlin
543c522cb8 Explicitly disambiguate local time zone from UTC
Don't rely on time zone offset to check whether it is local as this
doesn't, and can't, work for the local time zone in Great Britain which
uses the same offset as UTC, but does use DST, unlike the latter.

Add a unit test (albeit disabled by default) checking that the code that
previously didn't work correctly in BST does work now (run the tests
using "TZ=Europe/London ./test wxDateTime-BST-bugs" under Unix to test).

Closes #14317, #17220.

See #10445.
2017-11-29 23:02:22 +01:00
Vadim Zeitlin
5b2f7aa96d Remove IsDST() check in wxDateTime DST unit test
IsDST() returns 0 for the DST end date itself, which is wrong, but
doesn't seem to be directly relevant for this test.
2017-11-28 23:59:21 +01:00
Vadim Zeitlin
13c3b5cbd1 Use different sections for wxDateTime DST test
Try to make it more clear where exactly does it fail on buildbot.
2017-11-28 23:40:51 +01:00
Vadim Zeitlin
efb8d82c8a Provide more information if wxDateTime DST test fails
Show the original date and the date after modification.
2017-11-28 23:19:26 +01:00
Vadim Zeitlin
369e6f6554 Use "datetime" tag for all wxDateTime unit tests
Make it possible to run all these tests at once (and no other ones)
easily.
2017-11-28 23:09:51 +01:00
Vadim Zeitlin
e23ff6fded Add tests for wxDateTime setters around DST end time
Check that setting the other date components doesn't change its hour.

See https://github.com/wxWidgets/wxWidgets/pull/367
2017-11-28 23:05:45 +01:00