Commit Graph

1828 Commits

Author SHA1 Message Date
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
Vadim Zeitlin
4e4617a9e6 Show value if comparison fails in VarArgTestCase
Use string comparison instead of wxStrcmp() to view the actual value of
the string if it doesn't have the expected value.
2017-11-25 17:28:42 +01:00
Vadim Zeitlin
01cd702ee3 Test for wxXLocale availability directly in the unit test
Apparently a locale can be available at MSW level, so that
wxLocale::IsAvailable() returns true, but not supported by the MSVC CRT,
so that constructing the corresponding wxXLocale fails, which resulted
in wxXLocale unit test failures.

Fix them by checking that wxXLocale can be constructed directly instead
of using wxLocale::IsAvailable() as a proxy.

This is not ideal and perhaps wxLocale::IsAvailable() should check that
the locale is supported in wxXLocale too, but should at least allow unit
tests to pass on AppVeyor for now.
2017-11-25 17:28:42 +01:00
Vadim Zeitlin
62f9438ad3 Rewrite wxPathList unit test without CppUnit-compatible API
Simplify the test by using a single function instead of all the
machinery inherited from CppUnit.

Also provide more information in case of test failure.
2017-11-25 16:08:01 +01:00
Vadim Zeitlin
b630abffd2 Fix FormatConverterTestCase for MinGW and Cygwin
Standard/Unix format strings are intentionally used when using these
compilers/environments (see d62c535d4c for
the former), so don't check for Windows/MSVC format strings in the test.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
471a771382 Fix built-in wxPrintf() for repeated positional parameters
Allow wxPrintf("%1$s %1$s", "foo") to work.

Take into account the possibility that the number of format specifiers
and the number of actual arguments can be different.

Closes #9367.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
dd8155980b Enable building the unit tests for x64 in MSVS solutions
For some reason (but probably accidentally), building tests was disabled
for x64 platform.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
3508e3a623 Disable test for clicking URLs under AppVeyor
It fails, for whatever reason, even though it passes locally and other
tests using wxUIActionSimulator work under AppVeyor too.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
753aa757a4 Recognize AppVeyor CI environment in unit tests
Check for APPVEYOR environment variable in addition to TRAVIS one.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
0c29775d4d Skip wxTopLevelWindow showing/activation tests in CI builds
It doesn't seem to work when run unattended, for whatever reason.
2017-11-25 11:13:02 +01:00
Vadim Zeitlin
ba5a203105 Rewrite TLW unit test as a single function
Get rid of the unnecessary test case class.

No real changes yet.
2017-11-24 22:55:11 +01:00
Vadim Zeitlin
a68cb585cd Consistently use "unsigned" and "%u" in font unit test
Don't mix "size_t" and "unsigned" and don't use "%lu" for printing
"size_t" values as this doesn't work under Win64 where sizeof(size_t) is
8 while sizeof(unsigned long) is still just 4.
2017-11-24 22:55:11 +01:00
Vadim Zeitlin
a50541795c Compilation fix for VsnprintfTestCase with Catch
Rewrite an assert using "||" as 2 asserts to allow it compile with Catch
(this wasn't detected before as this code is only compiled when using
our own vsnprintf() implementation, which is usually not the case).
2017-11-24 22:55:11 +01:00
Vadim Zeitlin
166f754973 Fix comparison of size_t values with -1 in base 64 unit test
This doesn't work correctly in Catch after reverting the commit that
broke compilation with MSVC 9, so we have to live with explicitly using
the values of the correct type.
2017-11-23 02:02:19 +01:00
Maarten
bb9cd7a912 Fix rescaling image with wxIMAGE_QUALITY_BOX_AVERAGE
Work around rounding errors caused by using doubles.

Update reference images.

Closes https://github.com/wxWidgets/wxWidgets/pull/615
2017-11-23 00:36:46 +01:00
Vadim Zeitlin
0b8c4d54a8 Don't run FTP unit test by default any longer
ftp.wxwidgets.org seems to have gone, breaking the existing test (thanks
chris for all the fish...), so don't hardcode this URL in the test and,
without it, don't run the test by default any more and require
specifying a working FTP host (as well as an existing directory and a
file on it) when running it manually.

Rewrite the test using normal functions instead of Java-like structure
imposed by CppUnit to make it simple to skip it.
2017-11-22 22:48:05 +01:00
Vadim Zeitlin
f7d9098f1f Fix building wxVector unit tests in STL build without C++11
There is no shrink_to_fit() in wxVector in this case.

Arguably, we shouldn't be building wxVector unit tests in STL build at
all as there is no point in testing the standard class, but OTOH it
could be useful for checking that the tests themselves are correct, so
keep them for now.
2017-11-21 14:44:06 +01:00
Vadim Zeitlin
4ccda3959e Show more information for wxImage::Scale() unit test failures
Output the maximal difference between the differing images pixels to
show just how far are they from each other, exactly. And show the image
file name as well, for convenience.

Also run all checks instead of stopping after the first failing one.
2017-11-21 14:27:29 +01:00
Vadim Zeitlin
53443b5370 Add wxVector::shrink_to_fit() for C++11 compatibility
Also use this for wxArray::Shrink() implementation as it's more
efficient than the old swap-based implementation which requires an extra
memory allocation instead of really shrinking the existing one.
2017-11-19 22:09:37 +01:00
Vadim Zeitlin
8246c922af Add wxVector::insert() overload taking count of items to insert
Generalize the existing insert() to be more compatible with std::vector.
2017-11-19 22:08:54 +01:00
Vadim Zeitlin
25a7c70631 Implement wxVector::reverse_iterator::operator-()
Make wxVector reverse iterators (and const versions of them) more
compatible with the std::vector ones.
2017-11-19 22:08:54 +01:00