Commit Graph

2536 Commits

Author SHA1 Message Date
Vadim Zeitlin
c41041a3b6 Show error description if available when Cancel() test fails
Hopefully this might provide more information about the failure of this
test in MSVS 2008 build on AppVeyor.
2021-01-16 21:21:08 +01:00
Vadim Zeitlin
717e6590bd Merge branch 'macos_wkwebview' of https://github.com/TcT2k/wxWidgets
Use WKWebView for wxWebView Implementation under Apple systems.

See https://github.com/wxWidgets/wxWidgets/pull/2113
2021-01-16 16:20:58 +01:00
Vadim Zeitlin
1065e61ab7 Merge branch 'log-ms'
Use milliseconds in wxLog timestamps.

See https://github.com/wxWidgets/wxWidgets/pull/2164
2021-01-16 16:00:57 +01:00
Vadim Zeitlin
0777fda680 Rearrange states in the switch in a more logical order
No real changes, just try to organize the code in a more logical order.
2021-01-16 15:07:18 +01:00
Vadim Zeitlin
0742ae9091 Verify that native handle is available when state becomes active
Check that GetNativeHandle() behaves as documented.
2021-01-16 15:05:38 +01:00
Vadim Zeitlin
204ae594a2 Check that we never get events about switching to State_Idle
This state can never be returned to, once the state becomes active.
2021-01-16 15:02:06 +01:00
Vadim Zeitlin
65aad890e3 Add GetNativeHandle() to wxWebSession and wxWebRequest
This allows to retrieve the handles used internally in order to do
something not supported by the public API yet.
2021-01-16 00:21:00 +01:00
Vadim Zeitlin
60d429047e Fix workaround for the test failure with Ubuntu 14.04 libcurl
Don't check for 200 status code. Also don't check the response body if
we don't get it at all.
2021-01-15 23:14:14 +01:00
Vadim Zeitlin
af160f3d3e Use CHECK() when REQUIRE() is not needed in wxWebRequest tests
Continue performing the other checks unless we really can't do it.
2021-01-15 15:42:12 +01:00
Vadim Zeitlin
1e8fe318ed Work around wxWebRequest test failure under Ubuntu 14.04
Ignore wrong status code returned by libcurl on this ancient version,
it's not worth dealing with it.
2021-01-15 15:40:32 +01:00
Vadim Zeitlin
e6cedf6649 Really support milliseconds in wxLog
Although this was supposed to work, specifying "%l" in wxLog time stamp
format actually didn't because wxLog timestamps were stored as seconds.

Fix this by storing them as milliseconds and add a simple test (not
executed by default) showing that "%l" works correctly now.

Still keep the old wxLogRecordInfo::timestamp field for compatibility,
as it was documented.

See #13059.
2021-01-15 14:55:06 +01:00
Vadim Zeitlin
ef08d499ce Remove unnecessary SetIgnoreServerErrorStatus() from the API
It's up to the application code to decide how it handles the HTTP status
codes it gets back from server, there is no need to have a special
method for handling them in wxWebRequest itself.

We also shouldn't skip downloading the response body just because it was
unsuccessful, we may still need it (e.g. it's very common to return the
detailed error description in a JSON object in the message body when
returning some 4xx error), so don't do it in wxMSW implementation and
add a test verifying that we still get the expected body even for an
error status.

Also improve wxWebRequest::State values documentation.
2021-01-15 03:08:18 +01:00
Vadim Zeitlin
f85f716cea Show more information about the request result in manual test
Show the HTTP status as well as data retrieved by the server.
2021-01-15 02:52:15 +01:00
Vadim Zeitlin
f9d7a06c37 Fix tags for WebRequest::Manual() unit test
Don't give it any tags other than "." as we don't want to execute it
when these tags are specified, only when it's explicitly selected by
using its name on the command line.
2021-01-15 00:56:49 +01:00
Vadim Zeitlin
168408620d Add wxWebRequest::Cancel() unit test
Check that the request does get cancelled and has the correct state.
2021-01-15 00:53:45 +01:00
Vadim Zeitlin
70e7861a7d Implement authentication support for wxWebRequest under Mac
Add wxWebAuthChallengeURLSession and use the appropriate delegate
callback to create it.
2021-01-15 00:46:45 +01:00
Vadim Zeitlin
e80b65b132 Add timeout to wxWebRequest test
Ensure that the test terminates even if we don't get the expected event.
2021-01-15 00:45:54 +01:00
Vadim Zeitlin
89bc7b522f Use standard timestamp format for debug messages in the tests
Don't use the current locale format which doesn't provide all the
information (e.g. never includes milliseconds) and explicitly set the
format providing it instead when showing wxLogTrace() messages.
2021-01-13 19:01:20 +01:00
Artur Wieczorek
331840edb3 Fix replacing images in generic wxImageList
Bitmaps stored in the list as a result of replacing existing ones should
conform to the same constraints as bitmaps directly added to the list.
These constraints are applied in the shared GetImageListBitmap() function
called both on adding and replacing the images.
2021-01-13 18:38:57 +01:00
Artur Wieczorek
030664c148 Add tests of wxImageList
This is a basic test set.
2021-01-12 18:22:03 +01:00
Vadim Zeitlin
20a3317839 Rename wxWebRequestEvent::GetResponseFileName() to GetDataFile()
This is shorter and doesn't imply that just the name (and not the full
path) is being returned.

Also rename wxWebResponse::GetFileName() to GetDataFile() for the same
reasons and for consistency. And document this previously undocumented
method.
2021-01-12 03:34:40 +01:00
Vadim Zeitlin
252373e540 Allow a simple way to rest requesting the given URL in the test
This does nothing more than just running a GET request for the given
URL for testing purposes.
2021-01-11 02:30:43 +01:00
Vadim Zeitlin
0588b0e7ce Extract all the wxWebRequest test sections in separate tests
As in 31a441e814 (Use separate test cases for wxWebRequest auth tests,
2021-01-10), there is no real reason to use sections here as we don't
reuse anything between them and using separate tests makes it easier to
run individual tests and, especially, combinations of them.

This commit is best viewed ignoring whitespace-only changes.
2021-01-10 21:27:51 +01:00
Vadim Zeitlin
31a441e814 Use separate test cases for wxWebRequest auth tests
This allows to easily run both auth tests at once without all the other
tests and it's not like we reuse much (or actually anything) by having
them as sections in the same test case anyhow.

This commit is best viewed ignoring whitespace-only changes.
2021-01-10 21:27:15 +01:00
Vadim Zeitlin
1e6d6be8bb Add wxWebCredentials and use it in SetCredentials()
Prefer using a class encapsulating both the user name and the password
to using a pair of variables.
2021-01-10 21:27:15 +01:00
Vadim Zeitlin
8820bb9609 Test using wrong credentials in the auth unit tests too
In addition to verifying that the correct password works, check that
using a wrong one does not.
2021-01-10 00:41:05 +01:00
Vadim Zeitlin
b64ad7f06d Test Basic, not Digest, authentication method in the test
Basic authentication method unit test somehow used Digest authentication
method.
2021-01-10 00:33:39 +01:00
Jouk
003d24d3c1 workaround for which is probably a compiler-bug on OpenVMS-AXP 2021-01-07 09:47:46 +01:00
Vadim Zeitlin
989cafe535 Take raw pointer and not wxSharedPtr<> in SetData()
Using shared pointer seems to be ill-advised here, the stream shouldn't
be shared as it's going to be used by wxWebRequest itself and can't be
used by the application code in parallel, so the ownership transfer
semantics is more appropriate.

We could take a wxScopedPtr<> instead, but wx API takes ownership of raw
pointers everywhere else, so do it here too.

Incidentally fix a bug with calling IsOk() on a possibly null pointer.
2021-01-04 01:57:36 +01:00
Artur Wieczorek
0a06a5066a Add test of putting wxImage on and retrieving it from clipboard 2020-12-31 13:59:13 +01:00
Vadim Zeitlin
63f1260739 Skip wxWebRequest authentication tests when using NSURLSession
The NSURLSession-based backend is missing authentication support, so
these tests always fail there, skip them for now.
2020-12-30 14:41:17 +01:00
Vadim Zeitlin
50424cba2c Change wxWebRequest and related objects to hide ref counting
Don't force the application code to deal with wxObjectDataPtr<> or,
worse, calling {Inc,Dec}Ref() manually by hiding it inside the wx
objects themselves and giving the value-like semantics to them.

There should be no real changes in the behaviour, but the API does
change significantly. Notably, wxWebRequest is not a wxEvtHandler itself
any longer, as this would be incompatible with the value semantics, and
an event handler needs to be specified when creating it, so that it
could be notified about the request state changes.
2020-12-30 02:02:20 +01:00
Dimitri Schoolwerth
ff79db8ac1 wxGrid: Add test for auto-wrapped multi-line cells
Check that a row's height doesn't change when auto-sizing a column with
an auto-wrapping cell containing newlines.

Also currently will cause an infinite loop which will be fixed in the
next commit.

See #15943.
2020-12-28 00:13:17 +01:00
Vadim Zeitlin
8b632bb892 Enable wxWebRequest tests by default
Don't require WX_TEST_WEBREQUEST_URL environment variable to be set, but
only allow defining it to override the default https://httpbin.org value
or to disable the tests by setting it to 0.
2020-12-26 16:43:03 +01:00
Vadim Zeitlin
6a064c85d4 Compile even less code when wxUSE_WEBREQUEST==0 in the test
Move the check slightly higher, there is no need to include the headers
if we're not going to compile any tests anyhow.
2020-12-26 16:00:03 +01:00
Maarten Bent
a530d645d1 Replace tabs with spaces 2020-12-23 17:03:10 +01:00
Tobias Taschner
10398b8f72 macOS: Document missing wxWebView features and don't test for them 2020-12-14 13:40:32 +01:00
Vadim Zeitlin
b37c7417f6 Don't make wxWebRequest::SplitParameters() public
They're not necessary to use this class and we may consider exporting
them later, possibly with a better API and more tests, if really needed.

Also do change their API slightly by leaving only a single function and
returning the value instead of using an out parameter for it to make it
simpler to use.
2020-12-13 02:41:01 +01:00
Vadim Zeitlin
be3eb334f6 Add file with wxWebRequest unit tests to MSVS project too
This file is not generated and so needs to be updated manually.
2020-12-13 02:39:23 +01:00
Vadim Zeitlin
64a3801160 Tweaks to wxWebRequest::SetData() overload taking stream
Check that the stream is valid, if specified at all, and return false if
it isn't -- or if no size was specified and determining stream size
failed.

Check for SetData() success in the test to provide better diagnostics in
case the file it uses is not found (as is the case when running the test
from another directory, for example).

Also pass wxSharedPtr<> by const reference instead of by value to avoid
unnecessary copies.
2020-12-12 18:46:28 +01:00
Vadim Zeitlin
92e41a7477 Improve reporting test failures due to assert failures
Show the condition which failed for wxASSERT() (as opposed to
wxASSERT_MSG()), as otherwise the error message didn't show any
information at all, making diagnosing the problem impossible.

Also show the assert location, as this can be useful too and there
doesn't seem to be any reason not to do it.
2020-12-12 18:13:25 +01:00
Vadim Zeitlin
fcaccbf12c Avoid -Wswitch warnings in wxWebRequest test
No real changes, just suppress the warnings about not handling all
states in a switch.
2020-12-12 18:12:44 +01:00
Vadim Zeitlin
6bdab7b3c8 Merge branch 'master' into web-request
Merge with the latest master in preparation for merging into master.

Rebake to resolve conflicts in generated files.
2020-12-12 18:12:25 +01:00
Vadim Zeitlin
d47fa718cd Add wxDataViewCtrl::ExpandChildren()
This convenient method allows to expand all children of the item
recursively.

This is directly supported by both native implementations, so it makes
sense to have this in wxDataViewCtrl itself, even if it could be also
(less efficiently) implemented in the user code.
2020-12-05 16:37:13 +01:00
Vadim Zeitlin
859193fb65 Merge branch 'connect-overloaded-c++17'
Make Connect() work with overloaded event handlers in C++17.

See https://github.com/wxWidgets/wxWidgets/pull/2126
2020-12-04 20:02:46 +01:00
Vadim Zeitlin
dc33f27e10 Merge branch 'printf-out-of-mem'
Fix crash in wxString::PrintfV() due to integer overflow/running out of
memory.

See https://github.com/wxWidgets/wxWidgets/pull/2131
2020-12-04 20:01:30 +01:00
Vadim Zeitlin
a7dfedf602 Skip URL test if it fails when running on AppVeyor
Failing it is not useful, this results in the CI failure when in 99% of
the cases the transient network problem which resulted in this test
failure has nothing to do with the changes being tested.
2020-12-04 19:29:59 +01:00
Vadim Zeitlin
344cc940a0 Impose upper limit on memory allocation in wxString::PrintfV()
Don't loop indefinitely until we run out of memory, possibly after
wrapping around INT_MAX, but impose an arbitrary limit of 128MiB for the
max allocation done by wxString::PrintfV() when the provided format
string or one of the arguments are invalid.

This notably fixes a crash when trying to use "%c" to output an invalid
Unicode character.

Also improve comment explaining DoStringPrintfV() logic and change the
size type to size_t from int.

Co-Authored-By: Arrigo Marchiori <ardovm@yahoo.it>
2020-12-01 21:53:55 +01:00
Vadim Zeitlin
8fb4ab99f1 Always return -1 but set errno in our wxVsnprintf() on error
This makes it more compatible with the standard behaviour of vswprintf()
and allows to use the same logic in the builds using our version of this
function and the normal ones in DoStringPrintfV(), simplifying its
(already rather hairy) logic.

Update the tests to not require any particular return value in case of
buffer overflow, as this differs between Unicode and non-Unicode builds.
When we finally drop the latter, we should just check that it always
returns -1 in this case.

Note that ideal would be to return the actually needed size of the
buffer in case of the error due to buffer being too small, but this
isn't that simple to do and it's probably not worth spending time on
improving this code as long as we still need to use the buffer doubling
strategy in DoStringPrintfV() when using the standard vswprintf().
2020-12-01 21:53:55 +01:00
Vadim Zeitlin
7a2786bf11 Get rid of CppUnit macros in wxVsnprintf() tests too
Use CATCH macros directly.

Also remove some unnecessary casts and wxT().
2020-12-01 00:53:07 +01:00