Check the values from wxWebRequestEvent in the unit test too
In addition to checking that wxWebRequest itself is filled with the expected values, verify that the same values are returned via wxWebRequestEvent.
This commit is contained in:
parent
c0f8c0e0f2
commit
0548a06905
@ -44,6 +44,8 @@ public:
|
||||
{
|
||||
expectedFileSize = 0;
|
||||
dataSize = 0;
|
||||
stateFromEvent = wxWebRequest::State_Idle;
|
||||
statusFromEvent = 0;
|
||||
}
|
||||
|
||||
// All tests should call this function first and skip the test entirely if
|
||||
@ -81,7 +83,17 @@ public:
|
||||
|
||||
void OnRequestState(wxWebRequestEvent& evt)
|
||||
{
|
||||
switch (evt.GetState())
|
||||
stateFromEvent = evt.GetState();
|
||||
const wxWebResponse& response = evt.GetResponse();
|
||||
if ( response.IsOk() )
|
||||
{
|
||||
// Note that the response object itself may be deleted if request
|
||||
// using it is, so we need to copy its data to use it later.
|
||||
statusFromEvent = response.GetStatus();
|
||||
responseStringFromEvent = response.AsString();
|
||||
}
|
||||
|
||||
switch ( stateFromEvent )
|
||||
{
|
||||
case wxWebRequest::State_Idle:
|
||||
FAIL("should never get events with State_Idle");
|
||||
@ -134,16 +146,22 @@ public:
|
||||
request.Start();
|
||||
RunLoopWithTimeout();
|
||||
|
||||
if ( request.GetState() != requiredState )
|
||||
if ( stateFromEvent != requiredState )
|
||||
{
|
||||
errorDescription.Trim();
|
||||
if ( !errorDescription.empty() )
|
||||
WARN("Error: " << errorDescription);
|
||||
}
|
||||
|
||||
REQUIRE( request.GetState() == requiredState );
|
||||
REQUIRE( stateFromEvent == requiredState );
|
||||
|
||||
CHECK( request.GetState() == stateFromEvent );
|
||||
|
||||
if (requiredStatus)
|
||||
{
|
||||
CHECK( statusFromEvent == requiredStatus );
|
||||
CHECK( request.GetResponse().GetStatus() == requiredStatus );
|
||||
}
|
||||
}
|
||||
|
||||
// Precondition: we must have an auth challenge.
|
||||
@ -156,6 +174,9 @@ public:
|
||||
wxString baseURL;
|
||||
wxEventLoop loop;
|
||||
wxWebRequest request;
|
||||
wxWebRequest::State stateFromEvent;
|
||||
int statusFromEvent;
|
||||
wxString responseStringFromEvent;
|
||||
wxInt64 expectedFileSize;
|
||||
wxInt64 dataSize;
|
||||
wxString errorDescription;
|
||||
|
Loading…
Reference in New Issue
Block a user