| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |