Commit Graph

326 Commits

Author SHA1 Message Date
Vadim Zeitlin
9a0072b12e Remove wxDECLARE_NO_COPY_CLASS from a local class in wxGrid test
Declaring the copy ctor/assignment operator for a local class without
defining them triggers MSVC warning C4822, so don't do this to avoid
unnecessary noise in the build logs (we could disable the warning or
conditionally do this for non-MSVC compilers, but it doesn't seem to be
worth doing this for a class used inside a single function and very
unlikely to be copied accidentally).
2019-09-26 22:23:36 +02:00
Vadim Zeitlin
fcd734387a Fix best size computation for multiline wxTextCtrl in wxGTK
The initial value was not taken into account before because the best
size computed before it was set, i.e. for the empty control, was always
used, as it was never invalidated.

Do invalidate it now if the control is created with non-empty value, in
order to adjust its best, and initial, size appropriately to its
contents.

Closes #18507.

Closes https://github.com/wxWidgets/wxWidgets/pull/1560
2019-09-18 14:35:12 +02:00
Vadim Zeitlin
93815ad2d2 Merge branch 'listctrl-itemrect'
Improve wxListCtrl::GetSubItemRect() and add a unit test for it.

See https://github.com/wxWidgets/wxWidgets/pull/1511
2019-09-14 16:37:57 +02:00
Ilya Sinitsyn
dda6aa6bdc Fix assert with setting current cell in wxGrid::Redimension()
Avoid calling wxGrid::SetCurrentCell(0, 0) when the grid has no columns
or rows, as it doesn't have any cells then and doing this logically
fails the precondition assert in GetColPos().

Also refactor all 6 different snippets calling SetCurrentCell() in
Redimension() into a single function to simplify the code and make it
more maintainable.

Add a unit test verifying that this works as intended.

Closes https://github.com/wxWidgets/wxWidgets/pull/1546
2019-09-13 00:47:48 +02:00
Vadim Zeitlin
c1fdc717ae Merge branch 'multiline-enter-fix'
Fix handling Enter in multiline text controls in wxMSW.

And other improvements, notably don't send wxEVT_TEXT_ENTER for controls
without wxTE_PROCESS_ENTER style.

Closes #18491.

See https://github.com/wxWidgets/wxWidgets/pull/1539
2019-09-12 00:50:00 +02:00
Artur Wieczorek
163c7cf834 Fix checking WXUSINGDLL in conditional block
We have to check if WXUSINGDLL macro is defined instead of checking its value.
2019-09-10 22:52:23 +02:00
Ilya Sinitsyn
e2bd6ec8f7 Fix clearing selection in a grid with reordered columns
Since the changes of 04f7f1fd32 (frozen
rows/columns implementation), RefreshBlock() could call GetColPos() with
an invalid index. This didn't matter most of the time as the function
simply returned the same index as long as the columns were using their
natural order, but resulted in a crash due to an out of bound access to
m_colAt array as soon as they were reordered.

Fix this by avoiding using invalid indices in RefreshBlock() and, more
generally, improving its precondition check and making the assumptions
about the input parameters more clear. Also add a defensive check to
GetColPos() itself.

Finally, add a unit test exercising this code.

Closes https://github.com/wxWidgets/wxWidgets/pull/1536
2019-09-10 19:41:45 +02:00
Vadim Zeitlin
9bab9d8da8 Don't activate default button on Enter in multiline wxTextCtrl
Restore behaviour until c43e0fa123 and let
Enter presses in multiline text controls perform their default function
in the control instead of closing the dialog.

Make the unit test more discerning to check for this.
2019-09-10 18:48:20 +02:00
Vadim Zeitlin
84f29ce472 Don't send EVT_TEXT_ENTER to controls without wxTE_PROCESS_ENTER
wxMSW always sent this event to multiline text controls, even when they
didn't have wxTE_PROCESS_ENTER style, contrary to what was documented.

Avoid sending this event unless wxTE_PROCESS_ENTER is used and add unit
tests checking that multiline text controls don't get it without this
style (but still do get it with it).
2019-09-10 18:48:20 +02:00
Vadim Zeitlin
4c075c2128 Replace Bind() call with an event table in Enter handling tests
For once, using the event table macros is preferable because this
bypasses the (generally helpful, but not here) test done by Bind()
verifying that wxEVT_TEXT_ENTER handler is bound to a window with
wxTE_PROCESS_ENTER style.

Doing it like this will allow to check that controls without this style
really do not receive the corresponding event.
2019-09-10 18:48:20 +02:00
Vadim Zeitlin
e85b5e5261 Replace a single function with a class in Enter processing tests
No real changes yet, this is a pure refactoring before the upcoming
changes.
2019-09-10 18:48:20 +02:00
Ilya Sinitsyn
e5d59c6b7f Respect minimum grid column width when using native header too
Override wxHeaderColumn::GetMinWidth() to return the actual minimum
width instead of just returning 0.

Add a unit test verifying that this works as intended.
2019-09-05 20:11:09 +02:00
Ilya Sinitsyn
2290d97453 Fix dragging grid columns when using scrolled native header
Drag-resizing the columns didn't work correctly when using the native
header and scrolling it horizontally, as the wrong offset was used in
this case.

Fix the offset in wxGrid code and add a unit test checking that this
works as intended (at least under MSW, as wxUIActionSimulator just
doesn't work reliably enough to test for this under the other platforms,
and, besides, only MSW has the native header control implementation
anyhow).
2019-09-05 20:11:09 +02:00
Ilya Sinitsyn
1bce1a1d4c Make using non-wxControl-derived wxGrid editors really work
While feacaf8714 changed the API to allow
using any wxWindow (and not only a window of a wxControl-derived class)
as the associated window of the grid editor, actually doing resulted in
an immediate crash due to dereferencing a null pointer in wxGrid code
which still expected to have a wxControl.

Fix this by replacing all calls to wxGridCellEditor::GetControl() inside
wxGrid with wxGridCellEditor::GetWindow(), to ensure that a non-null
editor window is used even in this case.

Closes https://github.com/wxWidgets/wxWidgets/pull/1509
2019-08-27 22:09:03 +02:00
oneeyeman1
7e3bbedaa5 Add a test case for wxListCtrl::GetSubItemRect()
Check that the results for the item icon/label rectangles are
consistent.
2019-08-27 17:12:47 +02:00
Vadim Zeitlin
bcf604b5cb Disable wxTE_PROCESS_ENTER unit tests under wxGTK
wxUIActionSimulator doesn't work reliably there and doesn't work at all
when using Xvfb.
2019-07-26 19:29:00 +02:00
Vadim Zeitlin
fb2c17c193 Merge remote-tracking branch 'sunset/process-enter'
Fix wxTE_PROCESS_ENTER logic for wxMSW and wxGTK too.

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

Closes #18273.
2019-07-26 18:02:08 +02:00
Vadim Zeitlin
5bd9c5b65b Test wxTextCtrl::HitTest() with negative coordinates under wxGTK
In wxGTK using negative coordinates with HitTest() happens to work and
it's useful to test that it does, as this test will run when the control
is scrolled even under Travis CI, unlike the test with positive
coordinates which doesn't work under Xvfb there and was disabled in the
previous commit.

Also document that passing negative coordinates to this function only
works in wxGTK.
2019-07-19 01:44:29 +02:00
Vadim Zeitlin
cfb12091ca Skip wxTextCtrl::HitTest() unit test failing under Xvfb
For some reason, wxTextCtrl scrolls much too far when running under
Xvfb, so the test assumption that it still has some visible characters
after calling SetInsertionPointEnd() fails and must be disabled in this
environment.
2019-07-19 01:41:13 +02:00
Vadim Zeitlin
c1cbacd0ad Skip wxWebView unit tests when using wxGTK2
All tests currently fail because the initial LOADED event is never
received.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
96c3b11b99 Disable another wxSTC unit test mysteriously failing under Xvfb
For some reason, the control does lose focus there, even if it doesn't
happen when using a normal X11 server.

Just disable the test in this environment.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
8b6f79c886 Disable wxStyledTextCtrl unit test failing under wxGTK
wxStyledTextCtrl does _not_ always retain focus under wxGTK currently
while the STC popup is shown, even though it does get it at the end.

See https://github.com/wxWidgets/wxWidgets/pull/1267
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
8634808a6c Make wxRadioButton focus test MSW-specific
This test doesn't need to, and actually does not, pass under wxGTK,
where a radio button can have focus without being selected, unlike in
wxMSW.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
e3caafabc3 Provide more information for failures involving FindFocus()
It is useful to know where the focus actually is when a test checking
that it's set to a particular window fails.
2019-07-18 17:45:20 +02:00
Vadim Zeitlin
1e0d47452c Replace CppUnit check macros with CATCH ones
No real changes, just use more natural CHECK() instead of
CPPUNIT_ASSERT() and CPPUNIT_ASSERT_EQUAL().
2019-07-16 02:26:57 +02:00
Vadim Zeitlin
2b71ce3664 Get rid of CppUnit boilerplate in wxWebView unit test
This not only cuts down on its size, but will make it simpler to skip
this test in the environments where web access is unavailable in the
upcoming commit.
2019-07-16 02:26:57 +02:00
Vadim Zeitlin
f8bdf123f2 Remove unnecessary header from the webview unit test
No real changes.
2019-07-16 02:26:57 +02:00
Vadim Zeitlin
13aa2a6721 Add unit tests for checking wxTE_PROCESS_ENTER handling
Verify that pressing Enter in a dialog activates its default button when
a text-like (i.e. wxTextCtrl or wxComboBox) has focus either if it
doesn't have wxTE_PROCESS_ENTER style or if it does, but its handler
skips the event, but not if the style is used and the event is handled.
2019-07-14 16:55:44 +02:00
Vadim Zeitlin
4a6f16cf15 Merge branch 'statictext-setlabel'
wxControl label-related fixes and improvements.

See https://github.com/wxWidgets/wxWidgets/pull/1364
2019-07-08 10:09:49 +02:00
Vadim Zeitlin
44634cbf90 Merge branch 'qt_tree_control' of https://github.com/GeoTeric/wxWidgets into qt-fixes
See https://github.com/wxWidgets/wxWidgets/pull/1225
2019-06-29 20:49:25 +02:00
Vadim Zeitlin
a6b8774636 Run label unit tests for ellipsized wxStaticText too
Check that the public methods still behave as expected even if the
displayed value is different because it is ellipsized.
2019-06-20 01:45:26 +02:00
Vadim Zeitlin
672847772d Fix an off-by-1 bug in wxControl::FindAccelIndex() after "&&"
This resulted in wrong letter being underlined in wxGenericStaticText
when the mnemonic occurred after "&&" (i.e. an actual ampersand) in the
label.

Add unit test which passes now, but would fail before on the last check.
2019-06-19 19:40:05 +02:00
Vadim Zeitlin
a93b1416a7 Add unit tests for wxControl::SetLabelMarkup() too
Check that "&" is interpreted correctly.
2019-06-19 19:18:48 +02:00
Vadim Zeitlin
21babfa2d0 Test a couple more cases in wxControl label unit test
Check that double ampersand also works correctly.
2019-06-19 19:13:00 +02:00
Vadim Zeitlin
0d35c3f36a Put all wxControl label unit tests inside a loop
There doesn't seem to be any reason to write some of them out
explicitly.

No real changes.
2019-06-19 19:08:38 +02:00
Vadim Zeitlin
5e98099699 Add unit test for wxGenericStaticText label
Run the same tests for it as for the native wxStaticText too.
2019-06-19 18:55:52 +02:00
Vadim Zeitlin
d22321b14f Rewrite wxControl label unit test without CppUnit macros
Also remove the macros used in the test to perform the same tests for
wxStaticText and wxCheckBox and use a helper function instead, making
the code more clear and extensible.

No real changes.
2019-06-19 18:51:40 +02:00
Vadim Zeitlin
b6477e0b9c Merge branch 'stcpopup'
Many usability and appearance improvements for autocompletion popups and
call tips in wxSTC.

See https://github.com/wxWidgets/wxWidgets/pull/1267
2019-04-21 02:03:32 +02:00
Vadim Zeitlin
8042648c73 Don't move wxTextCtrl insertion point if it doesn't really change
Resetting the insertion point position to 0 after calling
wxTextCtrl::SetValue() or ChangeValue() which didn't really change the
control contents was unexpected, as such calls are supposed to be
"optimized away", and this was indeed the case under wxMSW and wxOSX,
but not in wxGTK.

So change wxGTK to follow the other ports, add a unit test checking for
this behaviour and officially document it.

As a side effect, this ensures that the numeric validator classes don't
reset the insertion point position to 0 on every focus loss under wxGTK,
as happened before.
2019-03-21 02:44:45 +01:00
New Pagodi
7b0c7495e3 Add gui test for STC popup items
With wxSTC, popup autocompletion lists and call tips need to be able to
show their information and respond to mouse clicks, but should never
take focus from their parent STC. This test verifies that these popups
function in this manner.
2019-03-20 17:07:39 -05:00
Vadim Zeitlin
23ddf26571 Fix bug with wxRadioButton state changing unexpectedly in wxMSW
In wxMSW, a focused wxRadioButton is always checked, which meant that
checking a wxRadioButton while focus was not in the window containing it
and later giving the focus to that window could uncheck it by giving
focus to another wxRadioButton that had had it previously.

Fix this by adding WXSetPendingFocus() to wxMSW wxWindow and calling it
from wxRadioButton::SetValue() to ensure that when the focus is
regained, it goes to the newly checked radio button and not some other
one.

This replaces the previously used, for the same purpose, wxMSW-specific
wxTopLevelWindow::SetLastFocus(), so while this solution is not exactly
pretty, it's not worse than we had before, while being more generic.

Also add a unit test checking that things work correctly in the scenario
described above.

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

Closes #18341.
2019-03-18 18:29:19 +01:00
Graham Dawes
5d2663432e Delete child items in wxTreeCtrl::Delete under wxQT 2019-02-11 08:14:25 +00:00
Graham Dawes
c87e959a4a Add test for wxTreeCtrl::GetItemCount() 2019-02-05 19:49:36 +00:00
Vadim Zeitlin
ddc550105e Merge branch 'qt-radio-groups'
Fix radio button grouping in Qt.

See https://github.com/wxWidgets/wxWidgets/pull/1212
2019-02-05 03:03:10 +01:00
Vadim Zeitlin
9886c25645 Ensure that test notebook is destroyed after the end of its test
Don't let wxNotebook created in the recently added test for the events
generated when adding pages to it continue to live after the test end as
this breaks the subsequent tests using wxUIActionSimulator (but only
when using MinGW, for some reason).
2019-02-02 17:40:33 +01:00
Vadim Zeitlin
a913393147 Test that controls between radio buttons don't break grouping
Add a test checking that even not directly consecutive radio buttons are
still treated as being part of the same radio group.
2019-02-02 15:06:14 +01:00
Vadim Zeitlin
d403c9ecce Slightly simplify radio buttons creation in the unit test
No real changes, just add a temporary variable for the parent and use
more useful (and shorter) labels for the buttons.
2019-02-02 15:06:14 +01:00
Vadim Zeitlin
c22e81c7a1 Extend unit test for events generated by wxNotebook::AddPage()
In addition to checking that adding the first page doesn't generate any
events, check that adding another page later does generate them.
2019-01-28 19:01:17 +01:00
Vadim Zeitlin
6fdcfd8199 Add unit test for no events when adding first wxNotebook page
Adding the first page shouldn't generate any events even if the
selection does change (from -1 to 0) internally.
2019-01-28 18:21:32 +01:00
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