Commit Graph

97 Commits

Author SHA1 Message Date
Arrigo Marchiori
d16787e1af Fix tests build with wxNO_IMPLICIT_WXSTRING_ENCODING
Add wxASCII_STR to the tests sources too.
2020-07-17 17:52:16 +02:00
ali kettab
59ad9f46e6 Make wxUIActionSimulator works more reliably on GTK/X11
Add wxXSync class which adds delays between the synthesized events
sufficient for them to be processed by the higher layers (X, GTK).

This makes it possible to run the UI tests by default with wxGTK.

Closes https://github.com/wxWidgets/wxWidgets/pull/1845
2020-05-15 00:36:00 +02:00
Vadim Zeitlin
6fcf285136 Merge branch 'more-travis'
Test Linux on ARM, PPC64 and S390 architectures on Travis CI too.

See https://github.com/wxWidgets/wxWidgets/pull/1783
2020-04-19 22:31:10 +02:00
Maarten Bent
7da632b438 Fix building test.cpp with c++17
uncaught_exception() has been replaced with uncaught_exceptions().
2020-04-08 22:13:53 +02:00
Vadim Zeitlin
17c7469af3 Switch to manual method of LXC "detection"
Just define wxLXC environment variable for the builds using LXC on
Travis.
2020-04-07 17:15:04 +02:00
Vadim Zeitlin
82cfdd07c2 Disable tests of /proc/cpuinfo in LXC containers
It seems that we can't access /proc files when running inside such
containers, so don't try to do it.
2020-04-07 14:30:01 +02:00
Vadim Zeitlin
e376e74210 Fix build-breaking typo in the GUI test suite
Fix after afe1816996.

See #17400.
2019-11-01 00:53:12 +01:00
Vadim Zeitlin
1439845802 Remove extra new lines after GTK log messages
This seems unnecessary as the default log handler already outputs a new
line at the end of the message anyhow and at least some messages (e.g.
debug ones in GdkPixbuf) also contain an extra new line in them, so
adding another one here resulted in having at least one and sometimes
two extra blank lines.
2019-11-01 00:10:27 +01:00
Vadim Zeitlin
afe1816996 Ignore GTK debug logs in the unit test unless they're enabled
Don't output "*** GTK log message while running" messages for every
g_debug() call when we the debug messages themselves will not be
displayed because G_MESSAGES_DEBUG is not set or its value doesn't
include the domain used by the message.

This results in much more reasonable output from the test suite.

See #17400.
2019-11-01 00:09:52 +01:00
Vadim Zeitlin
2228caa8d4 Don't disable logging in the tests if WXTRACE is set
Disabling logging makes WXTRACE useless, so avoid doing it in this case
to facilitate debugging the code exercised by the tests.
2019-10-14 23:40:08 +02:00
Vadim Zeitlin
ee0f21388f Add a helper IsRunningUnderXvfb() function to the test suite
This will allow disabling some tests which fail when running only under
Xvfb.

The new function doesn't work automatically because there doesn't seem
to be any way to distinguish it from the usual server, so it just checks
whether wxUSE_XVFB=1 is set in the environment, as is done by Travis CI
build script.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
dcee3ce899 Suppress some harmless clang warnings in the test suite
Use wxCLANG_WARNING_SUPPRESS() to avoid multiple warnings in CATCH
headers as well as in some of our own tests.
2019-01-04 23:51:31 +01:00
Maarten Bent
7c1ab06ea5 Add more wxOVERRIDE 2018-09-22 14:44:07 +02:00
Maarten Bent
57180d68c8 Add wxOVERRIDE to test files
And cleanup some tailing spaces and tabs.
2018-07-29 12:08:53 +02: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
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
5463402e39 Try to show when do X errors happen while running tests
Install an X11 error handler to try to gather more information about the
GUI tests failures on buildbot.
2017-11-14 02:57:57 +01:00
Vadim Zeitlin
643071fc77 Add more new lines around GTK errors in the test suite
Try to make things a bit more readable.
2017-11-07 16:21:38 +01:00
Vadim Zeitlin
99378ed0d7 Disable tests using wxUIActionSimulator under non-MSW platforms
wxUIActionSimulator is just too unreliable to be used there, so while
fixing it should really be a priority, for now at least prevent these
spurious failures from masking any other ones, which indicate real
problems that need to be fixed.

Notice that these tests can still be enabled by setting the environment
variable WX_UI_TESTS to 1 (or disabled by setting it to 0 under MSW).
2017-11-05 17:51:55 +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
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
1821a4043b Fix compilation error in a recent commit
Add semicolon missing from 7a2df9534c.
2017-03-11 03:48:06 +01:00
Vadim Zeitlin
7a2df9534c Recognize Travis CI environment in the tests
Avoid running time-sensitive tests such as StopWatchTestCase under Travis as
they can result in spurious failures if the machine running the test is under
too much load.
2017-03-11 03:35:11 +01:00
Jouk
d2b3484e60 g_log_set_default_handler not avaliable for gtk1 2016-07-08 15:15:27 +02:00
Vadim Zeitlin
68d235fed3 Output test name before GTK error messages in the test suite
Try to make it possible to understand where exactly do the GTK+ errors
appearing in the buildbot slaves output originate from by installing a custom
Glib log handler and prefixing the normal log messages with the name of the
test running when they're generated.

This required a small refactoring of DetailListener which is now always
installed, in order to always have access to the current test name, but still
needs to be explicitly enabled to produce output.
2016-06-29 18:49:47 +02:00
Vadim Zeitlin
8686ca62e7 Avoid asserts when destroying windows with mouse capture in tests
Destroying a window with mouse capture results in an assert, which is
translated into an exception when running the test suite. As this exception is
thrown from wxWindowBase dtor, it results in an immediate program termination
when using C++11 and can also have the same effect even when using C++98 if
this exception is thrown while already handling another exception due to a
test failure.

Try to avoid this by using a "safe" DeleteTestWindow() function instead of
deleting the window directly. Currently this function ensures that the window
doesn't have mouse capture before deleting it, but it could also be used to
check for other things later. Also, this commit only uses this function for
the two controls which do happen to be destroyed with mouse capture currently
(at least when using wxGTK), but it should probably be generalized to all
controls in the future.
2016-06-29 18:26:11 +02:00
Vadim Zeitlin
de491dd67f Show wxTestableFrame from its ctor
No real changes, just always show the frame as we need it to be shown for the
tests to run anyhow.

Also update the nonsensical comment about creating a hidden window just before
showing it.
2016-02-27 02:41:18 +01:00
Vadim Zeitlin
54c874d488 Don't duplicate information in detailed test output
No need to output wxGetOsDescription() twice.
2016-02-13 18:34:47 +01:00
Vadim Zeitlin
bef874a674 Skip network tests when running under Travis CI
These tests fail sporadically for some reason outside of our control, just
skip them rather than have frequent false positives.
2016-01-26 23:19:51 +01:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Vadim Zeitlin
2d7875c926 Restore OnRun() in the non-GUI unit test suite.
Commit 3e67b1ef68 broke the test suite in
non-GUI case, we still need to override OnRun() then to run the tests.

Also make it more clear that m_exitcode is only used in the GUI case.
2015-04-12 18:21:47 +02:00
Vadim Zeitlin
3e67b1ef68 Fix the unit test suite exit code in case of failure.
Return the program exit code from the (overridden) OnRun(), not OnExit(),
doing it from the latter didn't work since many years.

The failures in the GUI tests will be detected by buildbot now.
2015-04-12 17:51:30 +02:00
Vadim Zeitlin
e8d969244e Check for "buildbot" user in IsAutomaticTest().
The new buildbot setup runs the code under this user, so adjust the check for
running under buildbot to detect it.
2015-04-12 17:40:10 +02:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
e77dc839af Use normal event loop in GUI test program.
Don't create an event loop manually, let the port-specific code do it and run
it as usual in the GUI unit tests.

This has several advantages:
 - No need to manage the event loop manually in the test.
 - No need for Mac-specific code in the test itself.
 - Code being tested runs in the same context as in a normal GUI program,
   which is especially important for event-loop related tests under wxOSX as
   the main event loop is special there.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-03 00:25:46 +00:00
Stefan Csomor
234e255639 wait for the frame window to be really done on OSX before starting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-06-13 00:15:59 +00:00
Vadim Zeitlin
92318ee1fd Recognize "sandbox" user as indicating automatic testing.
The buildbot slaves actually use "sandbox" as the user name, not "buildbot",
so test for the former instead for the latter, see r73963.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73965 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-12 19:19:43 +00:00
Vadim Zeitlin
6524d302d0 Recognize "buildbot" user in IsAutomaticTest() too.
Some build slaves apparently run under "buildbot" user and not "buildslave",
recognize them as running automatic tests too.

Also show the name of the current system and user on startup to avoid such
guess work in the future.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73963 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-10 19:21:42 +00:00
Vadim Zeitlin
7582edfbf9 Fix wxLocale::GetInfo() in C locale under Windows.
Don't use LOCALE_USER_DEFAULT when the locale hadn't been changed because the
user default locale often (and maybe even always) is different from "C" locale
used by the CRT resulting in mismatch between the conventions used by
wxDateTime::Format(), which uses the CRT locale, and wxDateTime::Parse(),
which uses Windows format. Instead use the hard-coded values corresponding to
the "C" locale to ensure we use the same values as the CRT in this case.

This also reverts r73244 which was applies to make the unit tests pass before
this fix as it's not necessary any longer.

Closes #14918.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-12-29 21:53:13 +00:00
Vadim Zeitlin
9de31412ed Add a temporary workaround to make the tests pass.
Call SetCLocale() on tests startup to avoid problems with wxDateTime parsing
that happen when the user locale is different from "C" one under Windows.

See #14918.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73244 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-12-22 02:35:07 +00:00
Vadim Zeitlin
c66bfe457c Show some information about the environment in the unit tests.
For now just show the system description and the locale, this should already
be helpful for diagnosing some test failures.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72759 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-10-24 23:14:01 +00:00
Vadim Zeitlin
d01ec0965c No changes, just suppress an unused variable warning.
Omit the name of the exception object that we never use.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71910 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-06-30 23:41:33 +00:00
Vadim Zeitlin
f1287154cd Add IsAutomaticTest() function to the unit tests.
This allows to easily test if we're running on a buildbot slave and disable
some difficult to debug test failures there.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-06-01 16:21:06 +00:00
Vadim Zeitlin
e84d989930 Use printf() instead of wxPrintf() in cppunit details listener.
Wide char output from wxPrintf() didn't appear at all under Linux because
stdout was switched into narrow stream mode by GNU libc due to initial use of
cout in the test.

Use printf() instead of wxPrintf() as we are only printing ASCII strings
anyhow. Of course, this is not a real fix but at least we can see the tests
results like this.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-06-01 16:21:03 +00:00
Vadim Zeitlin
b57655127d Improve error reporting for nested asserts failures in the test suite.
If an assert occurred while handling an exception generated by a previous
assert handler, the information about the original assert was lost even if
though it was more important than the secondary assert. Do preserve and show
the original assert message in this case now.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71318 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-04-29 23:22:08 +00:00
Vadim Zeitlin
bb5a951418 Use __WINDOWS__ for OS checks and __WXMSW__ for GUI checks (round 2).
This is continuation of r70796 and serves the same purpose.

Closes #14065, #14066.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70808 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-03-04 20:31:42 +00:00
Michael Wetherell
0dffa8059d Change the return code of the test program so that aborting a test with an
exception doesn't count as a failure, to provide a way to skip tests that
can't be performed.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65869 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-10-22 22:15:07 +00:00
Vadim Zeitlin
33f7fa342f Don't throw assert failure exception in the test suite if it's unsafe.
Don't throw when already handling an exception as it would result in a call to
terminate() and no useful information about the test failure would be given.
Abort ourselves instead to at least give the message about the assert failure.

This should help debug the mysterious ListCtrlTestCase failures in buildbot
wxGTK builds.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65760 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-10-04 10:53:37 +00:00