Commit Graph

2803 Commits

Author SHA1 Message Date
Vadim Zeitlin
61e24f6be0 Give more information if wxFont unit tests fail
Use INFO() to provide extra information instead of the ugly
WX_ASSERT_MESSAGE().
2022-04-18 14:29:53 +02:00
Vadim Zeitlin
b66d4488e1 Merge branch 'fn-long-path'
Fix wxPATH_NORM_LONG with UNC paths and slightly optimize long path
normalization.

See #22307.
2022-04-17 18:51:09 +02:00
Vadim Zeitlin
2144ca38d2 Get rid of CppUnit boilerplate in DynamicLibraryTestCase
Use CATCH macros directly, this is simpler and more clear.

Also use narrow strings instead of wide ones and get rid of wxT() too.

No real changes.

This commit is best viewed ignoring whitespace-only changes.
2022-04-17 18:44:51 +02:00
Vadim Zeitlin
f3b4ee3b5f Skip dynamic library file existence check under Darwin
Under Monterrey (macOS 10.12) we can actually load the file using
wxDynamicLibrary even though it does _not_ exist on the disk, so don't
skip the test just because of this.
2022-04-17 18:38:08 +02:00
Vadim Zeitlin
c6b3b4a39c Make the warning in DynamicLibraryTestCase actually visible
Using wxLogWarning() doesn't work as logs are suppressed by default, but
using CATCH WARN() macro does work.
2022-04-17 18:35:34 +02:00
Vadim Zeitlin
6a48431ca1 Add missing wxLogWarning() argument to wxDynamicLibrary test
The argument corresponding to the "%s" format specifier was missing,
which resulted in a crash if the dynamic library tested didn't actually
exist.
2022-04-17 18:30:42 +02:00
Vadim Zeitlin
35d08e6a87 Don't corrupt UNC paths when normalizing with wxPATH_NORM_LONG
After the fixes to UNC paths handling, Normalize(wxPATH_NORM_LONG)
started adding an extra colon after the UNC paths.

Fix this by using wxGetVolumeString() instead of constructing this thing
manually and add a unit test checking for this.

Closes #22275.
2022-04-15 00:32:35 +01:00
Vadim Zeitlin
e50c7b2e2f Add GetDOSPath() helper to wxFileName unit test
No real changes.
2022-04-15 00:13:07 +01:00
Vadim Zeitlin
0ba4cf8ac9 Avoid spurious MSVC warning about uninitialized variable
Use wxDUMMY_INITIALIZE() to suppress a warning in wxDVC unit test.
2022-04-14 17:46:39 +01:00
Vadim Zeitlin
4e6e1ce054 Show debug log messages on the console in the test when enabled
Using LogEnabler in wxFileSystemWatcher test case still didn't show
anything even in case of unexpected failures because debug messages
didn't appear in the test output.

Fix this by using a custom log target which shows the debug (and trace)
messages on stderr, instead of using the debug output for them, even
under MSW.

Also make LogEnabler public, and rename it to a more unique name, as it
could be useful in the other tests too.
2022-04-14 17:37:32 +01:00
Vadim Zeitlin
ce46d77360 Merge branch 'bitmap-dc-ctor'
Add wxBitmap ctors taking wxDC to all ports and set the scale factor
correctly in the existing ctors taking wxDC in wxMSW.

See #22297.
2022-04-13 15:57:35 +02:00
Vadim Zeitlin
24970061fa Add wxBitmap(wxImage, wxDC) ctor to all ports
This ctor was previously present only in wxMSW, make it available in all
ports to allow the same code to compile everywhere.

In most of them wxDC argument is simply ignored, but in wxGTK and wxOSX
it is used to assign the appropriate scale factor for the new bitmap.

Enable previously wxMSW-only unit test checking for this.
2022-04-12 19:08:56 +01:00
Vadim Zeitlin
b185186ebf Handle scale factor in another wxMSW wxBitmap ctor taking wxDC
This is similar to db6d565fad (Handle wxDC scale factor in wxBitmap ctor
taking wxDC in wxMSW, 2022-04-10), but for the constructor taking
wxImage and wxDC -- it should also use the DC scale factor, even if it
is not used for scaling the bitmap size in this case.

Add a unit test checking for this.
2022-04-12 17:57:49 +01:00
Vadim Zeitlin
558a300996 Create bitmaps from image and a wxDC without an HDC in wxMSW
This is similar to 7382e99bbb (Create bitmaps even when given a wxDC
without an HDC in wxMSW, 2022-04-10) and does the same change to
wxBitmap ctor from wxImage and wxDC -- and also extends the unit test to
check for this under wxMSW, which is the only port in which this ctor is
currently available.
2022-04-12 17:30:42 +01:00
Maarten Bent
87465898f3 Fix unused variable warnings 2022-04-10 23:41:44 +02:00
Vadim Zeitlin
db6d565fad Handle wxDC scale factor in wxBitmap ctor taking wxDC in wxMSW
When using wxBitmap ctor taking wxDC, the bitmap should inherit the
scale factor of the DC, both because it's already the case in the other
ports and because it makes sense to do it.

Add a unit test checking that this is the case in all ports now.
2022-04-10 19:45:59 +01:00
Vadim Zeitlin
7382e99bbb Create bitmaps even when given a wxDC without an HDC in wxMSW
It seems wrong to just fail to create the bitmap entirely if a not
wxMSWDCImpl-derived wxDC is provided to wxBitmap::Create(size, wxDC)
overload, especially because no check is done to see if the associated
HDC is non-null for wxMSWDCImpl-derived classes.

Instead, simply create a DIB-based bitmap with the specified size, as
this seems more useful and less surprising and was already the behaviour
in the other ports.

Add a test ensuring that this remains the case in the future.
2022-04-10 19:43:29 +01:00
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