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.
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
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.
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.
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.
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.