Merge changes I54d367fd,Ib789dc59 am: aa257b1449
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2388907 Change-Id: I75614eeb4348d5d3220aba67c4c3a9216f2eb8dd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,10 +26,28 @@ cronet_test_java_defaults = "CronetTestJavaDefaultsDisabled"
|
|||||||
// as cronet_test_java_defaults may have different values
|
// as cronet_test_java_defaults may have different values
|
||||||
// depending on the branch
|
// depending on the branch
|
||||||
|
|
||||||
|
java_defaults {
|
||||||
|
name: "CronetTestJavaDefaultsEnabled",
|
||||||
|
enabled: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
java_defaults {
|
||||||
|
name: "CronetTestJavaDefaultsDisabled",
|
||||||
|
enabled: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
java_defaults {
|
||||||
|
name: "CronetTestJavaDefaults",
|
||||||
|
defaults: [cronet_test_java_defaults],
|
||||||
|
}
|
||||||
|
|
||||||
android_test {
|
android_test {
|
||||||
name: "CtsNetHttpTestCases",
|
name: "CtsNetHttpTestCases",
|
||||||
compile_multilib: "both", // Include both the 32 and 64 bit versions
|
compile_multilib: "both", // Include both the 32 and 64 bit versions
|
||||||
defaults: ["cts_defaults"],
|
defaults: [
|
||||||
|
"CronetTestJavaDefaults",
|
||||||
|
"cts_defaults",
|
||||||
|
],
|
||||||
sdk_version: "test_current",
|
sdk_version: "test_current",
|
||||||
srcs: [
|
srcs: [
|
||||||
"src/**/*.java",
|
"src/**/*.java",
|
||||||
@@ -47,7 +65,7 @@ android_test {
|
|||||||
"android.test.base",
|
"android.test.base",
|
||||||
"android.test.mock",
|
"android.test.mock",
|
||||||
"androidx.annotation_annotation",
|
"androidx.annotation_annotation",
|
||||||
"framework-cronet",
|
"framework-tethering",
|
||||||
"org.apache.http.legacy",
|
"org.apache.http.legacy",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
<application android:networkSecurityConfig="@xml/network_security_config">
|
<application android:networkSecurityConfig="@xml/network_security_config">
|
||||||
<uses-library android:name="android.test.runner"/>
|
<uses-library android:name="android.test.runner"/>
|
||||||
<uses-library android:name="framework-cronet"/>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<instrumentation
|
<instrumentation
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.http.HttpEngine;
|
||||||
|
import android.net.http.UrlRequest;
|
||||||
|
import android.net.http.UrlRequest.Status;
|
||||||
|
import android.net.http.UrlResponseInfo;
|
||||||
import android.net.http.cts.util.CronetCtsTestServer;
|
import android.net.http.cts.util.CronetCtsTestServer;
|
||||||
import android.net.http.cts.util.TestStatusListener;
|
import android.net.http.cts.util.TestStatusListener;
|
||||||
import android.net.http.cts.util.TestUrlRequestCallback;
|
import android.net.http.cts.util.TestUrlRequestCallback;
|
||||||
@@ -31,10 +35,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.test.platform.app.InstrumentationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import org.chromium.net.CronetEngine;
|
|
||||||
import org.chromium.net.UrlRequest;
|
|
||||||
import org.chromium.net.UrlRequest.Status;
|
|
||||||
import org.chromium.net.UrlResponseInfo;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -44,7 +44,7 @@ import org.junit.runner.RunWith;
|
|||||||
public class CronetUrlRequestTest {
|
public class CronetUrlRequestTest {
|
||||||
private static final String TAG = CronetUrlRequestTest.class.getSimpleName();
|
private static final String TAG = CronetUrlRequestTest.class.getSimpleName();
|
||||||
|
|
||||||
@NonNull private CronetEngine mCronetEngine;
|
@NonNull private HttpEngine mHttpEngine;
|
||||||
@NonNull private TestUrlRequestCallback mCallback;
|
@NonNull private TestUrlRequestCallback mCallback;
|
||||||
@NonNull private ConnectivityManager mCm;
|
@NonNull private ConnectivityManager mCm;
|
||||||
@NonNull private CronetCtsTestServer mTestServer;
|
@NonNull private CronetCtsTestServer mTestServer;
|
||||||
@@ -53,19 +53,19 @@ public class CronetUrlRequestTest {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||||
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
CronetEngine.Builder builder = new CronetEngine.Builder(context);
|
HttpEngine.Builder builder = new HttpEngine.Builder(context);
|
||||||
builder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
|
builder.setEnableHttpCache(HttpEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
|
||||||
.enableHttp2(true)
|
.setEnableHttp2(true)
|
||||||
// .enableBrotli(true)
|
// .setEnableBrotli(true)
|
||||||
.enableQuic(true);
|
.setEnableQuic(true);
|
||||||
mCronetEngine = builder.build();
|
mHttpEngine = builder.build();
|
||||||
mCallback = new TestUrlRequestCallback();
|
mCallback = new TestUrlRequestCallback();
|
||||||
mTestServer = new CronetCtsTestServer(context);
|
mTestServer = new CronetCtsTestServer(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
mCronetEngine.shutdown();
|
mHttpEngine.shutdown();
|
||||||
mTestServer.shutdown();
|
mTestServer.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class CronetUrlRequestTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UrlRequest buildUrlRequest(String url) {
|
private UrlRequest buildUrlRequest(String url) {
|
||||||
return mCronetEngine.newUrlRequestBuilder(url, mCallback, mCallback.getExecutor()).build();
|
return mHttpEngine.newUrlRequestBuilder(url, mCallback, mCallback.getExecutor()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package android.net.http.cts.util
|
package android.net.http.cts.util
|
||||||
|
|
||||||
|
import android.net.http.UrlRequest.StatusListener
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import org.chromium.net.UrlRequest.StatusListener
|
|
||||||
import org.junit.Assert.assertSame
|
import org.junit.Assert.assertSame
|
||||||
|
|
||||||
private const val TIMEOUT_MS = 12000L
|
private const val TIMEOUT_MS = 12000L
|
||||||
|
|||||||
@@ -24,15 +24,14 @@ import static org.junit.Assert.assertSame;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import android.net.http.CallbackException;
|
||||||
|
import android.net.http.HttpException;
|
||||||
|
import android.net.http.InlineExecutionProhibitedException;
|
||||||
|
import android.net.http.UrlRequest;
|
||||||
|
import android.net.http.UrlResponseInfo;
|
||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
|
|
||||||
import org.chromium.net.CallbackException;
|
|
||||||
import org.chromium.net.CronetException;
|
|
||||||
import org.chromium.net.InlineExecutionProhibitedException;
|
|
||||||
import org.chromium.net.UrlRequest;
|
|
||||||
import org.chromium.net.UrlResponseInfo;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@@ -50,7 +49,7 @@ public class TestUrlRequestCallback extends UrlRequest.Callback {
|
|||||||
public ArrayList<UrlResponseInfo> mRedirectResponseInfoList = new ArrayList<>();
|
public ArrayList<UrlResponseInfo> mRedirectResponseInfoList = new ArrayList<>();
|
||||||
public ArrayList<String> mRedirectUrlList = new ArrayList<>();
|
public ArrayList<String> mRedirectUrlList = new ArrayList<>();
|
||||||
public UrlResponseInfo mResponseInfo;
|
public UrlResponseInfo mResponseInfo;
|
||||||
public CronetException mError;
|
public HttpException mError;
|
||||||
|
|
||||||
public ResponseStep mResponseStep = ResponseStep.NOTHING;
|
public ResponseStep mResponseStep = ResponseStep.NOTHING;
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ public class TestUrlRequestCallback extends UrlRequest.Callback {
|
|||||||
// Signaled on each step when mAutoAdvance is false.
|
// Signaled on each step when mAutoAdvance is false.
|
||||||
private final ConditionVariable mStepBlock = new ConditionVariable();
|
private final ConditionVariable mStepBlock = new ConditionVariable();
|
||||||
|
|
||||||
// Executor Service for Cronet callbacks.
|
// Executor Service for Http callbacks.
|
||||||
private final ExecutorService mExecutorService;
|
private final ExecutorService mExecutorService;
|
||||||
private Thread mExecutorThread;
|
private Thread mExecutorThread;
|
||||||
|
|
||||||
@@ -349,7 +348,7 @@ public class TestUrlRequestCallback extends UrlRequest.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(UrlRequest request, UrlResponseInfo info, CronetException error) {
|
public void onFailed(UrlRequest request, UrlResponseInfo info, HttpException error) {
|
||||||
// If the failure is because of prohibited direct execution, the test shouldn't fail
|
// If the failure is because of prohibited direct execution, the test shouldn't fail
|
||||||
// since the request already did.
|
// since the request already did.
|
||||||
if (error.getCause() instanceof InlineExecutionProhibitedException) {
|
if (error.getCause() instanceof InlineExecutionProhibitedException) {
|
||||||
|
|||||||
Reference in New Issue
Block a user