Commit Graph

2786 Commits

Author SHA1 Message Date
Vadim Zeitlin
19e3a47d98 Update version to 3.1.7 and rebake the makefiles
Make it possible to distinguish the latest master from 3.1.6 before
making any changes.

Closes #22282.
2022-04-07 17:40:13 +02:00
PB
295237882b Fix building benchmarks with gcc
GCC failed to compile bench.cpp due to DBL_MAX not being declared.

Fix this by including float.h.

Closes #22262.
2022-04-03 20:12:44 +02:00
Vadim Zeitlin
46f81624c1 Add tests for wxLocaleIdent::FromTag() and FindLanguageInfo()
Add at least trivial tests for this function and FindLanguageInfo()
overload using it to confirm that it works minimally correctly.

See #22252.
2022-04-02 16:45:20 +02:00
Vadim Zeitlin
9501349b14 Disable wxWebRequest tests using badssl.com
There are DNS problems with resolving it that make the tests fail, see
https://github.com/chromium/badssl.com/issues/500

Require WX_TEST_WEBREQUEST_URL_SELF_SIGNED to be set to the URL to test
instead of hard-coding https://self-signed.badssl.com and don't set this
variable for now to let the tests pass.
2022-04-01 15:27:24 +02:00
Vadim Zeitlin
0138fcfa32 Use function, not class, in GetTextExtent() unit tests
Simplify the code by more or less reverting c7619cf139 (Replace a
template function with template class to fix VC6 build., 2012-11-12)
which shouldn't be necessary any longer as VC6 is not supported since a
long time.

No real changes.

This commit is best viewed ignoring whitespace-only changes.
2022-03-29 14:11:14 +01:00
Vadim Zeitlin
b390c487f7 Fix wxMemoryDC::SetFont(wxNullFont) broken by recent changes
Fix crash in this function introduced by 9e5c8a8027 (Respect bitmap
content scale factor in wxMSW wxMemoryDC, 2022-03-26).

Also add a unit test ensuring that this doesn't get broken again under
MSW, which seems to be the only place where it works.

Closes #22240.
2022-03-29 14:10:34 +01:00
Vadim Zeitlin
4979457f4d Add wxMemoryDC::GetTextExtent() unit test
Test this wxDC kind too.
2022-03-29 13:45:40 +01:00
Vadim Zeitlin
a0d1379a57 Split wxDC::GetTextExtent() test case in 3 pieces
No real changes, just don't test all the different wxDC kinds in one
test, when they are completely separate.
2022-03-29 13:43:21 +01:00
utelle
6d6e5cde21 Enhance wxUILocale and wxLocaleIdent
Many improvements and fixes to wxUILocale:

- Add wxUILocale method for retrieving wxLocaleIdent identifier,
  localized names, layout direction.
- Add wxLocaleIdent attributes, getter, and setter for
  platform-dependent tags under Windows: extension, sort order.
- Modify method wxLocaleIdent::FromTag to support not only BCP 47-like
  tags, but also platform-dependent syntax.
- Modify method wxLocaleIdent::GetTag to allow specifying the tag type.
- Update internat sample to better show using wxUILocale.
- Update German and French message catalogs for internat sample (German
  fully translated, French msgIds only).
- Introduced wxUILocaleImplStdC under Windows, because locale "en-US" is
  not equivalent to the C locale.
- Adjust wxLocale class to restore previous wxUILocale in the
  destructor.
- Implement wxLocale::GetInfo method through wxUILocale methods.
- Removed LCID dependency in wxLocale.
- Move the implementation of some static wxUILocale methods from
  intl.cpp to uilocale.cpp.

Co-authored-by: Vadim Zeitlin <vadim@wxwidgets.org>

Closes #2615.
2022-03-28 01:11:40 +02:00
Vadim Zeitlin
f280bcdb58 Improve error reporting in wxDateTime unit tests
Simply use INFO() to give all the information we want to see in case of
failure once instead of doing it in multiple WX_ASSERT_MESSAGE() in a
more ugly way with extra parentheses.

Also use FAIL_CHECK() to keep running the test after the first failure.
2022-03-28 00:56:19 +02:00
Gerhard Gruber
9dc7248b1d Add conversion to signed/unsigned int to wxString
Add wxString::ToInt() and ToUInt() for convenience and consistency with
the existing ToLong() and ToULong().

Closes #22068.
2022-03-26 00:46:58 +01:00
Vadim Zeitlin
a48859e20c Merge branch 'uilocale-fixes'
wxUILocale-related fixes.

See #22222.
2022-03-24 21:39:34 +01:00
Vadim Zeitlin
387981e373 Merge branch 'generic-dvc-fixes'
Fixes to generic wxDataViewCtrl under GTK.

See #22220.
2022-03-24 21:39:09 +01:00
Ilya Sinitsyn
861313f0e9 Handle the nodes duplication error in the DVC test 2022-03-25 00:55:37 +07:00
Vadim Zeitlin
db9756c562 Enable ValNum::Interactive test for MSW CI builds too
This test should work after the fix in the parent commit.
2022-03-23 18:48:35 +01:00
Vadim Zeitlin
5f011b84c1 Merge branch 'tz-parse' of https://github.com/lanurmi/wxWidgets
Parse more time sonzes in wxDateTime::ParseDataTime().

See #22217.
2022-03-23 14:38:58 +01:00
Vadim Zeitlin
b91173f76e Fix comparing wxDataFormat with wxDF_INVALID in wxGTK
Define wxDataFormat::operator==(wxDataFormatId) instead of relying on
the implicit conversion from wxDataFormatId to wxDataFormat, as this
can't be done when the format ID is wxDF_INVALID because creating
wxDataFormat results in an assert failure in this case, while comparing
with wxDF_INVALID is clearly a perfectly valid operation.

Add a unit test checking for this.

Closes #22213.
2022-03-23 13:43:44 +01:00
Vadim Zeitlin
cc02b3cece Revert "Assure that all images in the generic wxImageList have the same scale factor"
This reverts commit b6d305e4f2 because
silently discarding images using a different scale factor is simply too
user-unfriendly: this can silently break the existing code, i.e. it can
still compile perfectly and not give any errors during run-time but not
show any images neither.

Also revert most of dc43d15cf7 (Add tests of storing HiDPI images in
generic wxImageList (wxOSX, wxGTK3), 2021-04-05) as these tests don't
pass any longer because the behaviour was intentionally changed.

See #22189.
2022-03-22 23:01:40 +01:00
Vadim Zeitlin
d9a48edc81 Restore the old default size of Tango art provider bitmaps
The default size of the bitmaps created from bitmap bundles returned by
the Tango art provider for the client strings different from wxART_MENU
and wxART_BUTTON was changed from 24x24 to 16x16 in 766fefeb34 (Use SVG
instead of PNGs in tango art provider, 2022-01-27), see #22067, without
any real need and perhaps even non intentionally at all.

Restore the old default size to restore the old behaviour.

See #22189.
2022-03-22 23:01:40 +01:00
Lauri Nurmi
fdd05c8b8b Parse also time zone in ParseDateTime(), if found
Accept the same kind of time zone specifiers that RFC822 timestamps
accept; most importantly the "+0200" style.

Added more tests, and changed the way tests compare dates:
Since some timestamps now specify a time zone, those need to be compared
as UTC to avoid the system's time zone affecting the tests. Others can
still be compared as local time, as before.
2022-03-22 19:12:48 +02:00
Lauri Nurmi
770cf26afe Fix out-of-bounds with military and truncated time zones; add more tests
Out-of-bounds was already covered by the fact that the date is appended 32
zero-bytes in ParseRFC822Date() as a safety measure. But now the time zone
parsing section of the function no longer relies on those extra zeros
being present.

Added tests for RFC822 timestamps with military time zones, and more types
of truncated, invalid time zone specifiers.
2022-03-22 19:11:22 +02:00
Lauri Nurmi
89eec3cb80 Fix truncated time zone specifier tests for ParseRFC822Date()
Correction to the commit:
2153ffc (Test ParseRFC822Date() with truncated time zone specifiers,
2022-03-19)

The inputs failed as expected, but due to an unrelated reason (missing
comma).
2022-03-22 19:09:23 +02:00
Lauri Nurmi
088e643d37 Do not consume whitespace/delimiters after date in DateParse()
Set the end iterator to the end of the actually parsed date, instead
of consuming any ultimately unparsed whitespace/delimiters possibly
following the date.
2022-03-19 22:56:08 +01:00
Lauri Nurmi
945738042d Fix ParseDate() for dates having day expressed as an ordinal
Previously the year was left unparsed, and the current year was
incorrectly used even when the input provided a year.
2022-03-19 22:56:08 +01:00
Lauri Nurmi
700d763ebc Test ParseDate() with dates containing a weekday
Test both a weekday that matches the date, and one that does not.
2022-03-19 22:56:08 +01:00
Lauri Nurmi
4cf335340c Test the end iterator set by Parse{Date,Time,DateTime}()
In other words, check that the unprocessed part of the input is what
we expected.

Also add some cases where a valid date or time is followed by something.
2022-03-19 22:56:07 +01:00
Lauri Nurmi
23b8ec6d9a Test ParseRFC822Date() with truncated time zone specifiers 2022-03-19 22:56:07 +01:00
Lauri Nurmi
504c0b16c3 Fix ParseDateTime() to also accept time + date, in that order
The intent of the implementation clearly is to allow parsing time first,
date second. But this failed, because a time such as "14:30:15" would
successfully parse as a date (as 14th of current month, current year).

Consequently an attempt is made to parse the actual date as time, which
fails, and therefore the whole ParseDateTime() fails.

Adding a failing test case for ensuring times cannot be parsed as dates
does not cause a failure, because partially yet successfully parsed inputs
get silently ignored (in both ParseDate and ParseDateTime tests). Fixing
both of these, too.

Closes #22203.
2022-03-18 00:01:18 +01:00
Vadim Zeitlin
0cb0db015f Merge branch 'fix-dvc' of https://github.com/thesiv/wxWidgets
Fix behaviour of ItemAdded() in generic wxDataViewCtrl implementation
for not yet opened nodes: calling it shouldn't prevent calling the model
GetChildren() when the node is opened, resulting only in explicitly
added children appearing in it.

See #22201.
2022-03-17 23:57:16 +01:00
Lauri Nurmi
538a75fe4e Decode 2-digit years properly in ParseRfc822Date()
The RFC accepts 2-digit years, and it makes most sense to interpret
e.g. 95 as 1995. However, this is an incompatible change, as earlier
95 was literally decoded as 95 AD.

Years 00..29 are considered to mean 20xx; 30..99 means 19xx.

Closes #22196.
2022-03-17 23:55:57 +01:00
Ilya Sinitsyn
0144608b4b Test DVC with the custom model
wxDataViewCtrl::AssociateModel() don't create child nodes, which leads to
missing nodes if then used wxDataViewModel::ItemAdded(). So add the test
for such situation.
2022-03-17 08:10:58 +07:00
Lauri Nurmi
1c5e66a12c Allow RFC822 timestamps without a week day
RFC 822 specifies the week day is optional.
2022-03-10 19:25:21 +02:00
Lauri Nurmi
8d9d2684ef Fix out-of-bounds reads in ParseRfc822Date() with too short input
The implementation implicitly relies, in many places, on the assumption
that the input never ends prematurely. If it does, the iterator
pointing beyond the end of buffer is dereferenced, which is UB.

The solution used here is to append 32 zero bytes to the date string,
which hopefully keeps the code more readable than checking for the end
of string before each deference operation.

Add various syntactically invalid inputs to unit tests.

Closes #22185.
2022-03-10 16:44:44 +01:00
Vadim Zeitlin
9a3d3156ab Merge branch 'better-bitmap-resize'
Use "nearest" algorithm for resizing bitmaps.

See #22152.
2022-02-27 22:44:50 +00:00
Jouk
6c9d1291f6 Fix build under OpenVMS where mkdtemp() is unavailable
Just skip the part of the test using this function under OpenVMS.

Closes #22158.
2022-02-25 18:23:32 +01:00
Vadim Zeitlin
4e05ee9c5a Benchmark wxIMAGE_QUALITY_BOX_AVERAGE too for completeness
Check the speed of wxImage::Scale() using this algorithm too.

As expected, it's between normal and high quality when upscaling and
exactly the same as high quality when shrinking (because it is actually
the algorithm used for shrinking for wxIMAGE_QUALITY_HIGH).
2022-02-23 00:01:52 +00:00
Vadim Zeitlin
e25b47ee32 Allow tweaking parameters of wxImage::Scale() benchmarks
Use the string parameter as the name of the file containing the image to
resize and the numeric parameter as the scale factor in percents (so
that fractional factors could also be specified using this integer
parameter).
2022-02-22 23:59:36 +00:00
Vadim Zeitlin
a8ec7eec0b Allow passing default value to Bench::GetXXXParameter()
Just an extra convenience for the benchmark functions.
2022-02-22 23:58:38 +00:00
Vadim Zeitlin
5847b302be Make it possible to run a benchmark for the given amount of time
This is more practical than running it a given number of times, which
may result in very long running times for slow functions, such as
wxImage resizing tests using wxIMAGE_QUALITY_HIGH.

Also show the standard deviation in addition to the average and min/max
values.
2022-02-22 23:58:19 +00:00
Vadim Zeitlin
4ff445af4d Check that we parsed something in wxBitmapBundle::FromSVG()
Don't always return success from this function, NanoSVG just skips
everything until the start of the XML prologue and doesn't return an
error even if it doesn't find it at all, so check that it could parse at
least something to avoid returning a "valid" bundle not containing
anything at all.

Add a unit test checking that we actually can't create an SVG from a
.bmp file (which is something that "worked" before).
2022-02-15 19:37:22 +00:00
Vadim Zeitlin
f0e6a8b15a Merge branch 'bitmap-scale-fixes'
Really fix setting wxBitmap scale factor in wxMSW and rename
wxBitmap::CreateWithLogicalSize() to CreateWithDIPSize().

See #22118.
2022-02-13 00:27:24 +01:00
Vadim Zeitlin
74424cbeb2 Rename wxBitmap::CreateWithLogicalSize() to CreateWithDIPSize()
The new name, recently introduced in 94716fd801 (Add
wxBitmap::CreateWithLogicalSize(), 2022-01-22), was perhaps more clear,
but also misleading and confusing because the postcondition

	CreateWithLogicalSize(size, 2).GetLogicalSize() == size

was not satisfied under MSW, so rename it once again, and hopefully
finally, because the new name is consistent with GetDIPSize() returning
the same size.

Also try to improve the documentation a bit more.
2022-02-11 17:30:57 +00:00
Vadim Zeitlin
20f82e2ccb Fix CreateWithLogicalSize() to set correct scale in wxMSW too
Unlike under Mac (see previous commit), this never worked correctly in
wxMSW at all, only SetScaleFactor() could be used to change the scale
factor of the bitmaps there.

Fix this and make CreateWithLogicalSize(..., scale) result in
GetScaleFactor() returning the same scale for the resulting bitmap, as
expected, under MSW too.

Also add a unit test verifying that this holds.
2022-02-11 17:15:51 +00:00
Vadim Zeitlin
d130323a4c Fix default size of wxBitmapBundle created from scaled bitmap
We need to use GetDIPSize(), not GetLogicalSize(), for this to work
correctly under MSW too.

Also add a unit test checking for this.
2022-02-10 14:01:09 +00:00
Vadim Zeitlin
20d1188e82 Really fix setting wxBitmap scale factor
Optimization of 2ae80673ff (Avoid unnecessarily unsharing bitmaps in
wxMSW, 2022-02-02) broke setting the scale factor because we didn't
update the right bitmap data in case bitmap hadn't had exclusive
ownership of its data before. Fix this by not using a reference which
may refer to another object after AllocExclusive() call.

Also change the other ports to unshared the bitmap when modifying its
scale factor so that the new unit test passes for them too.
2022-02-10 14:01:09 +00:00
Vadim Zeitlin
34ca92d362 Show logs in case of Mkdir or Rmdir failures in wxFSW unit tests
Try to gather more information about the test failures on GitHub Actions
when creating or removing the test directory that isn't reproducible
locally.
2022-02-10 13:55:54 +00:00
Vadim Zeitlin
046f228bb2 Reset watch directory in wxFileSystemWatcher unit test
Share the same variable between GetWatchDir() and RemoveWatchDir() to
make things more clear.

Also check for GetWatchDir() postcondition (i.e. that the directory
exists) in the function itself instead of doing it in the caller.
2022-02-10 13:38:00 +00:00
Vadim Zeitlin
93c86fe5cd Fix harmless signed/unsigned warning in wxRegEx unit test
Cast the expected number of matches to "int" to have the same type as
wxRegEx::Replace() return value -- there is no danger of truncation here
as we're never going to expect billions of matches.
2022-02-10 13:36:49 +00:00
Scott Talbert
f172f53ac4 Create our own socket file for socket file test
/dev/log doesn't exist in certain types of containers (e.g., Fedora's
build system).  Additionally, this enables us to run this test on
platforms other than Linux.

Closes #22090.
2022-02-05 16:18:22 +01:00
oneeyeman1
995c6e6df5 Add wxSpinCtrl::SetIncrement() and implement it for all ports
SetIncrement() was already available in wxSpinCtrlDouble and GTK version
of wxSpinCtrl, now implement support for it in wxMSW and wxOSX as well.

In fact, in wxMSW, implement it at wxSpinButton level, so that both this
class and wxSpinCtrl inheriting from it (in wxMSW only) support setting
custom increment now.

Also add support for it to XRC, show it in the sample and add a unit
test verifying that it works.

Closes #2597.
2022-02-04 02:16:06 +01:00