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.
This commit is contained in:
Vadim Zeitlin
2021-01-16 00:21:00 +01:00
parent a561cf199b
commit 65aad890e3
8 changed files with 108 additions and 1 deletions

View File

@@ -144,6 +144,33 @@ TEST_CASE_METHOD(RequestFixture,
CHECK( request.GetBytesReceived() == 65536 );
}
TEST_CASE_METHOD(RequestFixture,
"WebRequest::Get::Simple", "[net][webrequest][get]")
{
if ( !InitBaseURL() )
return;
// Note that the session may be initialized on demand, so don't check the
// native handle before actually using it.
wxWebSession& session = wxWebSession::GetDefault();
REQUIRE( session.IsOpened() );
// Request is not initialized yet.
CHECK( !request.IsOk() );
CHECK( !request.GetNativeHandle() );
Create("/status/200");
CHECK( request.IsOk() );
CHECK( session.GetNativeHandle() );
// Note that the request must be started to have a valid native handle.
request.Start();
CHECK( request.GetNativeHandle() );
RunLoopWithTimeout();
CHECK( request.GetState() == wxWebRequest::State_Completed );
CHECK( request.GetResponse().GetStatus() == 200 );
}
TEST_CASE_METHOD(RequestFixture,
"WebRequest::Get::String", "[net][webrequest][get]")
{