Commit Graph

422 Commits

Author SHA1 Message Date
Vadim Zeitlin
c24dddc462 Return empty rectangle from GetItemRect() for collapsed items
GetItemByRow() returned a valid row even for an item which was collapsed
which is clearly inappropriate for its use in GetItemRect(), which is
supposed return an invalid rectangle if the item is not visible. It also
might be inappropriate in other cases, but this is not totally clear and
it seems like it is supposed to return a valid row even for collapsed
items at least sometimes, so just make its behaviour conditional by
adding a new flags parameter to GetItemRect() and to Walker() helper
used by it itself, so that it could skip over collapsed items.

Update the test to show that it succeeds now even when the item is
present in the tree, as it only passed before because the item had never
been expanded at all, and so wasn't really present in the tree
structure and the updated test would have failed without the changes to
the code in this commit.
2020-10-19 01:31:14 +02:00
Vadim Zeitlin
fa1b1e700b Initialize variable to avoid a warning in wxCaret unit test
Always initialize the caret pointer in the test added in 88f808e303 (Add
a unit test for wxCaret::Create(), 2020-10-01) to avoid a MSVS warning.
2020-10-17 14:46:41 +02:00
Vadim Zeitlin
98ea7b49c7 Fix harmless signed/unsigned comparison warning in a test
Add a cast to avoid a warning recently added in 1f40a7e4e3 (Document
that wxDataViewCtrl::SetSelections() skips invalid items, 2020-10-12).
2020-10-17 14:45:41 +02:00
Vadim Zeitlin
b6cff426ce Merge branch 'remove-bcc-support'
Remove support for Borland C++ compiler, it wasn't tested since a long
time and probably didn't work anyhow and there was no interest in
keeping support for it since many years.

See https://github.com/wxWidgets/wxWidgets/pull/2087
2020-10-16 01:58:13 +02:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Vadim Zeitlin
1f40a7e4e3 Document that wxDataViewCtrl::SetSelections() skips invalid items
Also add the unit test checking for this.
2020-10-12 18:32:11 +02:00
ali kettab
fedc80eee3 Improve selection and focus events generation in wxGenericLisCtrl
Avoid sending spurious wxEVT_LIST_ITEM_{FOCUSED, SELECTED, DESELECTED}
events and make the generic version consistent with the behaviour of the
native wxMSW one.

Also add/extend the tests and slightly improve the sample.

Closes https://github.com/wxWidgets/wxWidgets/pull/2044
2020-10-10 19:13:52 +02:00
PB
952e5f32cd Fix generation of extraneous wxEVT_SLIDER events in wxMSW
Don't send the event when it's redundant, i.e. doesn't really notify
about the change in the slider value.

Also add a test case for wxEVT_SLIDER and show these events in the
widgets sample.

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

Closes #18929.
2020-10-10 18:21:27 +02:00
Vadim Zeitlin
123044c68c Merge branch 'fix-caret-default'
Fix using default-constructed wxCaret.

See https://github.com/wxWidgets/wxWidgets/pull/2007
2020-10-01 02:29:43 +02:00
Vadim Zeitlin
88f808e303 Add a unit test for wxCaret::Create()
Verify that constructing wxCaret using its default ctor and Create()
works too, now that it does -- previously it uses to result in a GTK
warning and a crash in wxGTK.
2020-10-01 02:28:42 +02:00
oneeyeman1
61ef150044 Implement GetStringSelection() in generic wxBitmapComboBox
Also update the test to avoid assuming that wxBitmapComboBox inherits
from wxComboBox, which now allows it to build (and pass) on all
platforms.

Closes https://github.com/wxWidgets/wxWidgets/pull/2057
2020-10-01 02:19:12 +02:00
Vadim Zeitlin
1f1a9d52d6 Merge branch 'expose-radiogroup'
Add public functions for navigating in radio button groups.

Also introduce wxRadioButtonBase defining wxRadioButton API for all
ports.

See https://github.com/wxWidgets/wxWidgets/pull/2052
2020-09-24 00:11:15 +02:00
Vadim Zeitlin
b84bc8e26a Add unit tests for radio button group navigation functions
Extend the existing "group" and "single" tests to check these functions
too.

This at least verifies that these functions can be used.
2020-09-21 15:54:42 +02:00
Vadim Zeitlin
46a21e5aba Use wxScopedPtr<> instead of manual delete in wxRadioButton test
Make the test code safer and ensure that no controls created here remain
alive after the test end.
2020-09-21 15:18:22 +02:00
Vadim Zeitlin
fceaa907a8 Remove CppUnit boilerplate from wxRadioButton unit test
Replace CppUnit test case class with a simple fixture and use CHECK()
instead of CPPUNIT_ASSERT_XXX().

No real changes.
2020-09-21 15:15:37 +02:00
Vadim Zeitlin
50fc4eb1f3 Work around spurious Travis CI failures in WebView selection test
We can't rely on HasSelection() returning true immediately after calling
SelectAll() because this operation (as almost all the other ones) is
asynchronous with WebKit and might not have completed yet when we check
for the selection existence.

There doesn't seem to be any way to wait for its completion, so just
poll the selection state for some time before deciding that it hasn't
been updated. In practice, just a couple of ms is enough on a normal
machine, but wait up to 50ms on Travis just to be on the safe side.

Note that to reliably reproduce the problem locally it's enough to run
"taskset 1 ./test_gui -c Selection WebView", i.e. pin both the main and
WebKit processes to the same CPU.
2020-09-20 23:19:09 +02:00
Vadim Zeitlin
0a053580c0 Use wxEVT_GRID_RANGE_SELECTED instead of deprecated SELECT
Fix building the tests with WXWIN_COMPATIBILITY_3_0 disabled.
2020-09-01 15:04:39 +02:00
Andreas Falkenhahn
a59901f8f1 Fix bug in CanUndo() returning true after wxTextCtrl creation
For wxMSW text controls with wxTE_RICH2 style, calling SetFont() counts
as an undoable operation, resulting in CanUndo() returning true even if
no "real" changes have been made yet.

Fix this by resetting the undo stack after creating the control using
ITextDocument::Undo().

Unfortunately this interface is not available in MinGW-32, so this fix
can't be used with it.

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

Closes #17524.
2020-08-25 18:10:20 +02:00
Vadim Zeitlin
ff3cb34d18 Add a unit test for using bitmaps with image and empty label
This used to be broken, see #18898, and now that it is fixed by
5a70051c7e (Avoid assertion failure in wxButton with bitmap and empty
label, see #18898, 2020-08-21) add a unit test so that it stays fixed.
2020-08-21 20:21:17 -07:00
Vadim Zeitlin
bb93682a87 Improve wxGrid selection test slightly
Check that deselecting a row leaves the cells outside of this row
selected.

This requires passing "true" to the previous call of SelectRow() to
prevent it from clearing the existing selection, as it does by default.
2020-08-14 12:41:10 +02:00
Vadim Zeitlin
4475df8264 Add unit tests for wxGrid::Deselect{Row,Col}()
These functions got broken by the changes of cdf3187fe5 (Improve rows,
columns and cells deselection in wxGrid, 2020-03-26), but this went
unnoticed because they were not covered by the unit tests, so add the
tests for them to prevent this from happening again in the future.
2020-08-14 12:36:46 +02:00
ali kettab
2256dac384 Enable wxSlider "Thumb" unit test under GTK too
This was disabled, but only didn't work because wxSlider used tiny size
in wxGTK by default previously. After correcting this in aa2d159e8c (Use
more reasonable length for wxSlider in wxGTK by default, 2020-08-04),
the unit test passes with wxGTK too and can be reenabled.

Closes https://github.com/wxWidgets/wxWidgets/pull/1992
2020-08-05 22:46:04 +02:00
Vadim Zeitlin
f19b3f6586 Merge branch 'test-test' of https://github.com/AliKet/wxWidgets
Minor cleanups for the tests.

See https://github.com/wxWidgets/wxWidgets/pull/1998
2020-08-03 00:26:43 +02:00
ali kettab
30e5ff87a4 the assertion was mistakenly placed in the wrong place 2020-07-25 18:09:55 +01:00
ali kettab
b1c83920b5 fix typo 2020-07-25 16:09:50 +01:00
ali kettab
ad68515d52 cleanup a wxTextCtrl leftover from SpinCtrlTest 2020-07-25 14:59:31 +01:00
ali kettab
852f817291 Get rid of redundant call to wxDELETE (no real change) 2020-07-25 12:34:25 +01:00
ali kettab
247ee328b3 remove workaround from BitmapComboBoxTestCase 2020-07-25 12:14:42 +01:00
Scott Talbert
957842946e Skip tests for functions unsupported on WebKit2 2020-07-23 21:49:14 -04:00
Artur Wieczorek
3feea201da Add tests of setting wxSpinCtrl base and range 2020-07-12 19:58:30 +02:00
Artur Wieczorek
a4928c0fde Use Catch in wxSpinCtrl unit tests
Use Catch instead of CppUnit for unit tests of wxSpinCtrl.
2020-07-12 19:58:30 +02:00
Vadim Zeitlin
de6b4e4095 Use LocaleSetter class in wxTextCtrl test case
Replace manual calls to setlocale() with the existing helper class.

This makes the code slightly simpler and avoids -Wnoexcept-type warnings
due to using setlocale as template argument as a welcome side effect.
2020-07-06 12:32:38 +02:00
Vadim Zeitlin
036ab992d5 Merge branch 'list-deselect-event'
Consistently send DESELECTED events from virtual wxListCtrl.

See https://github.com/wxWidgets/wxWidgets/pull/1857
2020-06-13 22:50:55 +02:00
Vadim Zeitlin
6f0a2b66b4 Remove hard TAB from the recently added test
No real changes.
2020-06-13 22:50:36 +02:00
Lauri Nurmi
fa16bc05da Test DESELECTED events in both virtual and non-virtual listctrls. 2020-05-28 10:51:58 +03:00
Vadim Zeitlin
3307000baa Add wxGrid::GetSelectedRowBlocks() and GetSelectedColBlocks()
These functions are much simpler to use in the application code using
wxGrid in row- or column-only selection mode than GetSelectedBlocks()
itself because they take care of deduplicating, ordering and squashing
together the adjacent ranges, so that the application can use their
results directly, unlike with GetSelectedBlocks().
2020-05-27 03:19:34 +02:00
Vadim Zeitlin
92b6a55fd6 Fix returning duplicates from Get{Row,Col}Selection()
The "unique" rows/columns arrays used in the implementation of these
functions were not unique at all, as we happily added duplicates of the
existing items into them. Fix this by checking that a row/column is not
already present before adding it.

Add a (previously failing) unit test checking that this works correctly
with overlapping selected blocks.
2020-05-26 16:32:05 +02:00
Lauri Nurmi
0b54f944bc Fix compilation of wxGrid unit tests with VC10 (VS2010)
VC10 does not support range-based for-loops, they were only introduced in
VC11 (VS2012): https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/hh409293(v=vs.110)

Closes https://github.com/wxWidgets/wxWidgets/pull/1863
2020-05-22 23:17:05 +02:00
Artur Wieczorek
edc553870f Fix displaying wxSpinCtrlDouble values with default precision
For the sake of consistency with native wxGTK implementation,
spin control value should be displayed with fixed precision.

See #17085.
2020-05-18 20:39:05 +02:00
Artur Wieczorek
3ef2fc3560 Add test of default wxSpinCtrlDouble precision 2020-05-18 18:55:22 +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
30079ad0e6 Fix building GUI tests with MSVC
This was broken by da48b9e45d (adding an iOS build to travis (#1847),
2020-05-08), as we can't use preprocessor directives inside macro
arguments with MSVC (at least with its traditional preprocessor).

Use a helper macro to make this work again.
2020-05-10 02:15:52 +02:00
Stefan Csomor
da48b9e45d
adding an iOS build to travis (#1847)
* fixing compilation of tests that cannot build

bracket code with the corresponding wxUSE… macros

* adding directive for iOS

* adding a switch for skipping the run - not the build of tests

right now I don’t know yet, how to run the test binary in the iOS simulator, but building it is still a good test in itself

* adding skipping of tests

* increasing minimum deployment to get proper c++17 support

* using --disable-sys-libs, restoring other targets

even when the zlib in -isysroot is used, due to deployment on lower iOS versions inflateValidate may not be available and crash. The guards are evaluated using macros from the zlib from the SDK, not from the lowest version supported.
2020-05-08 08:01:56 +02:00
Vadim Zeitlin
e5d03323f9 Rename wxGridBlockCoords::ContainsCell/Block() to just Contains()
These methods do the same thing, so it seems better to use the same name
for them.

This is not really a backwards-incompatible change, as these methods
were just added in the parent commit, so nobody is using them yet.
2020-04-15 18:37:06 +02:00
Vadim Zeitlin
bc3c6fea70 Fix Shift-Ctrl-arrows handling
Extending the selection with Ctrl-arrows is different from all the other
cases, as we need to combine both the selection anchor and the current
cell coordinates when doing it.

This means that we can't reuse the same PrepareForSelectionExpansion()
helper for this case, so this function is not useful finally and this
commit removes it entirely. It also replaces GetCurrentBlockCornerRow()
and GetCurrentBlockCornerCol() functions with GetExtensionAnchor() which
combines both of them.

Finally, it adds wxGridDirectionOperations::TryToAdvance() helper to
avoid repeating the IsAtBoundary() check which was previously part of
PrepareForSelectionExpansion() in multiple places.

And because the "extending" and normal parts of DoMoveCursorByBlock()
are so different now, it also factors out AdvanceByBlock() helper which
can be used to keep these parts well separate from each other instead of
intermixing them together.

With all these preparatory changes, it's finally possible to implement
the "extending selection by block" logic relatively easily, with the
bulk of this branch actually taken by comments explaining why do we have
to do what we do.

Add unit tests verifying that the functions used by Shift-Ctrl-arrow
work as expected.
2020-04-13 00:49:22 +02:00
Vadim Zeitlin
30eaa28de5 Rename wxGrid::GetSelectionRange() to GetSelectedBlocks()
This seems to be more consistent with the existing functions and doesn't
create ambiguity with a grid range.

Also rename wxGridSelectionRange to just wxGridBlocks as, in principle,
this class could be used for iterating over any blocks, not just the
selected ones.

No changes in functionality, this is just a renaming.
2020-04-12 02:38:37 +02:00
Vadim Zeitlin
d031ef154a Simplify wxGrid::SetSelectionMode() selection updating logic
Don't try to extend the existing selected blocks to rows/columns, this
contradicts the documented behaviour which is to discard the selected
blocks that become invalid in the new mode.

Do handle switching to wxGridSelectRowsOrColumns mode, as there doesn't
seem to be any reason not to.

Update the tests to check for the expected selection update behaviour.
2020-04-05 02:11:04 +02:00
Vadim Zeitlin
791a9e68ae Rename and simplify wxGridBlockCoords::ContainsBlock()
Change the return type of this function to a simple and clear bool
instead of 3-valued int requiring a special explanation. This is simpler
and not any less efficient as checking for whether one block contains
another or the other one contains this one are separate operations
anyhow.

Rename the function to a more grammatically correct name.

Also move it inline as it's now trivial enough for this to be worth it.
2020-04-05 01:37:56 +02:00
Vadim Zeitlin
a5952ee087 Rename wxGridBlockCoords::ContainsCell() and move it inline
Make the function name more grammatically correct.

No real changes.
2020-04-04 19:45:19 +02:00
Vadim Zeitlin
0a5a904d8d Simplify wxGridSelectionRange to provide only iterators
This class was a strange hybrid of a container/view/range and iterator,
as it both provided begin()/end() container-like methods and
iterator-like methods for dereferencing/advancing.

Simplify this by removing the latter part and making this class really
just a range, with its own iterator class in order to avoid leaking the
exact type of the iterator used in the API.

Note that while it's now completely trivial, it is still useful as it
isolates the application code from the vector used to store the selected
blocks currently and will allow to change internal representation in the
future without breaking the existing code.
2020-04-04 19:37:23 +02:00