<?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.
  -->

<configuration description="Config for CTS InputMethodFramework Installation test cases (formerly hostside tests)">
    <option name="test-suite-tag" value="cts" />
    <option name="config-descriptor:metadata" key="component" value="inputmethod" />
    <option name="config-descriptor:metadata" key="parameter" value="all_foldable_states" />
    <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
    <option name="config-descriptor:metadata" key="parameter" value="not_secondary_user" />
    <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" />
    <option name="config-descriptor:metadata" key="parameter" value="run_on_sdk_sandbox" />

    <object class="com.android.tradefed.testtype.suite.module.DeviceFeatureModuleController"
            type="module_controller">
        <option name="required-feature" value="android.software.input_methods" />
    </object>

    <!-- Create place to store apks -->
    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="run-command" value="mkdir -p /data/local/tmp/cts/inputmethod/" />
        <option name="teardown-command" value="rm -rf /data/local/tmp/cts"/>
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true" />
        <!--
            MockIME always needs to be installed as a full package, even when CTS is running
            for instant apps.
        -->
        <option name="force-install-mode" value="FULL"/>
        <option name="test-file-name" value="CtsMockInputMethod.apk" />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true" />
        <option name="force-install-mode" value="FULL"/>
        <option name="test-file-name" value="CtsInputMethodInstallTestCases.apk" />
    </target_preparer>

    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
        <option name="cleanup" value="true" />
        <!--
            CtsInputMethod1 should not always be installed, but the apk must be
            available.
        -->
        <option name="push" value="CtsInputMethod1.apk->/data/local/tmp/cts/inputmethod/CtsInputMethod1.apk" />
        <option name="push" value="CtsInputMethod2.apk->/data/local/tmp/cts/inputmethod/CtsInputMethod2.apk" />
    </target_preparer>
    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
        <option name="cleanup-apks" value="true" />
        <!--
            In order to simulate the scenario where the IME client process is normally
            installed, explicitly set false here.  Otherwise, the test APP will be installed under
            force-queryable mode, which makes the test useless.
        -->
        <option name="force-queryable" value="false" />
        <option name="test-file-name" value="CtsInputMethodStandaloneTestApp.apk" />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
        <option name="run-command" value="input keyevent KEYCODE_WAKEUP" />
        <option name="run-command" value="wm dismiss-keyguard" />
    </target_preparer>

    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
        <option name="package" value="android.view.inputmethod.cts.installtests" />
        <option name="runtime-hint" value="1m" />
    </test>
</configuration>