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

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java

Issue 2406273002: [Cronet] Test the libcronet that's shipped, not libcronet_test (Closed)
Patch Set: fix perf test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import android.os.ConditionVariable; 7 import android.os.ConditionVariable;
8 import android.os.StrictMode; 8 import android.os.StrictMode;
9 import android.test.MoreAsserts; 9 import android.test.MoreAsserts;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
(...skipping 28 matching lines...) Expand all
39 private static final String TEST_URL = "http://127.0.0.1:8000"; 39 private static final String TEST_URL = "http://127.0.0.1:8000";
40 40
41 private CronetTestFramework mTestFramework; 41 private CronetTestFramework mTestFramework;
42 42
43 @Override 43 @Override
44 protected void setUp() throws Exception { 44 protected void setUp() throws Exception {
45 super.setUp(); 45 super.setUp();
46 mTestFramework = startCronetTestFramework(); 46 mTestFramework = startCronetTestFramework();
47 assertTrue(NativeTestServer.startNativeTestServer(getContext())); 47 assertTrue(NativeTestServer.startNativeTestServer(getContext()));
48 // Add url interceptors after native application context is initialized. 48 // Add url interceptors after native application context is initialized.
49 MockUrlRequestJobFactory.setUp(); 49 MockUrlRequestJobFactory.setUp(mTestFramework.mCronetEngine);
50 } 50 }
51 51
52 @Override 52 @Override
53 protected void tearDown() throws Exception { 53 protected void tearDown() throws Exception {
54 MockUrlRequestJobFactory.shutdown();
54 NativeTestServer.shutdownNativeTestServer(); 55 NativeTestServer.shutdownNativeTestServer();
55 mTestFramework.mCronetEngine.shutdown(); 56 mTestFramework.mCronetEngine.shutdown();
56 super.tearDown(); 57 super.tearDown();
57 } 58 }
58 59
59 private TestUrlRequestCallback startAndWaitForComplete(String url) throws Ex ception { 60 private TestUrlRequestCallback startAndWaitForComplete(String url) throws Ex ception {
60 TestUrlRequestCallback callback = new TestUrlRequestCallback(); 61 TestUrlRequestCallback callback = new TestUrlRequestCallback();
61 // Create request. 62 // Create request.
62 UrlRequest.Builder builder = new UrlRequest.Builder( 63 UrlRequest.Builder builder = new UrlRequest.Builder(
63 url, callback, callback.getExecutor(), mTestFramework.mCronetEng ine); 64 url, callback, callback.getExecutor(), mTestFramework.mCronetEng ine);
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int end) { 2018 private String bufferContentsToString(ByteBuffer byteBuffer, int start, int end) {
2018 // Use a duplicate to avoid modifying byteBuffer. 2019 // Use a duplicate to avoid modifying byteBuffer.
2019 ByteBuffer duplicate = byteBuffer.duplicate(); 2020 ByteBuffer duplicate = byteBuffer.duplicate();
2020 duplicate.position(start); 2021 duplicate.position(start);
2021 duplicate.limit(end); 2022 duplicate.limit(end);
2022 byte[] contents = new byte[duplicate.remaining()]; 2023 byte[] contents = new byte[duplicate.remaining()];
2023 duplicate.get(contents); 2024 duplicate.get(contents);
2024 return new String(contents); 2025 return new String(contents);
2025 } 2026 }
2026 } 2027 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698