Updating trusted voice test for cts v2.
Change-Id: I933fea5da42abce0a0bc457da47f1db39cc6dce0
diff --git a/hostsidetests/trustedvoice/Android.mk b/hostsidetests/trustedvoice/Android.mk
index b4639b9..9d6237f 100644
--- a/hostsidetests/trustedvoice/Android.mk
+++ b/hostsidetests/trustedvoice/Android.mk
@@ -23,10 +23,12 @@
# Must match the package name in CtsTestCaseList.mk
LOCAL_MODULE := CtsTrustedVoiceHostTestCases
-LOCAL_JAVA_LIBRARIES := old-cts-tradefed ddmlib-prebuilt tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := cts-tradefed ddmlib-prebuilt tradefed-prebuilt
LOCAL_CTS_TEST_PACKAGE := android.host.trustedvoice
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
include $(BUILD_CTS_HOST_JAVA_LIBRARY)
diff --git a/hostsidetests/trustedvoice/AndroidTest.xml b/hostsidetests/trustedvoice/AndroidTest.xml
new file mode 100644
index 0000000..835db65
--- /dev/null
+++ b/hostsidetests/trustedvoice/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?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 Trustedvoice host test cases">
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsTrustedVoiceApp.apk" />
+ </target_preparer>
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="CtsTrustedVoiceHostTestCases.jar" />
+ </test>
+</configuration>
diff --git a/hostsidetests/trustedvoice/app/Android.mk b/hostsidetests/trustedvoice/app/Android.mk
index 598fb27..7a759d8 100644
--- a/hostsidetests/trustedvoice/app/Android.mk
+++ b/hostsidetests/trustedvoice/app/Android.mk
@@ -26,6 +26,9 @@
LOCAL_PACKAGE_NAME := CtsTrustedVoiceApp
+# Tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
LOCAL_SDK_VERSION := current
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java b/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
index d075e2c..fd3c827 100644
--- a/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
+++ b/hostsidetests/trustedvoice/src/android/trustedvoice/cts/TrustedVoiceHostTest.java
@@ -16,12 +16,7 @@
package android.trustedvoice.cts;
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.testtype.IBuildReceiver;
-
import java.io.File;
import java.lang.String;
@@ -37,7 +32,7 @@
* into an APK which it then installs at runtime. TrustedVoiceActivity sets the
* FLAG_DISMISS_KEYGUARD, prints a message to Logcat and then gets uninstalled.
*/
-public class TrustedVoiceHostTest extends DeviceTestCase implements IBuildReceiver {
+public class TrustedVoiceHostTest extends DeviceTestCase {
/**
* The package name of the APK.
@@ -77,55 +72,19 @@
private static final String TEST_STRING = "TrustedVoiceTestString";
/**
- * A reference to the build.
- */
- private CtsBuildHelper mBuild;
-
- /**
- * A reference to the device under test.
- */
- private ITestDevice mDevice;
-
- @Override
- public void setBuild(IBuildInfo buildInfo) {
- // Get the build, this is used to access the APK.
- mBuild = CtsBuildHelper.createBuildHelper(buildInfo);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // Get the device, this gives a handle to run commands and install APKs.
- mDevice = getDevice();
- // Remove any previously installed versions of this APK.
- mDevice.uninstallPackage(PACKAGE);
- // Get the APK from the build.
- File app = mBuild.getTestApp(APK);
- // Install the APK on the device.
- mDevice.installPackage(app, false);
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Remove the package once complete.
- mDevice.uninstallPackage(PACKAGE);
- super.tearDown();
- }
-
- /**
* Tests the string was successfully logged to Logcat from the activity.
*
* @throws Exception
*/
public void testLogcat() throws Exception {
// Clear logcat.
- mDevice.executeAdbCommand("logcat", "-c");
+ getDevice().executeAdbCommand("logcat", "-c");
// Lock the device
- mDevice.executeShellCommand(LOCKSCREEN_COMMAND);
+ getDevice().executeShellCommand(LOCKSCREEN_COMMAND);
// Start the APK and wait for it to complete.
- mDevice.executeShellCommand(START_COMMAND);
+ getDevice().executeShellCommand(START_COMMAND);
// Dump logcat.
- String logs = mDevice.executeAdbCommand("logcat", "-v", "brief", "-d", CLASS + ":I", "*S");
+ String logs = getDevice().executeAdbCommand("logcat", "-v", "brief", "-d", CLASS + ":I", "*S");
// Search for string.
Scanner in = new Scanner(logs);
String testString = "";