Reland "Cronet: add test server"
This reverts commit a0fdf1e70ea30b16c26f80143d8af9ed60c6b33f.
Reason for revert: Should work now after aosp/2314940
Also removes usage of the added test server
Test: atest CtsCronetTestCases
Change-Id: I1cde8ab8205c7ed12ce97ba6e9580c9b8c333053
diff --git a/Cronet/tests/cts/Android.bp b/Cronet/tests/cts/Android.bp
index 56f3ddb..d10c68c 100644
--- a/Cronet/tests/cts/Android.bp
+++ b/Cronet/tests/cts/Android.bp
@@ -23,11 +23,15 @@
compile_multilib: "both", // Include both the 32 and 64 bit versions
defaults: ["cts_defaults"],
sdk_version: "test_current",
- srcs: ["src/**/*.java"],
+ srcs: [
+ "src/**/*.java",
+ "src/**/*.kt",
+ ],
static_libs: [
"androidx.test.rules",
"androidx.core_core",
"ctstestrunner-axt",
+ "ctstestserver",
"junit",
],
libs: [
@@ -36,6 +40,7 @@
"android.test.mock",
"androidx.annotation_annotation",
"framework-cronet",
+ "org.apache.http.legacy",
],
// Tag this as a cts test artifact
diff --git a/Cronet/tests/cts/AndroidManifest.xml b/Cronet/tests/cts/AndroidManifest.xml
index 70acb0d..5a92dea 100644
--- a/Cronet/tests/cts/AndroidManifest.xml
+++ b/Cronet/tests/cts/AndroidManifest.xml
@@ -23,7 +23,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <application android:usesCleartextTraffic="true">
+ <application android:networkSecurityConfig="@xml/network_security_config">
<uses-library android:name="android.test.runner"/>
<uses-library android:name="framework-cronet"/>
</application>
diff --git a/Cronet/tests/cts/assets/html/hello_world.html b/Cronet/tests/cts/assets/html/hello_world.html
new file mode 100644
index 0000000..ea62ce2
--- /dev/null
+++ b/Cronet/tests/cts/assets/html/hello_world.html
@@ -0,0 +1,24 @@
+<!--
+ ~ Copyright (C) 2022 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<html>
+<head>
+ <title>hello world</title>
+</head>
+<body>
+<h3>hello world</h3><br>
+</body>
+</html>
\ No newline at end of file
diff --git a/Cronet/tests/cts/res/xml/network_security_config.xml b/Cronet/tests/cts/res/xml/network_security_config.xml
new file mode 100644
index 0000000..7d7530b
--- /dev/null
+++ b/Cronet/tests/cts/res/xml/network_security_config.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ Copyright (C) 2022 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<network-security-config>
+ <domain-config cleartextTrafficPermitted="true">
+ <domain includeSubdomains="true">localhost</domain>
+ </domain-config>
+</network-security-config>
\ No newline at end of file
diff --git a/Cronet/tests/cts/src/android/net/http/cts/util/CronetCtsTestServer.kt b/Cronet/tests/cts/src/android/net/http/cts/util/CronetCtsTestServer.kt
new file mode 100644
index 0000000..3ccb571
--- /dev/null
+++ b/Cronet/tests/cts/src/android/net/http/cts/util/CronetCtsTestServer.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.http.cts.util
+
+import android.content.Context
+import android.webkit.cts.CtsTestServer
+
+/** Extends CtsTestServer to handle POST requests and other cronet specific test requests */
+class CronetCtsTestServer(context: Context) : CtsTestServer(context) {
+
+ val successUrl: String = getAssetUrl("html/hello_world.html")
+}