cronet: Copy configuration for CTS from //cts/tests/test

This allows us to separate the mainline's module's test from
the rest of CTS

Test: atest CtsCronetTestCases
Bug: 251012627
Change-Id: I3a2f2ae93c05c59b00ce877e2d8572233ae64e14
diff --git a/Cronet/TEST_MAPPING b/Cronet/TEST_MAPPING
index 815d496..b1f3088 100644
--- a/Cronet/TEST_MAPPING
+++ b/Cronet/TEST_MAPPING
@@ -1,7 +1,7 @@
 {
-  "postsubmit": [
+  "presubmit": [
     {
-      "name": "CronetApiTest"
+      "name": "CtsCronetTestCases"
     }
   ]
 }
diff --git a/Cronet/tests/cts/Android.bp b/Cronet/tests/cts/Android.bp
index e71c707..56f3ddb 100644
--- a/Cronet/tests/cts/Android.bp
+++ b/Cronet/tests/cts/Android.bp
@@ -18,12 +18,16 @@
     default_applicable_licenses: ["Android-Apache-2.0"],
 }
 
-java_library {
-    name: "CronetApiCommonTests",
+android_test {
+    name: "CtsCronetTestCases",
+    compile_multilib: "both", // Include both the 32 and 64 bit versions
+    defaults: ["cts_defaults"],
+    sdk_version: "test_current",
     srcs: ["src/**/*.java"],
     static_libs: [
         "androidx.test.rules",
         "androidx.core_core",
+        "ctstestrunner-axt",
         "junit",
     ],
     libs: [
@@ -33,14 +37,11 @@
         "androidx.annotation_annotation",
         "framework-cronet",
     ],
-}
 
-android_test {
-    name: "CronetApiTest",
-    sdk_version: "test_current",
-    test_suites: ["device-tests"],
-    certificate: "platform",
-    static_libs: [
-        "CronetApiCommonTests",
+    // Tag this as a cts test artifact
+    test_suites: [
+        "cts",
+        "general-tests",
+        "mts-tethering"
     ],
 }
diff --git a/Cronet/tests/cts/AndroidManifest.xml b/Cronet/tests/cts/AndroidManifest.xml
index db0f0b3..6797586 100644
--- a/Cronet/tests/cts/AndroidManifest.xml
+++ b/Cronet/tests/cts/AndroidManifest.xml
@@ -18,18 +18,21 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="org.chromium.net.test">
+          package="android.cronet.cts">
 
     <uses-permission android:name="android.permission.INTERNET"/>
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 
-    <application>
-        <uses-library android:name="android.test.runner" />
-        <uses-library android:name="framework-cronet" />
+    <application android:usesCleartextTraffic="true">
+        <uses-library android:name="android.test.runner"/>
+        <uses-library android:name="framework-cronet"/>
     </application>
 
     <instrumentation
         android:name="androidx.test.runner.AndroidJUnitRunner"
-        android:targetPackage="org.chromium.net.test"
-        android:label="Cronet API Networking Tests" />
-</manifest>
\ No newline at end of file
+        android:targetPackage="android.cronet.cts"
+        android:label="CTS tests of android.cronet">
+        <meta-data android:name="listener"
+                   android:value="com.android.cts.runner.CtsTestRunListener"/>
+    </instrumentation>
+</manifest>
diff --git a/Cronet/tests/cts/AndroidTest.xml b/Cronet/tests/cts/AndroidTest.xml
new file mode 100644
index 0000000..3ab60e4
--- /dev/null
+++ b/Cronet/tests/cts/AndroidTest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2019 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.
+  -->
+<configuration description="Config for CTS Cronet test cases">
+    <option name="test-suite-tag" value="cts" />
+    <option name="config-descriptor:metadata" key="component" value="networking" />
+    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
+    <option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
+    <option name="config-descriptor:metadata" key="parameter" value="secondary_user" />
+    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+        <option name="cleanup-apks" value="true" />
+        <option name="test-file-name" value="CtsCronetTestCases.apk" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+        <option name="package" value="android.cronet.cts" />
+        <option name="runtime-hint" value="10s" />
+    </test>
+
+    <!-- Only run CtsCronetTestcasess in MTS if the Tethering Mainline module is installed. -->
+    <object type="module_controller"
+            class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+        <option name="mainline-module-package-name" value="com.google.android.tethering" />
+    </object>
+</configuration>
diff --git a/Cronet/tests/cts/OWNERS b/Cronet/tests/cts/OWNERS
new file mode 100644
index 0000000..acb6ee6
--- /dev/null
+++ b/Cronet/tests/cts/OWNERS
@@ -0,0 +1,8 @@
+# Bug component: 31808
+
+set noparent
+file:platform/packages/modules/Connectivity:master:/OWNERS_core_networking_xts
+
+# TODO: Temp ownership to develop cronet CTS
+colibie@google.com #{LAST_RESORT_SUGGESTION}
+prohr@google.com #{LAST_RESORT_SUGGESTION}