Merge "Remove CtsInputMethodTestCases until it becomes ready." into nyc-dev
diff --git a/tests/inputmethod/Android.mk b/tests/inputmethod/Android.mk
deleted file mode 100644
index 3a90fa9..0000000
--- a/tests/inputmethod/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2015 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsInputMethodTestCases
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner android-support-test
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/inputmethod/AndroidManifest.xml b/tests/inputmethod/AndroidManifest.xml
deleted file mode 100644
index 038b164..0000000
--- a/tests/inputmethod/AndroidManifest.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-    Copyright (C) 2015 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.inputmethod.cts">
-
-    <application >
-        <uses-library android:name="android.test.runner"/>
-
-        <activity android:name="android.inputmethod.cts.TestActivity" />
-        <service android:name="android.inputmethod.cts.MockInputMethodService"
-                 android:permission="android.permission.BIND_INPUT_METHOD">
-            <intent-filter>
-                <action android:name="android.view.InputMethod" />
-            </intent-filter>
-            <meta-data android:name="android.view.im" android:resource="@xml/method" />
-        </service>
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.inputmethod.cts"
-                     android:label="Tests for the InputMethod APIs."/>
-
-</manifest>
diff --git a/tests/inputmethod/AndroidTest.xml b/tests/inputmethod/AndroidTest.xml
deleted file mode 100644
index 3a52042..0000000
--- a/tests/inputmethod/AndroidTest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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 Input test cases">
-    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
-        <option name="cleanup-apks" value="true" />
-        <option name="test-file-name" value="CtsInputMethodTestCases.apk" />
-    </target_preparer>
-    <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
-        <option name="package" value="android.inputmethod.cts" />
-    </test>
-</configuration>
\ No newline at end of file
diff --git a/tests/inputmethod/res/xml/method.xml b/tests/inputmethod/res/xml/method.xml
deleted file mode 100644
index fc2ec95..0000000
--- a/tests/inputmethod/res/xml/method.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-    Copyright (C) 2015 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.
--->
-
-<input-method xmlns:android="http://schemas.android.com/apk/res/android"
-              android:isDefault="True">
-    <subtype android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" />
-</input-method>
diff --git a/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTest.java b/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTest.java
deleted file mode 100644
index c68d448..0000000
--- a/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2015 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.inputmethod.cts;
-
-import android.annotation.NonNull;
-import android.content.pm.PackageManager;
-import android.os.IBinder;
-import android.inputmethodservice.InputMethodService;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.view.inputmethod.InputMethodManager;
-
-import java.util.List;
-
-public class InputMethodServiceTest extends InstrumentationTestCase {
-    private String mTestImeId;
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        mTestImeId = getInstrumentation().getContext().getPackageName() +
-                "/" + MockInputMethodService.class.getName();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    /**
-     * Ensures that the IME with {@code imeId} is not enabled.
-     *
-     * This method ensures that no IME with {@code imeId} is enabled. If the given IME is currently
-     * in use, switches to another IME first. Then, if the given IME is enabled, disables it.
-     */
-    private void ensureImeNotEnabled(@NonNull final String imeId) {
-        final String currentImeId =
-                InputMethodServiceTestUtil.getCurrentImeId(getInstrumentation());
-        if (currentImeId.equals(imeId)) {
-            // Requested IME is already used. This typically happens if the previous test case is
-            // not finished gracefully. In this case, selects another IME.
-            String otherImeCandidate = null;
-            final List<String> enabledImes =
-                    InputMethodServiceTestUtil.getEnabledImeIds(getInstrumentation());
-            for (final String enabledIme : enabledImes) {
-                if (!enabledIme.equals(imeId)) {
-                    otherImeCandidate = imeId;
-                    break;
-                }
-            }
-            if (otherImeCandidate == null) {
-                // When PackageManager.hasSystemFeature(PackageManager.FEATURE_INPUT_METHODS)
-                // returns true, this case must not happen.
-                throw new IllegalStateException(
-                        "No other IME is available. Unable to continue tests.");
-            }
-            assertTrue(InputMethodServiceTestUtil.setIme(getInstrumentation(), otherImeCandidate));
-        }
-
-        if (InputMethodServiceTestUtil.isImeEnabled(getInstrumentation(), imeId)) {
-            assertTrue(InputMethodServiceTestUtil.disableIme(getInstrumentation(), imeId));
-        }
-    }
-
-    /**
-     * Asserts the given service is not running.
-     */
-    private void assertServiceNotRunning() {
-        assertTrue(MockInputMethodService.getInstance() == null ||
-                MockInputMethodService.getInstance().getCallCount("onCreate") == 0);
-    }
-
-    /**
-     * This test checks the following APIs.
-     * <ul>
-     *   <li>{@link InputMethodManager#getEnabledInputMethodList()}</li>
-     *   <li>{@link InputMethodManager#getInputMethodList()}</li>
-     *   <li>{@link InputMethodManager#setInputMethod(IBinder, String)}</li>
-     *   <li>{@link InputMethodService#onCreate()}</li>
-     *   <li>{@link InputMethodService#onDestroy()}</li>
-     * </ul>
-     */
-    @MediumTest
-    public void testCreateAndDestroy() {
-        if (!getInstrumentation().getContext().getPackageManager().hasSystemFeature(
-                PackageManager.FEATURE_INPUT_METHODS)) {
-            // The "input method" system feature is not supported on this device.
-            return;
-        }
-
-        // Clear the counter in the mock service, since it might have been used in a previous test.
-        MockInputMethodService.resetCounter();
-
-        ensureImeNotEnabled(mTestImeId);
-
-        final String ImeIdToRestore =
-                InputMethodServiceTestUtil.getCurrentImeId(getInstrumentation());
-        MockInputMethodService service = MockInputMethodService.getInstance();
-        assertServiceNotRunning();
-
-        try {
-            // Enable test IME.
-            assertTrue(InputMethodServiceTestUtil.enableIme(getInstrumentation(), mTestImeId));
-            service = MockInputMethodService.getInstance();
-            assertServiceNotRunning();
-
-            // Select test IME.
-            assertTrue(InputMethodServiceTestUtil.setIme(getInstrumentation(), mTestImeId));
-            service = MockInputMethodService.getInstance();
-            assertNotNull(service);
-            assertEquals(1, MockInputMethodService.getCallCount("<init>"));
-            assertEquals(1, MockInputMethodService.getCallCount("onCreate"));
-        } finally {
-            // Restores IMEs to original one.
-            InputMethodServiceTestUtil.setIme(getInstrumentation(), ImeIdToRestore);
-            InputMethodServiceTestUtil.disableIme(getInstrumentation(), mTestImeId);
-            assertEquals(1, MockInputMethodService.getCallCount("onDestroy"));
-        }
-    }
-}
diff --git a/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTestUtil.java b/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTestUtil.java
deleted file mode 100644
index aa46c38..0000000
--- a/tests/inputmethod/src/android/inputmethod/cts/InputMethodServiceTestUtil.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2015 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.inputmethod.cts;
-
-import android.annotation.NonNull;
-import android.app.Instrumentation;
-import android.app.UiAutomation;
-import android.content.Context;
-import android.os.IBinder;
-import android.os.ParcelFileDescriptor;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.inputmethod.InputMethodInfo;
-import android.view.inputmethod.InputMethodManager;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Utility functions for testing of input method stuff.
- */
-public final class InputMethodServiceTestUtil {
-    private static final String TAG = InputMethodServiceTestUtil.class.getSimpleName();
-
-    // Prevents this from being instantiated.
-    private InputMethodServiceTestUtil() {}
-
-    @NonNull
-    private static String executeShellCommand(final UiAutomation uiAutomation, final String[] cmd) {
-        final String flattenCmd = TextUtils.join(" ", cmd);
-        List<String> output = new ArrayList<>();
-
-        try (final ParcelFileDescriptor fd = uiAutomation.executeShellCommand(flattenCmd);
-             final FileReader fr = new FileReader(fd.getFileDescriptor());
-             final BufferedReader br = new BufferedReader(fr)) {
-
-            String line;
-            while ((line = br.readLine()) != null) {
-                output.add(line);
-            }
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-
-        // The output from the "ime" command should be only one line.
-        if (output.size() != 1) {
-            throw new IllegalStateException(
-                    "The output from 'ime' command should be one line, but it outputs multiples: " +
-                    TextUtils.join("\n", output));
-        }
-        return output.get(0);
-    }
-
-    @NonNull
-    public static String getCurrentImeId(final Instrumentation inst) {
-        return Settings.Secure.getString(inst.getContext().getContentResolver(),
-                Settings.Secure.DEFAULT_INPUT_METHOD);
-    }
-
-    public static boolean isImeEnabled(final Instrumentation inst, final String imeId) {
-        final List<String> enabledImes = getEnabledImeIds(inst);
-        return enabledImes.contains(imeId);
-    }
-
-    @NonNull
-    public static List<String> getEnabledImeIds(final Instrumentation inst) {
-        InputMethodManager imm = (InputMethodManager) inst.getContext().getSystemService(
-                Context.INPUT_METHOD_SERVICE);
-        final List<InputMethodInfo> enabledImes = imm.getEnabledInputMethodList();
-        List<String> result = new ArrayList<>();
-        for (final InputMethodInfo enabledIme : enabledImes) {
-            result.add(enabledIme.getId());
-        }
-        return result;
-    }
-
-    /**
-     * Puts the specified IME into the available input method list.
-     *
-     * This operation will be done synchronously in "ime" command using
-     * {@link com.android.server.InputMethodManagerService#setInputMethodEnabled(String, boolean)},
-     * which is synchronous.
-     *
-     * @param imeId IME ID to be enabled.
-     * @return {@code true} if the target IME gets enabled successfully. {@code false} if failed.
-     */
-    public static boolean enableIme(final Instrumentation inst, final String imeId) {
-        // Needs to check the output message from the checking command, since executeShellCommand()
-        // does not pass the exit status code back to the test.
-        final String output = executeShellCommand(
-                inst.getUiAutomation(), new String[]{"ime", "enable", imeId});
-        final String expectedOutput = "Input method " + imeId + ": now enabled";
-        if (!output.equals(expectedOutput)) {
-            Log.e(TAG, "Unexpected output message. Expected: " + expectedOutput +
-                    ", Actual: " + output);
-            return false;
-        }
-
-        final InputMethodManager imm = (InputMethodManager) inst.getContext().getSystemService(
-                Context.INPUT_METHOD_SERVICE);
-        final List<InputMethodInfo> enabledInputMethods = imm.getEnabledInputMethodList();
-        for (final InputMethodInfo imi : enabledInputMethods) {
-            if (imi.getId().equals(imeId))
-                return true;
-        }
-
-        Log.e(TAG, "Failed to enable the given IME (IME ID: " + imeId + ").");
-        return false;
-    }
-
-    /**
-     * Removes the specified IME from the available input method list.
-     *
-     * This operation will {@code @NonNull} final be done synchronously in "ime" command using
-     * {@link com.android.server.InputMethodManagerService#setInputMethodEnabled(String, boolean)},
-     * which is synchronous.
-     *
-     * @param imeId IME ID to be disabled.
-     * @return {@code true} if the target IME gets disabled successfully. {@code false} if failed.
-     */
-    public static boolean disableIme(final Instrumentation inst, final String imeId) {
-        // Needs to check the output message from the checking command, since executeShellCommand()
-        // does not pass the exit status code back to the test.
-        final String output = executeShellCommand(
-                inst.getUiAutomation(), new String[]{"ime", "disable", imeId});
-        final String expectedOutput = "Input method " + imeId + ": now disabled";
-        if (!output.equals(expectedOutput)) {
-            Log.w(TAG, "Unexpected output message. Expected: " + expectedOutput +
-                    ", Actual: " + output);
-            return false;
-        }
-
-        final InputMethodManager imm = (InputMethodManager) inst.getContext().getSystemService(
-                Context.INPUT_METHOD_SERVICE);
-        final List<InputMethodInfo> enabledInputMethods = imm.getEnabledInputMethodList();
-        for (final InputMethodInfo imi : enabledInputMethods) {
-            if (imi.getId().equals(imeId)) {
-                Log.e(TAG, "Failed to disable the given IME (IME ID: " + imeId + ").");
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Switches to the specified IME.
-     *
-     * This operation will be done synchronously in the "ime" command using
-     * {@link InputMethodManager#setInputMethod(IBinder, String)}, which is synchronous.
-     *
-     * @param imeId IME ID to be switched to.
-     * @return {@code true} if the target IME gets active successfully. {@code false} if failed.
-     */
-    public static boolean setIme(final Instrumentation inst, final String imeId) {
-        // Needs to check the output message from the checking command, since executeShellCommand()
-        // does not pass the exit status code back to the test.
-        final String output = executeShellCommand(
-                inst.getUiAutomation(), new String[]{"ime", "set", imeId});
-        final String expectedOutput = "Input method " + imeId + " selected";
-        if (!output.equals(expectedOutput)) {
-            Log.w(TAG, "Unexpected output message. Expected: " + expectedOutput +  ", Actual: " +
-                    output);
-            return false;
-        }
-
-        final String currentImeId = getCurrentImeId(inst);
-        if (!TextUtils.equals(currentImeId, imeId)) {
-            Log.e(TAG, "Failed to switch the current IME. Expected: " + imeId +  ", Actual: " +
-                    currentImeId);
-            return false;
-        }
-
-        return true;
-    }
-}
diff --git a/tests/inputmethod/src/android/inputmethod/cts/MockInputMethodService.java b/tests/inputmethod/src/android/inputmethod/cts/MockInputMethodService.java
deleted file mode 100644
index 12b80a5..0000000
--- a/tests/inputmethod/src/android/inputmethod/cts/MockInputMethodService.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2015 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.inputmethod.cts;
-
-import android.annotation.NonNull;
-import android.annotation.Nullable;
-import android.inputmethodservice.InputMethodService;
-
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * A mock implementation of {@link InputMethodService} for testing purpose.
- */
-public class MockInputMethodService extends InputMethodService {
-    private static AtomicReference<MockInputMethodService> sCurrentInstance =
-            new AtomicReference<>();
-    private static final HashMap<String, Integer> mCallCounter = new HashMap<>();
-
-    /**
-     * @return The instance of {@code MockInputMethodService}. If the service has not been created
-     * yet or already been destroyed, returns {@code null}.
-     */
-    @Nullable
-    public static MockInputMethodService getInstance() {
-        return sCurrentInstance.get();
-    }
-
-    public static void resetCounter() {
-        synchronized (mCallCounter) {
-            mCallCounter.clear();
-        }
-    }
-
-    private static void incrementCallCount(@NonNull final String methodName) {
-        synchronized (mCallCounter) {
-            if (!mCallCounter.containsKey(methodName)) {
-                mCallCounter.put(methodName, 0);
-            }
-            mCallCounter.put(methodName, mCallCounter.get(methodName) + 1);
-        }
-    }
-
-    public static int getCallCount(@NonNull final String methodName) {
-        synchronized (mCallCounter) {
-            if (!mCallCounter.containsKey(methodName)) {
-                return 0;
-            }
-            return mCallCounter.get(methodName);
-        }
-    }
-
-    public MockInputMethodService() {
-        incrementCallCount("<init>");
-    }
-
-    @Override
-    public void onCreate() {
-        if (!sCurrentInstance.compareAndSet(null, this)) {
-            throw new IllegalStateException("New MockInputMethodService instance is being created "
-                    + "before the existing instance is destroyed.");
-        }
-
-        super.onCreate();
-        incrementCallCount("onCreate");
-    }
-
-    @Override
-    public void onDestroy() {
-        sCurrentInstance.lazySet(null);
-        super.onDestroy();
-        incrementCallCount("onDestroy");
-    }
-}
-