Commit Graph

63193 Commits

Author SHA1 Message Date
Vadim Zeitlin
70c057ed8a Revert "Test using previous build platform for AppVeyor"
This reverts commit b05d864f5e as it
didn't help with Python-related build failures, finally.
2017-11-03 16:58:33 +01:00
Vadim Zeitlin
257974e321 Work around using Python in Cygwin AppVeyor build
This doesn't work any longer since Cygwin Python 2.7.14 update, see
https://cygwin.com/ml/cygwin/2017-11/msg00053.html

Avoid using it by preventing include/wx/stc/stc.h file from being
updated, this shouldn't be necessary anyhow as the version in git should
be already up-to-date.
2017-11-03 15:46:33 +01:00
Vadim Zeitlin
e3589af56a Fix wxStringOutputStream position when using external string
Initialize m_pos correctly when using an existing, and hence possibly
not empty, string (and not the internal one which is always empty
initially). The old code was totally wrong as it divided the string
length by the size of wxChar instead of multiplying by it, but doing
this could have been wrong too with UTF-16 and surrogates, so use the
conversion object to compute the real length of the string
representation in the corresponding encoding.

Add a simple unit test checking that this works as intended.

Closes #17985.
2017-11-03 15:25:36 +01:00
Vadim Zeitlin
8e7fef5f08 Make wxStringOutputStream ctor explicit
Avoid accidentally creating wxStringOutputStream from a wxString
pointer, this seems unlikely, but why take the risk of it happening at
all.
2017-11-03 00:36:48 +01:00
Vadim Zeitlin
e09d87f54b Move wxStringOutputStream ctor to the source file
There is no real need for this not quite trivial function to be inline.

No real changes.
2017-11-02 23:36:05 +01:00
mgimenez
16888e9883 Fix copy-paste typo in wxGrid::DeleteRows() documentation
Just use the correct verb.

Closes #17987.
2017-11-02 20:51:34 +01:00
Paul Cornett
d76e627341 More use of wxFALLTHROUGH 2017-11-02 08:56:29 -07:00
Paul Cornett
c2513d8a4e Add missing break statement 2017-11-02 08:55:00 -07:00
Vadim Zeitlin
f200015b3c Fix wxFileDialog::SetExtraControlCreator() supported platforms
Just remove them, actually, as this functionality is supported by all 3
major platforms.
2017-11-02 14:55:54 +01:00
Vadim Zeitlin
b3fe07942f Remove top level "const" from wxMBConv methods return values
This "const" is useless and doesn't actually do anything, remove it to
avoid confusion.
2017-11-02 01:57:22 +01:00
Vadim Zeitlin
6e7254a7a1 Move both wxMBConv::cXX2YY() overloads together
No real changes, just group the overloads in a more logical way.
2017-11-02 01:57:20 +01:00
Vadim Zeitlin
18063f38ff Update comment describing wxMBConv::cMB2WC() and cWC2MB()
Don't say that these functions return NULL pointers when they don't
return pointers at all any more (and since quite some time).
2017-11-02 01:57:18 +01:00
Vadim Zeitlin
72781e78d8 Merge branch 'catchify'
Switch from CppUnit to Catch for the unit tests.

Closes https://github.com/wxWidgets/wxWidgets/pull/577
2017-11-02 01:55:00 +01:00
Vadim Zeitlin
62979a5f6f Remove unused member variables from unit testing class
Thanks clang for the reminder about them with its -Wunused-private-field
warnings.
2017-11-02 01:53:33 +01:00
Vadim Zeitlin
fdad46b10d Suppress some harmless clang warnings in a Catch header
Just avoid harmless but annoying warnings in catch_impl.hpp when using
clang.
2017-11-02 01:53:31 +01:00
Vadim Zeitlin
c363ce8500 Don't use "-t" option when running tests any longer
This option now lists the available tags instead of showing the timing
information.

We could use Catch "--durations yes" option, but it results in too much
output, so for now just run the tests with default verbosity.
2017-11-02 01:53:29 +01:00
Vadim Zeitlin
d78b7d2f27 Fix a typo in Catch tutorial link
No real changes.
2017-11-02 01:53:27 +01:00
Vadim Zeitlin
729dd5e693 Work around Catch multi-thread unsafety
Don't use Catch asserts in threads other than main, this doesn't work
reliably.

Switch to using simple wxASSERT() which doesn't give as much information
as Catch asserts when the test fails, but at least allows the tests to
pass when the asserts don't fail.
2017-11-02 01:53:25 +01:00
Vadim Zeitlin
ebf30adeb6 Avoid calling strftime() with an invalid format string
This results in an assertion from MSVC CRT implementation which was
somehow consumed by CppUnit but with the switch to Catch resulted in a
test failure.
2017-11-02 01:53:23 +01:00
Vadim Zeitlin
f3f345eec9 Fix harmless signed/unsigned comparison warnings in a test
These warnings appeared after switching to Catch, just use the same type
for all variables to avoid them.
2017-11-02 01:53:21 +01:00
Vadim Zeitlin
e70fc11ef1 Replace CppUnit with Catch for unit tests
Drop the legacy CppUnit testing framework used for the unit tests.
Replacing it with Catch has the advantage of not requiring CppUnit
libraries to be installed on the system in order to be able to run
tests (Catch is header-only and a copy of it is now included in the
main repository itself) and, in the future, of being able to write
the tests in a much more natural way.

For now, however, avoid changing the existing tests code as much as
[reasonably] possible to avoid introducing bugs in them and provide
the CppUnit compatibility macros in the new wx/catch_cppunit.h header
which allow to preserve the 99% of the existing code unchanged. Some
of the required changes are:

 - Decompose asserts using "a && b" conditions into multiple asserts
   checking "a" and "b" independently. This would have been better
   even with CppUnit (to know which part of condition exactly failed)
   and is required with Catch.

 - Use extra parentheses around such conditions when they can't be
   easily decomposed in the arrays test, due to the use of macros.
   This is not ideal from the point of view of messages given when
   the tests fail but will do for now.

 - Rewrite asserts using "a || b" as a combination of condition
   checks and assert macros. Again, this is better anyhow, and is
   required with Catch. Incidentally, this allowed to fix a bug in
   the "exec" unit test which didn't leave enough time for the new
   process to be launched before trying to kill it.

 - Remove multiple CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() macros,
   our emulation of this macro can be used only once.

 - Provide string conversions using Catch-specific StringMaker for
   a couple of types.

 - Replace custom wxImage comparison with a Catch-specific matcher
   class.

 - Remove most of test running logic from test.cpp, in particular don't
   parse command line ourselves any longer but use Catch built-in
   command line parser. This is a source of a minor regression:
   previously, both "Foo" and "FooTestCase" could be used as the name of
   the test to run, but now only the latter is accepted.
2017-11-02 01:53:16 +01:00
Vadim Zeitlin
b05d864f5e Test using previous build platform for AppVeyor
Try fixing Python-related build failures in Cygwin build by using the
previous version of the image, before the latest update.
2017-11-01 23:47:18 +01:00
Adrien Tétar
80e2264373 Fix wxBORDER_NONE handling for wxTextCtrl under GTK+ 3
Remove the border by applying custom CSS, which seems to be the only way
to do it with recent GTK+ versions.

Closes https://github.com/wxWidgets/wxWidgets/pull/576
2017-11-01 22:49:26 +01:00
Vadim Zeitlin
5520d56222 Remove test input file in file stream unit tests only once
Don't remove the files in the test cases classes dtors, this was
inconsistent with how they were created: we either need to create the
file in the ctor and destroy it in the dtor or do both only once
globally.

Implement the second solution using the helper AutoRemoveFile instead of
a simple static bool in GetInFileName() implementations.
2017-11-01 14:45:06 +01:00
Vadim Zeitlin
c54b611093 Replace few uses of CPPUNIT_TEST_FAIL with just CPPUNIT_TEST
Use positive tests really checking for whatever we want to check (that
the stream is not seekable in this particular case) instead of just
checking that the test fails, for whatever reason -- which might not be
at all the reason for which we expect it to fail.
2017-10-31 22:04:12 +01:00
Vadim Zeitlin
b8c9cd3528 Use wxScopedPtr<> instead of std::auto_ptr<> in the tests
It is better to use wholly non-standard wxWidgets smart pointer class
rather than using standard, but deprecated in C++17, std::auto_ptr<> as
this results in warnings from recent compilers.
2017-10-31 21:14:05 +01:00
Artur Wieczorek
1903c9615e TLW pending delete shouldn't be reported as the top window
Because top windows can (and do) act as parents for certain dialogs, a
window already pending delete shouldn't be explicitly reported as the top
window because all dialogs which would use it as a parent
would be destroyed at nearest idle cycle.

Closes #17982.
2017-10-31 20:47:45 +01:00
Vadim Zeitlin
9d0df5707a Include the required standard headers used in archives unit test
These files are currently implicitly included from other headers, but we
shouldn't rely on this and include them explicitly as we use std::map<>
and std::auto_ptr<> in this header.

No real changes.
2017-10-30 15:29:30 +01:00
Vadim Zeitlin
7b10210763 Move WX_ASSERT_STRARRAY_EQUAL() to the only test using it
It doesn't seem useful to have this macro in the header included by all
tests when it's only used in a single one of them.
2017-10-30 14:44:20 +01:00
Vadim Zeitlin
9f609a8148 Remove WXTEST_WITH_CONDITION macro to simplify the code
It was only used as part of WXTEST_WITH_GZIP_CONDITION which was
necessary only to support running the tests on systems using zlib < 1.2
which is not a concern since many years any more, so simplify the code
by using the simple non-conditional CPPUNIT_TEST instead and drop the
helper macros which were required only for this.
2017-10-30 14:16:11 +01:00
Vadim Zeitlin
b5aaede7b1 Add a helper for running fuzz function with a single input
This is useful when not using libFuzzer (e.g. because the compiler is
gcc or MSVC and not clang) as it allows to debug the problems found by
libFuzzer with the reproducers generated by it.
2017-10-28 15:12:14 +02:00
Vadim Zeitlin
ce3d416247 Make wx/buffer.h header self-contained
Including this header as the first wxWidgets header in a translation
unit resulted in compilation errors due to including the internal
wx/wxcrtbase.h header before including wx/defs.h, which must be included
before it (at least to define DLL import/export macros and sized char
types used in wx/wxcrtbase.h).

Fix this by simply including wx/defs.h from wx/buffer.h.
2017-10-28 15:07:35 +02:00
Vadim Zeitlin
d83b144727 Fix integer overflow in ZIP reading code
Check for the record size before subtracting it from the end position:
the former must be smaller than the latter for all valid ZIP files and
not performing this check could result in an integer overflow error from
the undefined behaviour sanitizer for bad input.

Credit to OSS-Fuzz: this solves its issue 3828.
2017-10-28 15:02:12 +02:00
Vadim Zeitlin
bb949e9847 Slightly improve wxMBConv::IsUTF8() documentation
Mention that this method is supposed to be used only as an optimization
and also mention that it hadn't been universally available until 3.1.1.

See https://github.com/wxWidgets/wxWidgets/pull/570
2017-10-28 01:10:51 +02:00
Tobias Taschner
fe77b2d593
Add support for UTF8 filenames in wxZipOutputStream
Zip filenames containing non ASCII characters will be marked with
bit 11 in the general purpose flags and will use UTF-8 encoding.

By only setting the flag when non ASCII characters are used the
created archives should be binary identical to previous versions.

The old behavior can be achieved by explicitly using wxConvLocal
with the constructor. This should also ensure that
existing code using a custom wxMBConv should work as before.
2017-10-27 20:27:44 +02:00
Tobias Taschner
73a22766ee
Always enable wxMBConv::IsUTF8()
These where previously guarded by wxUSE_UNICODE_UTF8 but
may be useful in other configurations too.
2017-10-27 20:13:04 +02:00
Paul Cornett
0cb55df404 Remove test code accidently committed in 44b30c1a60 2017-10-27 10:10:18 -07:00
Paul Cornett
44b30c1a60 Avoid use of GDBusServer object after it is destroyed 2017-10-27 10:05:43 -07:00
Vadim Zeitlin
677051b6e7 Remove hack with TLW focus reset from wxWindowMSW dtor
This shouldn't be needed any more, after the previous commit which
replaces the raw pointer to the focused child in wxTopLevelWindowMSW
with a safe weak reference.
2017-10-27 18:20:09 +02:00
Vadim Zeitlin
31d51186e2 Fix crash when reparenting the focused window to another TLW
If the window stored as m_winLastFocused in one TLW was reparented to
another one and then destroyed, this pointer to it wasn't updated and
became dangling.

Fix this by using a safe weak reference instead of raw pointer for
m_winLastFocused. This ensures that it can never be used when it becomes
invalid.

Closes #17980.
2017-10-27 18:18:14 +02:00
Vadim Zeitlin
c2d11dc275 Fix harmless MSVC warning about int to bool conversion
Compare the integer result of a bitwise operation with 0 explicitly to
avoid the C4800 warning given since the changes of the recent commit
802eac475d
2017-10-27 00:07:55 +02:00
Vadim Zeitlin
8a4573223e Fix invalid memcpy() call when reading corrupted ZIP files
Skip memcpy() call if its source and destination would overlap: this is
not allowed and is correctly flagged as an error by address sanitizer
and is unnecessary anyhow as we're certainly not going to find the magic
value in fewer than 3 remaining bytes.

Credit to OSS-Fuzz: this solves its issue 3794.
2017-10-25 17:11:36 +02:00
Vadim Zeitlin
802eac475d Fix undefined behaviour when reading corrupted ZIP files
Don't shift by m_SystemMadeBy value which can potentially be an
arbitrary (8 bit) integer and not necessarily one of the known (and
small) wxZIP_SYSTEM_XXX values, this results in undefined behaviour
whenever this value is greater than 32 or 64 (depending on int size) and
is flagged as such by clang undefined behaviour sanitizer.

To fix the problem, just use a more clear switch statement instead of
using a bit pattern for the lookup, this function is not nearly
performance-sensitive enough to worry about the overhead of the switch
here (assuming it's even slower, in the first place...) and the new
version is much more clear and maintainable.

Credit to OSS-Fuzz: this solves its issue 3792.
2017-10-25 16:38:37 +02:00
Vadim Zeitlin
d5a6568b21 Add a fuzzer for ZIP reading code
The new source file needs to be compiled with a recent clang using
libfuzzer using a command line similar to the following:

	$ clang++ -g -fsanitize=address -fsanitize-coverage=trace-pc-guard tests/fuzz/readzip.cpp `wx-config --cxxflags --libs base` -lFuzzer

and then executed passing it the corpus directory as parameter:

	$ ./a.out tests/fuzz/corpus/zip

This will be useful for finding more bugs like #17947 (and, indeed,
running it locally already found another assert failure, which will be
fixed soon).
2017-10-25 00:38:52 +02:00
Vadim Zeitlin
1519042018 Add missing wxOVERRIDE to avoid clang warning to wxAny unit test
Mark ConvertValue() virtual method inherited from the base class as
overridden to avoid clang -Winconsistent-missing-override warning.
2017-10-22 23:39:53 +02:00
Vadim Zeitlin
aa4c270d73 Fix warning about local variable shadowing in clipping unit test
Use "col" for the "wxColour" variable to avoid clash with "c" one used
for the corner index.

Also just construct the colour directly from the RGB values instead of
default-initializing it and then using Set(), which also allows to make
it "const".
2017-10-22 23:39:47 +02:00
Vadim Zeitlin
46fa106b10 Demonstrate using wxWebView::SetPage() in the sample
This allows to verify, at least interactively, that the expected events
are generated when using SetPage() too, and not only LoadPage().
2017-10-22 23:38:12 +02:00
Vadim Zeitlin
49401c960c Use HTTPS by default in the webview sample
This allows the sample to load the initial page when built using macOS
10.11 or later SDK which enables "app transport security" (ATS), which
prevents HTTP connections by default.
2017-10-22 23:38:10 +02:00
Vadim Zeitlin
b82af43361 Improve RunScript() and MSWSetModernEmulationLevel() documentation
Try to explain things better and add a couple of examples.
2017-10-22 23:38:08 +02:00
Vadim Zeitlin
6644a489e8 Test that RunScript() returns false in case of errors
Testing only for successful return is insufficient, we also need to
check that errors are detected.
2017-10-22 23:38:06 +02:00