<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2023 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 Cronet-unittests">
    <!-- Cronet runs on S+ -->
    <object type="module_controller"
            class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" />
    <!-- This is necessary for the APK to read/write to any file on disk. -->
    <target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer" />
    <!-- Uploading the APK to device and installing it -->
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true"/>
        <option name="test-file-name" value="cronet_net_tester_app.apk"/>
    </target_preparer>
    <!-- Push the testing data to the specified directory before running tests -->
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <!--
          Some of Cronet's unit tests require additional test files at runtime.
          Chromium's infrastructure pushes these automatically before running
          them, but Android's doesn't (or maybe it does, but we haven't yet
          figured out how to do it). With that in mind, copy this list of test
          files "known" to be needed.

          Note: We don't abort on failure to support HSUM builds
          (http://shortn/_nB4kKO4zsp). Historically, Chromium has always pushed
          test files to external storage
          (see org.chromium.net.UrlUtils#getIsolatedTestRoot,
          https://crsrc.org/c/base/test/android/javatests/src/org/chromium/base/test/util/UrlUtils.java;l=39;drc=48d6f7175422b2c969c14258f9f8d5b196c28d18),
          which points to android.os.Environment#getExternalStorageDirectory.
          On devices with multiple users, each users get its own external
          storage, under /storage/emulated/user_id. This means that we must
          know which user is running the tests. Prior to HSUM, this was always
          0, but with HSUM this is no longer the case. With the current
          architecture (pushing files from this xml file), it's impossible to
          tell which user is running the test. So, in an attempt to get this
          working, push to both places and ignore the one that fails. See
          http://b/437294013 for more info.
        -->
        <option name="abort-on-push-failure" value="false"/>

        <option name="push-file" key="testdir" value="/storage/emulated/0/chromium_tests_root/net/third_party/quiche/src/quiche/common/platform/api/testdir/" />
        <option name="push-file" key="testdir" value="/mnt/user/10/emulated/10/chromium_tests_root/net/third_party/quiche/src/quiche/common/platform/api/testdir/" />

        <option name="push-file" key="data" value="/storage/emulated/0/chromium_tests_root/net/data/" />
        <option name="push-file" key="data" value="/mnt/user/10/emulated/10/chromium_tests_root/net/data/" />

        <option name="push-file" key="anonymous_tokens" value="/storage/emulated/0/chromium_tests_root/third_party/anonymous_tokens/" />
        <option name="push-file" key="anonymous_tokens" value="/mnt/user/10/emulated/10/chromium_tests_root/third_party/anonymous_tokens/" />
    </target_preparer>
    <!-- Runs the test -->
    <test class="com.android.tradefed.testtype.HostTest">
        <option name="jar" value="net_unittests_tester.jar"/>
        <option name="set-option" value="library-to-load:net_unittests__library"/>
        <!-- Use exclude-filter once (b/342355769) has been fixed -->
        <option name="set-option" value="exclude-filter:HttpAuthNegotiateAndroidTest.GenerateAuthToken"/>
        <option name="set-option" value="exclude-filter:MerkleAuditProofDeathTest.DiesIfLeafIndexIsGreaterThanOrEqualToTreeSize"/>
        <option name="set-option" value="exclude-filter:CertNetFetcherURLRequestTest.ParallelFetchDuplicates"/>
        <option name="set-option" value="exclude-filter:DiskCacheBackendTest.SimpleDoomRecent"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.DisableCname"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.DisableCnameStandardPort"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.DisableCnameNonstandardPort"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.CnameSync"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.CnameAsync"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.ServerNotInKerberosDatabase"/>
        <option name="set-option" value="exclude-filter:HttpAuthHandlerNegotiateTest.NoKerberosCredentials"/>
        <option name="set-option" value="exclude-filter:EmbeddedTestServerTestInstantiation/EmbeddedTestServerTest#ConnectionListenerComplete/*"/>
        <option name="enable-pretty-logs" value="false" />
    </test>
</configuration>
