Commit Graph

277 Commits

Author SHA1 Message Date
Vadim Zeitlin
5811d541da Refactor code waiting for events in the test suite
We already had WX_ASSERT_EVENT_OCCURS_IN macro and a recent commit also
added code doing almost the same thing manually in wxTopLevelWindow unit
test, which was one version too many.

Replace both of them with the new EventCounter::WaitEvent().

No real changes, this is just a refactoring.
2019-01-24 22:52:46 +01:00
Vadim Zeitlin
f4ea128007 Include wx/stopwatch.h explicitly from wxTextCtrl unit test
Don't rely on it being implicitly included from another header when we
use wxStopWatch in this file (with wxGTK only).
2019-01-24 22:52:46 +01:00
Vadim Zeitlin
7c831d25ee Group headers together in wxTextCtrl unit test
No real changes.
2019-01-24 22:52:46 +01:00
Richard Smith
537b2c3bb0 Reinstate wxTextCtrl unit test previously disabled for wxQt
This test was fixed by earlier changes to wxQt font styles and passes
now.

Closes https://github.com/wxWidgets/wxWidgets/pull/1169
2019-01-23 16:48:26 +01:00
Richard Smith
4c05b3650a Add a test for WriteText and fix implementation in wxQt 2019-01-21 23:09:17 +01:00
Vadim Zeitlin
7f63adde95 Merge branch 'select-after-delete'
Harmonize behaviour of wxItemContainer::Delete() for all controls and
ports when using single selection.

See https://github.com/wxWidgets/wxWidgets/pull/1080

Closes #18267.
2019-01-04 14:01:02 +01:00
Cătălin Răceanu
5885b2f142 Test that selecting 'single' radio button does not reset others
Add a unit test for the expected behaviour.

Closes https://github.com/wxWidgets/wxWidgets/pull/1102
2019-01-04 13:59:06 +01:00
chris2oph
155a19a1a2 Improve checks for dates range in wxQt wxCalendarCtrl
Account for the minimum and maximum dates supported by QDatePicker, both
in the code and in the test suite, which shouldn't rely on not having
any range restrictions in wxQt.

Closes https://github.com/wxWidgets/wxWidgets/pull/1088
2019-01-03 00:18:37 +01:00
Richard Smith
0fbf87d11b Split single/multi line behaviour in Qt wxTextCtrl
Introduce wxQtEdit class and wxQtMultiLineEdit and wxQtSingleLineEdit
derived classes instead of using ifs in many wxTextCtrl methods, making
the code more clear and maintainable.

Also fix some wxTextCtrl-related unit test failures with wxQt and
disable some other ones which still don't pass.

Closes https://github.com/wxWidgets/wxWidgets/pull/1039
2018-12-24 01:52:07 +01:00
Sebastian Walderich
e9cbbede00 Implement wxAuiNotebook::GetBestSize()
Compute the best size of the notebook, taking into account all the
different layout possibilities, and add a test checking that this works
as expected.

Closes https://github.com/wxWidgets/wxWidgets/pull/1085
2018-12-23 17:05:09 +01:00
Vadim Zeitlin
b825c49c2e Document and test wxItemContainer::Delete() selection handling
Add test checking that selection is reset when deleting the selected
item or any item before, but not after, it.

Also explicitly document this behaviour.
2018-12-15 23:47:26 +01:00
Vadim Zeitlin
e0e4f16282 Fix a typo in ItemContainerTestCase comment
No real changes, just fix a copy-and-pasto.
2018-12-15 23:04:30 +01:00
Vadim Zeitlin
4ed28f681f Add a common tag for wxItemContainer-derived classes tests
This makes it possible to run the tests for all controls implementing
wxItemContainer interface by just passing "[item-container]" on the test
command line.
2018-12-15 23:04:30 +01:00
Vadim Zeitlin
c95f668b21 Fix use of dangling pointer in ButtonTestCase::Disabled()
Fix the test added in dfec7aa0c0 which
deleted the button pointer used by EventCounter by simply moving
EventCounter initialization after the button re-creation.

See #16385.
2018-12-13 00:39:25 +01:00
Vadim Zeitlin
dfec7aa0c0 Make disabling the window before creating it actually work
Disabling a window before actually creating it ought to work, similarly
to hiding a window before creating it which can be used to avoid showing
the window on screen at all, even briefly. However it didn't under MSW
where the window was disabled from wxWidgets point of view, but not at
the MSW level.

Fix this by accounting for the enabled state in MSWGetStyle().

Closes #16385.
2018-12-09 19:20:50 +01:00
oleksii.vorobiov
fd5c62bc41 Make updating the value in wxEVT_SPINCTRL work in wxMSW
In wxMSW, the value of the control was modified after executing the
user-defined wxEVT_SPINCTRL handler which meant that any calls to
SetValue() there were effectively ignored.

Fix this and add a unit test checking for the described scenario.

Closes https://github.com/wxWidgets/wxWidgets/pull/1027

Closes #18187.
2018-12-08 19:51:56 +01:00
Vadim Zeitlin
767639276f Disable failing wxDataViewCtrl::IsExpanded() test under Mac
For some unfathomable reason IsExpanded() returns wrong value for one of
the items. This should be fixed, but for now just leave a warning in the
test but don't fail it.

Also document this bug to at least spare people some surprises.
2018-11-06 04:03:34 +01:00
Vadim Zeitlin
fad50e74b7 Fix wxDataViewCtrl::GetItemRect() in wxGTK and enable its test
A couple of fixes compared to the previous commit:

- Use the correct gtk_tree_view_get_cell_area() rather than
  gtk_tree_view_get_background_area() which doesn't work correctly
  for the items which are not shown because their parent is collapsed.
- Translate logical coordinates to physical ones using
  gtk_tree_view_convert_bin_window_to_widget_coords().

With these fixes, the unit tests for this function pass and can now be
enabled under wxGTK as well.

See https://github.com/wxWidgets/wxWidgets/pull/990
2018-11-04 18:28:59 +01:00
Vadim Zeitlin
9460038b3f Return empty rectangle from GetItemRect() if item is not visible
This was already the case if the item was not visible because its parent
was not expanded, but now make it also true for the items which are not
visible due to the current scrollbar position.

Add unit tests checking for this and also verifying that GetItemRect()
returns the coordinates in the physical window coordinates.
2018-11-04 18:28:33 +01:00
Vadim Zeitlin
9b7757c44d Ensure that wxDataViewMainWindow has correct size in the test
Replace a redundant (because the same size was already specified in the
ctor) SetSize() call with a Layout() call which resizes
wxDataViewMainWindow to fit the parent control size when using the
generic implementation.

This is important for any tests dealing with the control geometry, i.e.
calling GetItemRect() or HitTest().
2018-11-04 17:49:12 +01:00
Vadim Zeitlin
ada5de3d0d Fix wxDataViewCtrl::GetItemRect() for collapsed items
Calling GetItemRect() for an item which was not currently visible
because its parent was collapsed resulted in silently returning the
value for a wrong value before the recent fix to GetRowByItem() and in
a crash after it because GetTreeNodeByRow() returned null when passed
invalid row index.

Fix this by explicitly checking whether the item is shown and just
returning an empty rectangle instead.

Also document this behaviour and add a unit test for it.
2018-11-04 17:15:42 +01:00
Vadim Zeitlin
31c49caab5 Add unit test for wxDataViewCtrl::IsExpanded()
Check that it returns correct results, both for the currently visible
and hidden items.
2018-11-04 17:10:23 +01:00
Vadim Zeitlin
fe865a1743 Rewrite wxDataViewCtrl unit test without using CppUnit macros
Use CATCH API directly, this simplifies the code and makes adding new
tests simpler.

No real changes yet.
2018-11-04 14:34:49 +01:00
Vadim Zeitlin
8e817f8a0e Don't send events from wxTextCtrl::ChangeValue("") in wxGTK
ChangeValue() must not send events, but did in wxGTK when changing the
contents of a wxTextCtrl to be empty when it had been non-empty before.

Closes #18264.
2018-11-01 02:04:01 +01:00
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