Skip to content

Commit

Permalink
[Cronet] |TestUrlRequestCallback| should record response info on cancel.
Browse files Browse the repository at this point in the history
The response info is sometimes present -- TestUrlRequestCallback should
record it if its there, otherwise, tests may make mistaken comparisons.

Bug: 879208
Change-Id: I90fd0d7833aa6ed384035644966a3a0dcdad05e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1585474
Reviewed-by: Misha Efimov <mef@chromium.org>
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Commit-Queue: Caleb Raitto <caraitto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#655606}
  • Loading branch information
caraitto authored and Commit Bot committed May 1, 2019
1 parent b5d52c1 commit 4a4cf55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions components/cronet/native/test/test_url_request_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ void TestUrlRequestCallback::OnCanceled(Cronet_UrlRequestPtr request,

response_step_ = ON_CANCELED;
on_canceled_called_ = true;
// It is possible |info| is nullptr if the response has not started.
if (info)
response_info_ = std::make_unique<UrlResponseInfo>(info);
MaybeCancelOrPause(request);
SignalDone();
}
Expand Down
6 changes: 3 additions & 3 deletions components/cronet/native/test/url_request_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,11 +1125,11 @@ void UrlRequestTest::TestCancel(

TEST_P(UrlRequestTest, TestCancel) {
TestCancel(TestUrlRequestCallback::CANCEL_SYNC,
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, false, false);
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, true, false);
TestCancel(TestUrlRequestCallback::CANCEL_ASYNC,
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, false, false);
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, true, false);
TestCancel(TestUrlRequestCallback::CANCEL_ASYNC_WITHOUT_PAUSE,
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, false, false);
TestUrlRequestCallback::ON_RECEIVED_REDIRECT, true, false);

TestCancel(TestUrlRequestCallback::CANCEL_SYNC,
TestUrlRequestCallback::ON_RESPONSE_STARTED, true, false);
Expand Down

0 comments on commit 4a4cf55

Please sign in to comment.