Commit Graph

2255 Commits

Author SHA1 Message Date
Vadim Zeitlin
a3f61f973d Merge branches 'travis-warning-errors' and 'travis-cleanup'
Fail CI builds if any warnings (other than those given by an explicit
preprocessor #warning directive) are encountered.

Also cleanup Travis config a bit.

See https://github.com/wxWidgets/wxWidgets/pull/1933,
    https://github.com/wxWidgets/wxWidgets/pull/1935
2020-07-07 12:45:58 +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
957183ef47 Associate the window with the sizer in wxSizer::Replace()
If wxSizerItem passed to Replace() contains a window, the window must be
associated with the sizer to ensure that it is uncoupled from it when it
is destroyed.

Add a simple test which resulted in a use-after-free before but passes
now.
2020-07-05 23:19:36 +02:00
Vadim Zeitlin
31632c4fbb Fix memory leaks in BoxSizer::IncompatibleFlags test case
The sizer item allocated by wxSizer::Add() was leaked if an exception
was thrown due to the use of invalid flags, resulting in tons of memory
leak reports from the leak sanitizer.

Fix them by using wxScopedPtr<> for this item and releasing it only if
adding the item to the sizer (unexpectedly) did not throw.

No real changes.
2020-07-04 15:53:36 +02:00
Fabian Cenedese
a571a13d44 Fix bug in wxFileName::Normalize() with leading ".."
Don't discard initial ".." when there is more than one such component in
the beginning of the path.

Closes #18800.
2020-06-30 23:00:06 +02:00
Vadim Zeitlin
dc9040cc89 Merge branch 'grid-autosize'
Optimize wxGrid::AutoSizeColumns() for big grids.

This includes an optimization of wxDC::GetTextExtent() at the price of
slightly reduced precision in wxMSW.

See https://github.com/wxWidgets/wxWidgets/pull/1893
2020-06-16 20:37:57 +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
Vadim Zeitlin
bfeae1922d Minor optimizations in GetMultiLineTextExtent()
Handle the case of a single line string specially, it's faster to do
this than use slow loop over all characters.

Also avoid constructing the string with the characters to measure one by
one and do it all at once instead.

Add a possibility to benchmark GetMultiLineTextExtent() rather than
GetTextExtent() in the graphics benchmark.
2020-06-10 23:41:24 +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
ali kettab
a3e264e8a3 Make wxSetInputFocusToXWindow a member instead of free function
Also add a couple of workarounds for problems when using Xvfb.

See https://github.com/wxWidgets/wxWidgets/pull/1845
2020-05-20 00:02:40 +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
Vadim Zeitlin
9df975f2a9 Merge branch 'gcc10-cxx20'
Compilation fixes for g++10 in C++20 mode.

See https://github.com/wxWidgets/wxWidgets/pull/1851
2020-05-14 23:50:29 +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
499252ace8 Fix unit tests compilation in C++20
There is no more overload of std::ostream::operator<<() for wchar_t in
C++20, i.e. it is explicitly deleted, so we need to define some other
way of printing wchar_t out from Catch macros.

Do it by specializing Catch::StringMaker<> for it and outputting it
either as a (7 bit) ASCII character, if this is what it is, or as a
Unicode character code otherwise, as this will probably be more useful
in case of a test failure.
2020-05-10 23:05:41 +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
Vadim Zeitlin
3e724ffa96 Merge branch 'memoryfs-iter' into window-id
Fix bug in wxMemoryFSHandler iteration.

See https://github.com/wxWidgets/wxWidgets/pull/1833
2020-05-09 23:37:14 +02:00
Vadim Zeitlin
3ab187f75f Add a test for "%e" to wxDateTime::ParseFormat()
See https://github.com/wxWidgets/wxWidgets/pull/1842
2020-05-09 23:23:31 +02:00
Vadim Zeitlin
2cf0537722 Correct the test for ParseFormat() with fall back date
This was added back in b5f85206a9 (fix ParseFormat("%d") to set the date
it finds (#10002), 2008-09-26), but the test didn't do what the comment
said and didn't use the default date object it added.

Fix this now to finally do what was intended all these years ago.
2020-05-09 23:22:13 +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
f5001e728c Rebake with bakefile 0.2.12
No real changes, just synchronize with the bakefile release used now.
2020-05-02 17:02:36 +02:00
Vadim Zeitlin
37485130cc Fix harmless warning about multiline comment in fuzzer runner
Don't embed backslash in multiline C++ comment.
2020-05-02 03:38:28 +02:00
Vadim Zeitlin
c098363e0d Add test for wxMemoryFSHandler bug fixed in the parent commit
Executing this test before the changes of the previous commit would
result in test failure/crash/Valgrind errors. Now it passes.

See #18744.
2020-05-01 18:57:54 +02:00
Vadim Zeitlin
a973d02c9f Get rid of CppUnit cruft in wxFileSystem test case
Use CATCH macros directly and define separate test cases instead of
using a useless FileSystemTestCase class.

Also add INFO() macros to provide information about the context in case
of test failure.

No real changes.
2020-05-01 15:06:05 +02:00
Paul Cornett
896512c732 Change fractional point size from float to double
There doesn't seem to be any compelling reason to use float. Using double
is simpler, and avoids otherwise unnecessary float<->double conversions.
2020-04-21 09:00:04 -07:00
Vadim Zeitlin
6fcf285136 Merge branch 'more-travis'
Test Linux on ARM, PPC64 and S390 architectures on Travis CI too.

See https://github.com/wxWidgets/wxWidgets/pull/1783
2020-04-19 22:31:10 +02:00
Vadim Zeitlin
f1714b3d69 Merge branches 'fix-autoconf-libdir-order' and 'autoconf-avoid-libinotify-freebsd'
Fix issues with FreeBSD build: use just built, instead of already
installed, libraries (this one is not really FreeBSD specific) and use
kqueue even if sys/inotify.h is available but inotify itself isn't (at
least without linking with an extra library).

Closes #18729.
2020-04-16 15:02:12 +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
a5a7641616 Merge branch 'grid-selection-refactoring'
Completely overhauled selection handling in wxGrid.

Make various ways of extending selection (using Shift-arrow keys,
Ctrl-Shift-arrows, Shift-click etc) work as expected from the user point
of view instead of producing various bizarre results. Also improve
row/column header click selection as well as Ctrl/Shift-Space handling.

Internally, store selection as just a vector of blocks, independently of
the selection mode, and provide a simple API for iterating over it which
remains usable even with selections containing millions of cells (as
long as they're still composed of only a few blocks, which is the case
in practice).

Add more tests and add display of the current selection to the sample.

See https://github.com/wxWidgets/wxWidgets/pull/1772
2020-04-15 18:10:08 +02:00
Vadim Zeitlin
47d881b683 Fix order of -L options in autoconf makefiles
Put linker flags determined by configure after -L$(LIBDIRNAME) option
pointing to the directory containing the libraries being built, to
ensure that we link with these libraries rather than any wx libraries
globally installed in the system, as could be the case since the changes
of ec091c9f2b (Don't override CFLAGS etc in configure-generated
makefile, 2020-02-02).

See #18729.
2020-04-15 02:33:53 +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
287c1b1d11 Merge branch 'noexcept-event-tables'
Allow using noexcept handlers in event tables.

See https://github.com/wxWidgets/wxWidgets/pull/1788
2020-04-12 16:41:55 +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
c3810da549 Allow using noexcept methods with event tables macros
Explicitly remove noexcept before static-casting the member function
pointer to the base class pointer type to avoid compilation error with
C++17.

Add a test checking that this does work now.

Closes #18721.
2020-04-09 22:36:30 +02:00
Maarten Bent
7da632b438 Fix building test.cpp with c++17
uncaught_exception() has been replaced with uncaught_exceptions().
2020-04-08 22:13:53 +02:00
Vadim Zeitlin
17c7469af3 Switch to manual method of LXC "detection"
Just define wxLXC environment variable for the builds using LXC on
Travis.
2020-04-07 17:15:04 +02:00
Vadim Zeitlin
82cfdd07c2 Disable tests of /proc/cpuinfo in LXC containers
It seems that we can't access /proc files when running inside such
containers, so don't try to do it.
2020-04-07 14:30:01 +02:00
Vadim Zeitlin
a776a9112e Use /proc/cpuinfo instead of /proc/diskstats in Linux file tests
The file /proc/diskstats doesn't seem to contain anything on some Travis
builds, so try using /proc/cpuinfo instead.
2020-04-07 13:41:21 +02:00
Scott Talbert
2005e50b27 Fix tests when run on s390x arch
Don't assume "mem" is always present in /sys/power/state, but hopefully
one of "mem" and "disk" is.
2020-04-07 13:39:34 +02:00
Vadim Zeitlin
b714a3614b Update comments to remove mentions of 4KiB for /sys files
The actual size is the page size, so update the comments to match the
changes to the code in the previous commit.
2020-04-07 13:38:34 +02:00
Scott Talbert
b2b1b21bf2 Fix tests when run on ppc64le arch
Don't assume that files in /sys are 4KiB in size, their actual size is
equal to the kernel page size which varies depending on the architecture
and kernel build options.
2020-04-07 13:37:07 +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