Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Issue 2406273002: [Cronet] Test the libcronet that's shipped, not libcronet_test (Closed)

Created:
4 years, 2 months ago by pauljensen
Modified:
4 years, 1 month ago
Reviewers:
kapishnikov, mef, xunjieli
CC:
chromium-reviews, cbentzel+watch_chromium.org, xunjieli, agrieve+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Cronet] Test the libcronet that's shipped, not libcronet_test The motivation is two-fold: 1. It's always best to test what you ship. 2. This facilitates testing an implementation (libcronet) loaded by other means, rather than forcing testing to replace the implementation in an artificial manner (e.g. substituting libcronet_test for libcronet). Previously libcronet_test contained both Cronet and the tests, so it could be tested without libcronet. Now libcronet contains Cronet and the tests are contained within libcronet_test. During testing libcronet and libcronet_test are loaded. This presents some complications because libcronet exposes no symbols so direct native testing is not possible (there are no symbols to call), but this is easily addressed: Most testing just involves actuating the Cronet API (we've good encapsulation boundaries) and what native components need to be accessed can be accessed through a couple simple @hide JNI APIs, namely CronetUrlRequestContext.getUrlRequestContextAdapter and CronetUrlRequest.getUrlRequestAdapterForTesting. There are a few static data items that cannot be directly manipulated within libcronet and required some additional changes for testing: 1. URLRequestFilter - A few tests registered URLRequest interceptors with URLRequestFilter. This was remedied by inserting a URLRequestInterceptingJobFactory into the URLRequestContext under test. The URLRequestInterceptingJobFactory delegates to libcronet_test's URLRequestFilter so interceptors work like normal. 2. NetworkChangeNotifier - I rewrote NetworkChangeNotifierTest to perform a more comprehensive system integration test that did not require direct native manipulation, and instead used pre-existing Java testing APIs. 3. MessageLoop and ThreadTaskRunnerHandle - When libcronet_test code (e.g. URLRequestInterceptors) are run on libcronet's network threads they cannot access MessageLoop::current() and ThreadTaskRunnerHandle::Get() as they're static and, like all static data, are not shared between libcronet and libcronet_test. To remedy this I simply instantiate a MessageLoop in libcronet_test via CronetTestUtil.PrepareNetworkThread(), and set it to use libcronet's SingleThreadTaskRunner. TestUploadDataStreamHandler was also slightly modified to run on a thread from libcronet rather than create its own thread. This way there was a MessageLoop and ThreadTaskRunnerHandle already accessible to libcronet native code. BUG=629299 Committed: https://crrev.com/fd031f17d903f22300f08f46610e1f6418275708 Cr-Commit-Position: refs/heads/master@{#433525}

Patch Set 1 #

Patch Set 2 : fix deps #

Patch Set 3 : fix build file #

Patch Set 4 : fix #

Patch Set 5 : fixes #

Patch Set 6 : fix jni load #

Patch Set 7 : lots of fixes #

Patch Set 8 : get working #

Patch Set 9 : almost fix testDestroyNativeStreamBeforeReadComplete #

Patch Set 10 : get all test passing #

Patch Set 11 : fix build #

Patch Set 12 : more fix #

Patch Set 13 : cleanup #

Patch Set 14 : more cleanup #

Patch Set 15 : more cleanup #

Patch Set 16 : more comments #

Patch Set 17 : fix perf test #

Total comments: 13

Patch Set 18 : Clean up phase 1 of 2: use network thread directly #

Patch Set 19 : cleanup (still more to come) #

Patch Set 20 : cleanup (still more to come) #

Patch Set 21 : Clean up phase 2 of 2: remove staticness (still more cleanup to come) #

Patch Set 22 : some comments #

Patch Set 23 : fixes #

Total comments: 16

Patch Set 24 : address Helen's comments #

Total comments: 12

Patch Set 25 : address Helen's comments #

Patch Set 26 : address two remaining comments #

Total comments: 21

Patch Set 27 : rebase #

Patch Set 28 : fix rebase #

Patch Set 29 : address Misha's comments #

Patch Set 30 : fix shutdown race #

Unified diffs Side-by-side diffs Delta from patch set Stats (+462 lines, -254 lines) Patch
M components/cronet/android/BUILD.gn View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 7 chunks +15 lines, -7 lines 0 comments Download
M components/cronet/android/cronet_url_request_adapter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +3 lines, -2 lines 0 comments Download
M components/cronet/android/cronet_url_request_adapter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +0 lines, -4 lines 0 comments Download
M components/cronet/android/cronet_url_request_context_adapter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 chunks +3 lines, -0 lines 0 comments Download
M components/cronet/android/test/cronet_test_jni.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 4 chunks +13 lines, -9 lines 0 comments Download
M components/cronet/android/test/cronet_test_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 1 chunk +40 lines, -1 line 0 comments Download
M components/cronet/android/test/cronet_test_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +81 lines, -6 lines 0 comments Download
M components/cronet/android/test/javaperftests/src/org/chromium/net/CronetPerfTestActivity.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 1 chunk +1 line, -1 line 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/CronetTestBase.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 chunk +2 lines, -0 lines 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/CronetUploadTest.java View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 13 chunks +22 lines, -28 lines 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 chunks +3 lines, -1 line 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +76 lines, -10 lines 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/UploadDataProvidersTest.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 3 chunks +3 lines, -1 line 0 comments Download
M components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 7 chunks +10 lines, -3 lines 0 comments Download
M components/cronet/android/test/mock_url_request_job_factory.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2 chunks +73 lines, -1 line 0 comments Download
D components/cronet/android/test/network_change_notifier_util.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -16 lines 0 comments Download
D components/cronet/android/test/network_change_notifier_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -70 lines 0 comments Download
M components/cronet/android/test/sdch_test_util.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 4 chunks +7 lines, -16 lines 0 comments Download
M components/cronet/android/test/src/org/chromium/net/CronetTestFramework.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 1 chunk +0 lines, -2 lines 0 comments Download
M components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 3 chunks +21 lines, -9 lines 0 comments Download
M components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 3 chunks +20 lines, -3 lines 0 comments Download
D components/cronet/android/test/src/org/chromium/net/NetworkChangeNotifierUtil.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +0 lines, -19 lines 0 comments Download
M components/cronet/android/test/src/org/chromium/net/TestUploadDataStreamHandler.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 5 chunks +13 lines, -4 lines 0 comments Download
M components/cronet/android/test/test_upload_data_stream_handler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 3 chunks +4 lines, -3 lines 0 comments Download
M components/cronet/android/test/test_upload_data_stream_handler.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 11 chunks +28 lines, -32 lines 0 comments Download
M net/url_request/url_request_intercepting_job_factory.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2 chunks +9 lines, -2 lines 0 comments Download
M net/url_request/url_request_intercepting_job_factory.cc View 1 2 3 4 5 6 1 chunk +14 lines, -3 lines 0 comments Download

Messages

Total messages: 40 (12 generated)
pauljensen
Helen & Andrei (Andrei suggested having both of you review), PTAL, thank you! This change ...
4 years, 2 months ago (2016-10-19 19:13:59 UTC) #5
kapishnikov
The solution is nice and very creative. My only concern is that we introduce a ...
4 years, 2 months ago (2016-10-20 17:25:46 UTC) #7
pauljensen
https://codereview.chromium.org/2406273002/diff/320001/components/cronet/android/test/cronet_test_jni.cc File components/cronet/android/test/cronet_test_jni.cc (right): https://codereview.chromium.org/2406273002/diff/320001/components/cronet/android/test/cronet_test_jni.cc#newcode51 components/cronet/android/test/cronet_test_jni.cc:51: if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) || On 2016/10/20 17:25:46, kapishnikov wrote: ...
4 years, 2 months ago (2016-10-21 02:27:33 UTC) #8
pauljensen
I'm working on a new patch-set that cleans up a lot of things.
4 years, 2 months ago (2016-10-23 03:26:39 UTC) #9
xunjieli
On 2016/10/23 03:26:39, pauljensen wrote: > I'm working on a new patch-set that cleans up ...
4 years, 1 month ago (2016-10-24 13:28:58 UTC) #10
pauljensen
Ok, PTAL, I think I'm done with the cleanup. My idea to friend the adapter ...
4 years, 1 month ago (2016-10-24 18:52:53 UTC) #12
kapishnikov
Thanks for getting rid of static members and the hopping between Java and C. The ...
4 years, 1 month ago (2016-10-24 21:17:34 UTC) #13
pauljensen
load_flags() and task_runner() are functions in net/ not Cronet. libcronet and libcronet_test both have copies ...
4 years, 1 month ago (2016-10-24 22:06:06 UTC) #14
pauljensen
https://codereview.chromium.org/2406273002/diff/440001/components/cronet/android/test/cronet_test_util.cc File components/cronet/android/test/cronet_test_util.cc (right): https://codereview.chromium.org/2406273002/diff/440001/components/cronet/android/test/cronet_test_util.cc#newcode24 components/cronet/android/test/cronet_test_util.cc:24: return TestUtil::getURLRequest(jurl_request_adapter)->load_flags(); On 2016/10/24 21:17:34, kapishnikov wrote: > Is ...
4 years, 1 month ago (2016-10-25 11:55:38 UTC) #15
xunjieli
This is very clever! I need to look at it a bit more. Here is ...
4 years, 1 month ago (2016-10-25 17:51:38 UTC) #16
pauljensen
https://codereview.chromium.org/2406273002/diff/440001/components/cronet/android/BUILD.gn File components/cronet/android/BUILD.gn (right): https://codereview.chromium.org/2406273002/diff/440001/components/cronet/android/BUILD.gn#newcode452 components/cronet/android/BUILD.gn:452: "//components/cronet/android/cronet_url_request_adapter.h", On 2016/10/25 17:51:38, xunjieli wrote: > Could you ...
4 years, 1 month ago (2016-10-26 17:55:18 UTC) #17
xunjieli
I think this change looks good. I still don't quite understand the MessageLoop part. If ...
4 years, 1 month ago (2016-10-27 14:49:43 UTC) #18
pauljensen
On 2016/10/27 14:49:43, xunjieli wrote: > If libcronet_tests.so grabs the TaskRunner of the CronetURLRequestContextAdapter > ...
4 years, 1 month ago (2016-10-27 18:43:26 UTC) #19
pauljensen
Oops, I forgot to address two comments, done. PTAL, thank you! https://codereview.chromium.org/2406273002/diff/460001/components/cronet/android/test/cronet_test_util.h File components/cronet/android/test/cronet_test_util.h (right): ...
4 years, 1 month ago (2016-10-28 15:24:42 UTC) #20
kapishnikov
Paul, thanks for making it happen. There are no extra comments from my side. LGTM ...
4 years, 1 month ago (2016-10-28 18:09:24 UTC) #21
xunjieli
Sorry for the delay. I was scrambling to fix some bugs earlier this week. I ...
4 years, 1 month ago (2016-10-28 22:47:49 UTC) #22
pauljensen
Ping. This has sat idle for 2 weeks now. I talked to davidben@ a bit ...
4 years, 1 month ago (2016-11-11 15:31:36 UTC) #23
xunjieli
I am deferring this to Misha.
4 years, 1 month ago (2016-11-11 16:43:33 UTC) #25
pauljensen
Ping.
4 years, 1 month ago (2016-11-15 10:18:54 UTC) #26
mef
Mostly nits and I *think* one bug. To be continued... https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn File components/cronet/android/BUILD.gn (right): https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn#newcode452 ...
4 years, 1 month ago (2016-11-16 18:45:44 UTC) #27
mef
Few more comments about naming and commenting. I think overall approach is sound. https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/test/cronet_test_util.cc File ...
4 years, 1 month ago (2016-11-16 20:01:27 UTC) #28
pauljensen
I addressed your comments, Misha, PTAL, thank you! https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn File components/cronet/android/BUILD.gn (right): https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn#newcode452 components/cronet/android/BUILD.gn:452: # ...
4 years, 1 month ago (2016-11-18 18:12:10 UTC) #29
mef
lg tm mod broken test. https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn File components/cronet/android/BUILD.gn (right): https://codereview.chromium.org/2406273002/diff/500001/components/cronet/android/BUILD.gn#newcode452 components/cronet/android/BUILD.gn:452: # While "cronet_tests" cannot ...
4 years, 1 month ago (2016-11-18 21:45:50 UTC) #30
pauljensen
On 2016/11/18 21:45:50, mef wrote: > lg tm mod broken test. I fixed the test, ...
4 years, 1 month ago (2016-11-19 02:05:41 UTC) #31
mef
lgtm
4 years, 1 month ago (2016-11-19 03:30:15 UTC) #32
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2406273002/580001
4 years, 1 month ago (2016-11-21 12:56:05 UTC) #35
commit-bot: I haz the power
Committed patchset #30 (id:580001)
4 years, 1 month ago (2016-11-21 13:53:25 UTC) #38
commit-bot: I haz the power
4 years, 1 month ago (2016-11-21 13:57:41 UTC) #40
Message was sent while issue was closed.
Patchset 30 (id:??) landed as
https://crrev.com/fd031f17d903f22300f08f46610e1f6418275708
Cr-Commit-Position: refs/heads/master@{#433525}

Powered by Google App Engine
This is Rietveld 408576698