Commit Graph

253 Commits

Author SHA1 Message Date
Vadim Zeitlin
f3c148cd4a Verify that wxTextCtrl::ChangeValue("") doesn't generate events
Check that changing the value of an already empty control to empty
doesn't result in any events.

See #18264.
2018-10-30 01:35:32 +01:00
Vadim Zeitlin
602b4a6863 Run all wxTextEntry unit tests for wxTextCtrl too
Comment stated that InsertionPoint() didn't pass, but it was actually
already running (and passing) and the only excluded test was the
TextChangeEvents() one which really should pass for multiline controls
as well, so run it too.
2018-10-30 01:34:27 +01:00
Maarten Bent
7c1ab06ea5 Add more wxOVERRIDE 2018-09-22 14:44:07 +02:00
Maarten Bent
837b7ca3e1 Fix ambiguous call to wxNotebook::DeletePage 2018-09-19 22:01:18 +02:00
Maarten Bent
a914478f60 Add guards around test cases 2018-09-19 22:01:17 +02:00
Vadim Zeitlin
b88d5e08ce Fix adding pages without associated window to wxTreebook
wxTreebook is supposed to allow not specifying any valid window for the
top-level pages, but this didn't work any longer, probably since the
changes of 02a92e23f3 (see #4379), as a
possibly null page was dereferenced without checking, resulting in a
crash.

Fix this by adding a missing check.

Also rename DoGetNonNullPage() to TryGetNonNullPage() to make it more
clear that this function can return null and add a unit test checking
that calling AddPage(NULL) really works (or at least doesn't crash).

See https://github.com/wxWidgets/wxWidgets/pull/921
2018-09-18 00:33:59 +02:00
Vadim Zeitlin
3c8b9589d8 Test that wxTreeCtrl::DeleteAllItems() does send events
This seems to be the case under all still supported MSW versions, so
remove the note saying that the events might not be sent from the
documentation and add a unit test verifying that they are indeed sent.
2018-08-14 17:50:28 +02:00
Vadim Zeitlin
d9d05bc221 Document that wxTreeCtrl::DeleteChildren() does send events
Contrary to what the documentation stated previously, this function does
generate the wxEVT_TREE_DELETE_ITEM events for all the items being
deleted, in both MSW and generic implementations.

Update the documentation and add a new unit test checking that the
behaviour really conforms to it.
2018-08-14 17:48:46 +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
fb71adab04 Add a unit test for wxDatePickerCtrl focus events
Unfortunately it doesn't work with wxGTK, as usual, due to
wxUIActionSimulator not working correctly there.
2018-07-25 18:18:18 +02:00
Vadim Zeitlin
06f554775c Add unit test for wxTextCtrl::HitTest() for single line controls
Note that the control needs to be created with a reasonable size for
HitTest() to work correctly (at least under MSW, but probably not only),
so change the test set up function to use some fixed size for all kinds
of controls instead of doing it only for the multi-line ones.
2018-06-03 17:05:11 +02:00
Vadim Zeitlin
3d9d46b754 Don't send "page changed" events from wxNotebook dtor with GTK+ 3
These events are unexpected and inconsistent with the other platforms,
including GTK+ 2, so make sure we don't send them during the
destruction.

Closes https://github.com/wxWidgets/wxWidgets/pull/821
2018-05-31 11:42: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
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
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
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
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
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
f5703673ad Skip focus event test when running under buildbot
This test seems to consistently fail, but the failure can't be
reproduced locally nor debugged on buildbot, so, lacking any other
solution, just disable it.
2017-11-14 02:41:58 +01:00
Vadim Zeitlin
f3995658ff Increase timeout for WindowTestCase::FocusEvent()
The default 100ms doesn't seem to be enough when this test runs under
buildbot.
2017-11-14 00:06:21 +01:00
Vadim Zeitlin
f0a32f0e1f Wait for the focus event to occur in the unit test
The test failed unless we dispatched events with wxGTK (both 2 and 3).
2017-11-07 15:44:18 +01:00
Vadim Zeitlin
66324470f1 Fix wxTextCtrl::GetStyle() with GTK+ 3
The text and background colours are now stored in the rgba array instead
of fg_color and bg_color as with GTK+ 2 (the latter ones seem to have
been repurposed for the underline and strike-through colours!).

Also make the unit test for this method more robust.
2017-11-07 15:40:29 +01:00
Vadim Zeitlin
5fb740fed8 Add a layout hack to PositionToCoords() unit test for wxGTK
The text control needs a few event loop iterations in order to layout
itself correctly, so give it up to 1 second to do it in order to avoid
spurious test failures that occurred if just a single call to wxYield()
were done (or, worse, none at all as it was the case before).

Also log the value returned by PositionToCoords() in case of test
failures.
2017-11-07 15:03:59 +01:00
Vadim Zeitlin
407d38d9ed Always use wxTE_MULTILINE explicitly in PositionToCoords() test
While it is added implicitly when running all tests in the order, this
style wasn't used if just this test was ran using "-c PositionToCoords"
option.

Specify wxTE_MULTILINE in it explicitly to allow this to work too.
2017-11-07 14:23:07 +01:00
Vadim Zeitlin
faad429b0f Fix wxTextCtrl::XYToPosition() for last position in wxGTK
Change this method to consider the coordinates corresponding to the last
position (i.e. the one beyond the last text character) as valid, for
consistency with wxMSW and to conform to the documented behaviour.

Also give more information about the failures in the corresponding unit
test to make debugging problems with this function simpler.
2017-11-07 14:12:48 +01:00
Vadim Zeitlin
13163fb315 Send event when clearing wxTextCtrl in wxGTK again
This was broken by 1c946a469a and resulted
in test failures in OwnerDrawnComboBoxTestCase::TextChangeEvents() unit
test because wxOwnerDrawnComboBox::Clear() used SetValue("") and didn't
generate any events any more.

Fix this regression by explicitly sending an event if we're returning
early and add a unit test explicitly checking that SetValue("") does
generate an event.
2017-11-07 03:12:10 +01:00
Vadim Zeitlin
7e0b6d4d81 Merge branch 'webview-js-retval'
Integrate GSoC 2017 work by Jose Lorenzo on allowing returning values
from JavaScript code via wxWebView::RunScript().
2017-11-04 16:07:51 +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
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
Vadim Zeitlin
ae88141fa0 Don't define unnecessary constants in public webview_ie.h
There is no need to check that calling MSWSetModernEmulationLevel()
changed the registry key in the test, this is just an implementation
detail of this function.

This makes it unnecessary to define wxIE_EMULATION_LEVEL and
wxREGISTRY_IE_PATH (which are both badly named) in the public header.

Finally, improve the error message in MSWSetModernEmulationLevel() and
add another one for failing to reset the emulation level too.
2017-10-22 23:37:42 +02:00
Jose Lorenzo
af8f7f33c3 Merge wxWebView JavaScript improvements branch
This is a squashed commit of the SOC2017_WEBVIEW_JS branch from
https://github.com/joseeloren/wxWidgets.git

Closes https://github.com/wxWidgets/wxWidgets/pull/538
2017-10-21 22:42:30 +02:00
Paul Cornett
63a8a852f9 Avoid unused variable warning 2017-10-01 09:46:56 -07:00
Paul Cornett
a87599b127 Fix building tests with wxUSE_UIACTIONSIMULATOR==0 2017-10-01 09:44:53 -07:00
Artur Wieczorek
4fc8753285 Test PositionToXY and XYToPostion also for multiline Rich Edit controls 2017-09-01 11:00:06 +02:00
Artur Wieczorek
691f530359 Swap arguments of CPPUNIT_ASSERT_EQUAL
Expected value should be passed as a first argument to CPPUNIT_ASSERT_EQUAL and actual value as a second one.
2017-09-01 08:26:15 +02:00
Artur Wieczorek
4308386eff Extend XYToPostion unit test for multiline controls
Extend the ranges of tested X,Y coordinates
to cover also areas beyond the text.
2017-08-31 21:32:01 +02:00
Vadim Zeitlin
af0a938a65 Enable InsertionPoint unit test for multiline text controls too
There doesn't seem to be any reason to not run it.
2017-08-25 01:45:41 +02:00
Vadim Zeitlin
e74fb5effe Account for the last position in wxMSW wxTextCtrl
There is a valid position after the last character of the text in
wxTextCtrl, e.g. position 0 in the empty control, so account for it and,
notably, don't return -1 from XYToPosition(0, 0) when the control is
empty.

This fixes a regression in a69ab2907c.
2017-08-25 01:45:37 +02:00
Artur Wieczorek
497f275e1b Add PositionToXY() and XYToPosition() to wxTextCtrl unit test
Added tests of PositionToXY() and XYToPosition() for multi- and single-line wxTextCtrl.
2017-07-30 09:56:27 +02:00
Jose Lorenzo
b6f2973c41 Return true from wxDialog::IsModal() in wxEVT_INIT_DIALOG handler
Ensure that checking for dialog modality in wxEVT_INIT_DIALOG handler returns
true when the dialog is being shown modally in MSW and GTK.

Add a unit test checking that this is the case.

Closes #10385.
2017-05-22 01:21:43 +02:00
Catalin
c4c7f12941 Do not explicitly tidy up when ending a test case 2017-05-14 22:32:59 +02:00
Catalin
640b7df69b Added a unit test for wxListCtrl::HitTest()
Run `ListBaseTestCase::HitTest()` only under MSW until proven to work with
other platforms too.
2017-05-14 22:32:08 +02:00
Dimitri Schoolwerth
5a7570bf7d Fix failing unit test in MarkupTestCase
One of the wxMarkupParser tests expects "&" to map to "&&" however
this, purposefully, is not the case any longer since
60bd6842e4. Fix by changing the expected
result to contain a single ampersand instead of double.
2017-04-13 00:27:41 +04:00
Vadim Zeitlin
4b4c572d5f Make wxTextCtrl Lines() unit test more robust
Verify that the last logical line was wrapped at least once, not exactly once,
as it could be wrapped more times depending on the font size.
2017-01-03 02:39:57 +01: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
9fee931d6d Work around a crash in wxGTK3 GUI test suite
The tests crashed after running ModalDialogsTestCase::FileDialog() because the
next call to wxYield() resulted in the completion of an async operation
launched by the native file dialog which tried to dereference the already
destroyed dialog.
2016-02-27 02:41:18 +01:00
Vadim Zeitlin
e29bfda8d8 Fix wxComboBox unit test under wxGTK after recent changes
wxEVT_COMBOBOX_CLOSEUP is sent during idle time after the changes of
a216806c99, so add wxYield() to make sure that
the unit test gets it.

See #17223.
2016-02-27 02:41:11 +01:00
Vadim Zeitlin
cceddaf3da dd a hack to make wxBitmapComboBox Editable() unit test pass
Sleep for a little while before sending text to this control as the test often
(although not always) fails without it under wxGTK.
2016-02-27 01:14:24 +01:00
Vadim Zeitlin
78d09e2e90 Document and test wxDatePickerCtrl::SetRange() date-clamping behaviour.
Document that the current value of the control is adjusted if it doesn't lie
in the newly set range and add a unit test to check for this, now that it
actually passes under all platforms, after the previous commits.
2015-07-17 17:59:40 +02:00