New issue
Advanced search Search tips

Issue 850145 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , iOS , Chrome , Mac , Fuchsia
Pri: 3
Type: Task



Sign in to add a comment

Migrate net::TestDelegate and consumers off of base::RunLoop::QuitCurrent*Deprecated()

Project Member Reported by w...@chromium.org, Jun 6 2018

Issue description

The net::TestDelegate, related test classes, and the test which rely upon it, currently set Boolean options to specify the events of interest, and then base::RunLoop::Run() to wait for those events to occur, expecting that the TestDelegate will invoke QuitCurrent*Deprecated() to quit whatever RunLoop is running at the time.

As the name suggests, the call is deprecated, and its use makes the tests fragile, and makes it harder to reason about what they are actually waiting for.

Proposal is to introduce explicit RunUntil<Event>() helpers for the common case of using TestDelegate to just wait for completion of a request, and closure-setters for more complex tests.  The old behaviour and API will be retained for use by current tests, to allow migration to be done incrementally.

 

Comment 1 by w...@chromium.org, Jun 6 2018

Labels: Hotlist-Refactoring

Comment 2 by w...@chromium.org, Jun 6 2018

Blocking: 844016

Comment 3 by w...@chromium.org, Jun 6 2018

Owner: w...@chromium.org
Status: Started (was: Untriaged)
Project Member

Comment 4 by bugdroid1@chromium.org, Jun 7 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/927db59630b51307f33eaf3d2b01ec90b8f36fdc

commit 927db59630b51307f33eaf3d2b01ec90b8f36fdc
Author: Wez <wez@chromium.org>
Date: Thu Jun 07 03:20:52 2018

Add new RunUntilComplete() and set_on_<event>() APIs to TestDelegate.

- Simple tests can use RunUntilComplete() to wait specifically for
  completion of a request.
- More complex tests can use set_on_<event>() to provide closures to
  invoke on completion, redirect, or auth-required. These will usually
  be passed a RunLoop's QuitClosure() to invoke.
- set_on_<event>() can be called with a null RepeatingClosure to
  cause that event to be silently ignored.

TestDelegate's default behaviour is unchanged, and the "legacy" APIs
to set_quit_on_<event>() flags are still available, so that tests can
be migrated incrementally.

Bug:  844016 , 850145
Change-Id: I5d6aea0a6a25a67f388ddb91c685b29d8b9eb6a8
Reviewed-on: https://chromium-review.googlesource.com/1088153
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565163}
[modify] https://crrev.com/927db59630b51307f33eaf3d2b01ec90b8f36fdc/net/url_request/url_request_test_util.cc
[modify] https://crrev.com/927db59630b51307f33eaf3d2b01ec90b8f36fdc/net/url_request/url_request_test_util.h

Project Member

Comment 5 by bugdroid1@chromium.org, Jun 7 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2a31b22b7cb4d5c754737110f1299b30739c1b3b

commit 2a31b22b7cb4d5c754737110f1299b30739c1b3b
Author: Wez <wez@chromium.org>
Date: Thu Jun 07 22:07:15 2018

Update various //net tests to use TestDelegate::RunUntilComplete() etc.

Update a subset of the //net tests to pump the message loop until a
particular event occurs by creating a RunLoop and passing its
QuitClosure to TestDelegate::set_on_<event>(..), or by using the
RunUntilComplete() helper.

Bug: 850145
Change-Id: Icc3cff76d5a7b93e92d2799ef9410bd41a31024f
Reviewed-on: https://chromium-review.googlesource.com/1084034
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: Eric Roman <eroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565433}
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/nqe/network_quality_estimator_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/nqe/throughput_analyzer_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/quic/chromium/quic_network_transaction_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/url_request/url_request_http_job_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/url_request/url_request_job_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/url_request/url_request_quic_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/url_request/url_request_simple_job_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/url_request/url_request_unittest.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/websockets/websocket_end_to_end_test.cc
[modify] https://crrev.com/2a31b22b7cb4d5c754737110f1299b30739c1b3b/net/websockets/websocket_stream_test.cc

Project Member

Comment 6 by bugdroid1@chromium.org, Jun 18 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0e7171111f1f364444a605650d111b8ac71e98d1

commit 0e7171111f1f364444a605650d111b8ac71e98d1
Author: Wez <wez@chromium.org>
Date: Mon Jun 18 23:09:22 2018

Remove legacy net::TestDelegate APIs and update tests.

Update the TestDelegate:
- Add RunUntilRedirect() and RunUntilAuthRequired() APIs.
- Create a clean separation between "legacy" and new API closures.
- Call the on_<event> closures in-line, rather than via PostTask.
- Use OnceClosures for new APIs instead of RepeatingClosure.
- Remove set_quit_on_redirect() and set_quit_on_auth_required().

Related changes to tests, including:
- Add necessary RunUntilIdle() calls after e.g. RunUntil*(), in
  various tests that were relying on QuitWhenIdle behaviour.
- Update FakeExternalProtocolHandlerDelegate,
  ExternalProtocolHandlerTest, EmbeddedTestServerTest,
  CancelRequestDelegate and SSLClientAuthTestDelegate to use
  QuitClosure.

Bug: 850145
Change-Id: I9320e5b7dc3e4aac883fa49dcdcd6384bc7d3ce9
Reviewed-on: https://chromium-review.googlesource.com/1094209
Reviewed-by: Tarun Bansal <tbansal@chromium.org>
Reviewed-by: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: Eric Roman <eroman@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568217}
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/chrome/browser/chromeos/fileapi/external_file_url_request_job_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/chrome/browser/external_protocol/external_protocol_handler_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/chrome/browser/net/chrome_network_delegate_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/components/data_use_measurement/core/data_use_network_delegate_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/content/browser/appcache/appcache_storage_impl_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/network_error_logging/network_error_logging_end_to_end_test.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/nqe/network_quality_estimator_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/nqe/throughput_analyzer_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/quic/chromium/quic_network_transaction_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/spdy/spdy_network_transaction_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/test/embedded_test_server/embedded_test_server_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/url_request/url_request_ftp_job_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/url_request/url_request_quic_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/url_request/url_request_test_util.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/url_request/url_request_test_util.h
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/net/url_request/url_request_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/storage/browser/fileapi/file_system_dir_url_request_job_unittest.cc
[modify] https://crrev.com/0e7171111f1f364444a605650d111b8ac71e98d1/storage/browser/fileapi/file_system_url_request_job_unittest.cc

Comment 7 by w...@chromium.org, Jun 19 2018

Blocking: -844016
Owner: eroman@chromium.org
Status: Assigned (was: Started)
This is as far as I need to take things to un-block the RunLoop work, so handing off for you to Untriaged or re-assign, as appropriate. :)

Comment 8 by w...@chromium.org, Jun 19 2018

Description: Show this description
Cc: -eroman@chromium.org
Owner: ----
Status: Available (was: Assigned)
Labels: -Type-Bug Network-Triaged Type-Task
Labels: Enterprise-Triaged

Sign in to add a comment