Commit Graph

439 Commits

Author SHA1 Message Date
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
Ilya Sinitsyn
a469d36783 Fix the test where wxGrid scrolling when selecting cells 2020-04-04 18:50:37 +02:00
Ilya Sinitsyn
f8015b13b1 Implement wxGrid selection blocks iterating interface 2020-04-04 18:50:37 +02:00
Ilya Sinitsyn
d1c8bba2b6 Fix SelectEmptyGrid wxGrid unit test
Use CATCH nested sections correctly.
2020-04-04 18:50:36 +02:00
Ilya Sinitsyn
acd72efbf1 Implement wxGridBlockCoords class
wxGridBlockCoords represents a location of a block of cells in the grid.
2020-04-04 18:50:36 +02:00
Vadim Zeitlin
28a9f50bc7 Merge branch 'grid-align-overflow'
Fix overflow in wxGrid cells with non-default alignment.

See https://github.com/wxWidgets/wxWidgets/pull/1775
2020-04-04 18:46:18 +02:00
Vadim Zeitlin
b4eb5438a4 Add a unit test for wxTextCtrl event generation on creation
Check that creating a wxTextCtrl doesn't generate any events to verify
that this problem doesn't exist in other ports, after fixing it in
wxGTK in 3e7e7dd24c (Avoid generating wxEVT_TEXT when wxTextCtrl initial
value is not empty, 2020-04-01).
2020-04-02 09:10:36 -07:00
Vadim Zeitlin
ca30169767 Restore overflowing for cells with non-default vertical alignment
Since the changes in a40acbb28e (Add CanOverflow function to
wxGridCellAttr, 2020-02-06), cells with non-default vertical alignment
didn't overflow any more, even if their horizontal alignment was
unchanged and still defaulted to left-aligned.

This was due to assuming that if the alignment of wxGridCellAttr itself
was different from wxALIGN_LEFT, it meant that it wasn't left-aligned,
which seems logical but is in fact false, as the alignment can also be
wxALIGN_INVALID, in which case the real alignment is taken from the
default grid attribute.

Fix this by using GetNonDefaultAlignment() to get the alignment value
effectively used and add a unit test, as well as an example in the
sample, showing that this now works correctly.
2020-03-31 19:32:47 +02:00
Vadim Zeitlin
5834bef2f7 Fix memory leaks in wxGrid unit tests
Use smart pointers to ensure that various objects are released, as they
have to be.
2020-03-31 19:32:47 +02:00
Vadim Zeitlin
d60f5484a9 Turn off a wxGrid sub-test on AppVeyor
Somehow emulating the column resizing doesn't work there, even though it
works perfectly reliably locally. This might be due to some display
optimization options used in this environment, but it's difficult to
debug what's going on there, so just disable the test when running under
AppVeyor for now.
2020-03-11 22:00:11 +01:00
Vadim Zeitlin
8b2237cd2d Make row/column drag-resizing in wxGrid "live"
Update the column width immediately, as it's being dragged, instead of
drawing a temporary line showing the new column boundary using wxINVERT.

This results in better user experience, as it the effect of changing the
column width can be immediately seen (especially important for non-left
aligned columns or columns using ellipsizition) and, equally if not more
importantly, fixes wxGrid drag-resize not showing any visible UI at all
with wxGTK3 and wxOSX where wxINVERT is not implemented.
2020-03-11 22:00:01 +01:00
Vadim Zeitlin
702ba58590 Replace legacy CppUnit assertions with CATCH ones in grid test
Get rid of compatibility macros and use CATCH macros directly.

Also remove the now unnecessary casts.
2020-03-11 18:42:14 +01:00
Vadim Zeitlin
29d890867c Rewrite grid unit tests to use individual test cases
Instead of using a single test case, with multiple sections, generated
by CppUnit compatibility macros, use multiple independent test cases.

This makes it more convenient to run individual tests, simplifies the
code and allows to get rid of ugly "pseudo tests".
2020-03-11 18:41:16 +01:00
Vadim Zeitlin
f21c7f2d49 Add a test for C++ comments in code passed to RunScript()
This used to be broken, check that it does work now.
2020-02-05 15:55:50 +01:00
Vadim Zeitlin
a26e81ccb1 Remove test for \v escaping in wxWebView::RunScript()
This escape character doesn't seem to be handled by IE in the default
emulation mode and it's not worth complicating the test code just to
test for it, so simply remove it from the test.
2020-02-05 15:40:27 +01:00
Ilya Sinitsyn
217349d772 Test wxGrid RefreshBlock function when a grid is empty
SelectCol and SelectRow should not fail an assertion if a grid has no
rows or columns.
2020-02-05 03:32:31 +01:00
Ilya Sinitsyn
7fa9416fb4 Test wxGrid cells selection using End key 2020-02-01 01:53:59 +01:00
Ilya Sinitsyn
677b9d21ea Test moving the grid cursor using End key for wxGrid 2020-02-01 01:53:59 +01:00
Ilya Sinitsyn
bf5be68510 Test wxGrid scrolling when selecting cells. 2020-02-01 01:53:59 +01:00
Lauri Nurmi
09e0b3927b Fix building tests when configured with --disable-log
Add missing wxUSE_LOG checks to wxTextCtrl test and disable wxLog test
entirely when wxUSE_LOG==0.

Closes https://github.com/wxWidgets/wxWidgets/pull/1703
2020-01-10 16:38:41 +01:00
Vadim Zeitlin
811be7ced7 Fix wxGridCellAttr::GetNonDefaultAlignment() for invalid inputs
The recent change of 19844d27ac fixed this
function for valid values of input/output parameters on input, but broke
it if the parameters had invalid value: in this case, we still need to
fill them even if this attribute doesn't have any specific alignment of
its own.

Account for this case too now, explain the logic of this function in the
comments inside it and extend the unit test to check for this case too.

Now the function should really conform to its documented (and expected,
including by the existing code in various grid renderers) behaviour.

Closes https://github.com/wxWidgets/wxWidgets/pull/1665
2019-12-03 02:26:49 +01:00
Igor Korot
68de1b2acf Fix initial value returned from wxRichTextCtrl::IsModified()
A just created control shouldn't be considered modified, so reset its
modified state in Create().

And add a unit test checking that IsModified() really behaves as
expected.

Closes https://github.com/wxWidgets/wxWidgets/pull/1652
2019-11-17 17:04:15 +01:00
Vadim Zeitlin
19844d27ac Fix default attribute wxGridCellAttr::GetNonDefaultAlignment()
This function is not supposed to overwrite the given alignment values
unless the alignment is specifically set for the given cell, but it
always overwrote them when called on m_defaultCellAttr, i.e. the
attribute used by the cells that don't have any special attribute.

This meant that custom attributes had to be set (or, more efficiently, a
custom attribute provider returning non-null attributes for all cells
had to be used) previously just to make the right alignment used by
default by number or date renderers work.

Fix this by ignoring the values set in the default attribute in this
function.

Also add a unit test (which required adding a special helper class just
to allow testing wxGrid::GetCellAttr() used by the renderers) that used
to fail but passes now.
2019-11-04 00:35:32 +01:00
Vadim Zeitlin
4df94771da Merge branch 'dataview_cocoa' of https://github.com/thesiv/wxWidgets
Ensure that last wxDataViewCtrl columns is always expanded to fit the
control width and a unit test checking for the scenario in which this
wasn't the case before, but is now.

See https://github.com/wxWidgets/wxWidgets/pull/1313
2019-11-01 00:49:29 +01:00
Vadim Zeitlin
6530323f31 Add unit test for wxWindow::IsThisEnabled()
Check that the child IsEnabled() returns false if its parent is
disabled, but its IsThisEnabled() still returns true in this case.
2019-10-27 01:31:21 +02:00
Vadim Zeitlin
ad6799f249 Merge branch 'grid-uitests-gtk'
Fixes to wxUIActionSimulator allowing the tests using it to work for
wxGrid in wxGTK.

And some improvements and bug fixes to wxGrid itself.

Closes https://github.com/wxWidgets/wxWidgets/pull/1609
2019-10-21 21:12:01 +02:00
Vadim Zeitlin
16619c5e77 Use DIPs for the margins around text in wxGrid columns
Improve the appearance on high DPI displays where the margins were
previously too small under MSW.
2019-10-19 18:31:50 +02:00
Vadim Zeitlin
f29b6564b1 Really fix recent regression in grid content autosizing
Fix autosizing broken in 3c72396a36 and
not fully fixed by f7e335c031.

Simplify the code to make it more obviously correct, by separating the
computation of the extent suitable for the label and determining the
size to use taking into account the extents of both the column data and
the its column.

Also add the unit test checking that auto-sizing works correctly in all
the different cases.

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

Co-Authored-By: Ilya Sinitsyn <the_siv@mail.ru>
2019-10-19 18:28:03 +02:00
Vadim Zeitlin
8064d9420f Fix the just added wxDataViewCtrl::DeleteAllItems() test
Using GetTopItem() was wrong, we actually need to use the invalid item,
which corresponds to the "virtual root" of wxDataViewTreeStore.
2019-10-17 22:26:37 +02:00
Vadim Zeitlin
57d2be63fc Wait until grid is fully shown in the unit test
Without this, the mouse clicks sometimes are received by the parent
frame and not the grid itself.
2019-10-17 22:04:20 +02:00
Vadim Zeitlin
7a980c455e Fix crash in wxDataViewTreeCtrl::DeleteAllItems() in wxGTK
Restore the checks for the model stamp, reverting the changes of
18594afe76: we still need to ignore the
calls to at least iter_children() and iter_nth_child() model methods
that can be called from inside gtk_tree_view_set_model() when we reset
the model, as running these methods crashes when trying to use the
pointers to already deleted items.

For consistency and robustness, add checks for the model stamp to all
the methods and not just those two, just in case other ones end up being
called later in some way.

Also add a unit test checking that DeleteAllItems() doesn't crash and
does delete all items.

Closes #18533.
2019-10-17 14:57:04 +02:00
Vadim Zeitlin
ed783b95f8 Add a hack to make wxGrid UI unit test pass
This is an ugly workaround for a mysterious problem occurring with the
simulated "Enter" presses under GTK, but it's worth it, as it allows all
grid tests, including the ones using wxUIActionSimulator, to pass now
under wxGTK2 (a couple of tests still fail under wxGTK3).
2019-10-15 03:18:28 +02:00
Vadim Zeitlin
ddd7ef45d0 Use CHECK() instead of CPPUNIT_ASSERT_EQUAL(), i.e. REQUIRE()
Perform all the checks, even if one (or more) of them fails.
2019-10-13 01:56:13 +02:00
Vadim Zeitlin
97b3e6e50b Check that the grid cell has the expected value in the test
In addition to checking that we get the expected events, also verify
that editing the cell actually worked.
2019-10-13 01:56:13 +02:00