Merge "Added tests for when FillResponse authentication dialog is canceled." into oc-dev
diff --git a/apps/CameraITS/pymodules/its/device.py b/apps/CameraITS/pymodules/its/device.py
index 5a29074..26af162 100644
--- a/apps/CameraITS/pymodules/its/device.py
+++ b/apps/CameraITS/pymodules/its/device.py
@@ -26,6 +26,9 @@
import numpy
import string
+CMD_DELAY = 1 # seconds
+
+
class ItsSession(object):
"""Controls a device over adb to run ITS scripts.
@@ -200,6 +203,10 @@
# TODO: Figure out why "--user 0" is needed, and fix the problem.
_run('%s shell am force-stop --user 0 %s' % (self.adb, self.PACKAGE))
+ _run(('%s shell am start --user 0 '
+ 'com.android.cts.verifier/.camera.its.ItsTestActivity '
+ '--activity-brought-to-front') % self.adb)
+ time.sleep(CMD_DELAY)
_run(('%s shell am startservice --user 0 -t text/plain '
'-a %s') % (self.adb, self.INTENT_START))
diff --git a/apps/CameraITS/tools/run_all_tests.py b/apps/CameraITS/tools/run_all_tests.py
index 4107e81..20a9c3d 100644
--- a/apps/CameraITS/tools/run_all_tests.py
+++ b/apps/CameraITS/tools/run_all_tests.py
@@ -169,6 +169,7 @@
# Make output directories to hold the generated files.
topdir = tempfile.mkdtemp()
+ subprocess.call(['chmod', 'g+rx', topdir])
print "Saving output files to:", topdir, "\n"
device_id = its.device.get_device_id()
diff --git a/apps/CameraITS/tools/turn_off_screen.py b/apps/CameraITS/tools/turn_off_screen.py
index 207042b..1faef9e 100644
--- a/apps/CameraITS/tools/turn_off_screen.py
+++ b/apps/CameraITS/tools/turn_off_screen.py
@@ -15,6 +15,9 @@
import re
import subprocess
import sys
+import time
+
+TURN_OFF_DELAY = 1 # seconds. Needed for back to back runs
def main():
@@ -38,5 +41,7 @@
else:
pwrdn = ('adb -s %s shell input keyevent POWER' % screen_id)
subprocess.Popen(pwrdn.split())
+ time.sleep(TURN_OFF_DELAY)
+
if __name__ == '__main__':
main()
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
index c38628d..c9a6265 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/VintfDeviceInfo.java
@@ -15,6 +15,7 @@
*/
package com.android.compatibility.common.deviceinfo;
+import android.os.Build;
import android.os.VintfObject;
import android.os.VintfRuntimeInfo;
@@ -33,6 +34,10 @@
@Override
protected void collectDeviceInfo(DeviceInfoStore store) throws Exception {
+ // VintfRuntimeInfo is available Android O onward.
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ return;
+ }
store.addResult("cpu_info", VintfRuntimeInfo.getCpuInfo());
store.addResult("os_name", VintfRuntimeInfo.getOsName());
store.addResult("node_name", VintfRuntimeInfo.getNodeName());
diff --git a/hostsidetests/backup/AndroidTest.xml b/hostsidetests/backup/AndroidTest.xml
index d123a76..5c33080 100644
--- a/hostsidetests/backup/AndroidTest.xml
+++ b/hostsidetests/backup/AndroidTest.xml
@@ -18,6 +18,7 @@
<option name="cleanup-apks" value="true" />
<option name="test-file-name" value="CtsBackupRestoreDeviceApp.apk" />
<option name="test-file-name" value="CtsFullbackupApp.apk" />
+ <option name="test-file-name" value="CtsIncludeExcludeApp.apk" />
</target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsBackupHostTestCases.jar" />
diff --git a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java b/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
index 7c3a6f6..ee49b87 100644
--- a/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
+++ b/hostsidetests/backup/fullbackupapp/src/android/cts/backup/fullbackupapp/FullbackupTest.java
@@ -36,7 +36,7 @@
import java.util.Random;
/**
- * Device side routines to be invoked by the host side NoBackupFolderHostSideTest. These are not
+ * Device side routines to be invoked by the host side FullbackupRulesHostSideTest. These are not
* designed to be called in any other way, as they rely on state set up by the host side test.
*/
@RunWith(AndroidJUnit4.class)
@@ -98,7 +98,7 @@
// Delete test data
deleteAllFiles();
- // No there should be no files left
+ // Now there should be no files left
checkNoFilesExist();
}
diff --git a/hostsidetests/backup/includeexcludeapp/Android.mk b/hostsidetests/backup/includeexcludeapp/Android.mk
new file mode 100644
index 0000000..9c55290
--- /dev/null
+++ b/hostsidetests/backup/includeexcludeapp/Android.mk
@@ -0,0 +1,39 @@
+# Copyright (C) 2017 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)
+
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+# tag this module as a cts test artifact
+LOCAL_COMPATIBILITY_SUITE := cts
+
+LOCAL_PACKAGE_NAME := CtsIncludeExcludeApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/backup/includeexcludeapp/AndroidManifest.xml b/hostsidetests/backup/includeexcludeapp/AndroidManifest.xml
new file mode 100644
index 0000000..3726eca
--- /dev/null
+++ b/hostsidetests/backup/includeexcludeapp/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.cts.backup.includeexcludeapp">
+
+ <application android:label="IncludeExcludeBackupApp"
+ android:fullBackupContent="@xml/my_backup_rules">
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation
+ android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.cts.backup.includeexcludeapp" />
+
+</manifest>
diff --git a/hostsidetests/backup/includeexcludeapp/res/xml/my_backup_rules.xml b/hostsidetests/backup/includeexcludeapp/res/xml/my_backup_rules.xml
new file mode 100644
index 0000000..dca51f5
--- /dev/null
+++ b/hostsidetests/backup/includeexcludeapp/res/xml/my_backup_rules.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<full-backup-content>
+ <include domain="file" path="."/>
+ <exclude domain="file" path="exclude_folder"/>
+ <include domain="sharedpref" path="."/>
+ <exclude domain="sharedpref" path="exclude_shared_pref.xml"/>
+ <include domain="database" path="db_name/file_to_include"/>
+ <exclude domain="database" path="db_name/file_to_exclude"/>
+ <include domain="external" path="."/>
+ <exclude domain="external" path="exclude_folder"/>
+ <include domain="root" path="file_to_include"/>
+ <exclude domain="root" path="file_to_exclude"/>
+</full-backup-content>
\ No newline at end of file
diff --git a/hostsidetests/backup/includeexcludeapp/src/android/cts/backup/includeexcludeapp/IncludeExcludeTest.java b/hostsidetests/backup/includeexcludeapp/src/android/cts/backup/includeexcludeapp/IncludeExcludeTest.java
new file mode 100644
index 0000000..83b932b
--- /dev/null
+++ b/hostsidetests/backup/includeexcludeapp/src/android/cts/backup/includeexcludeapp/IncludeExcludeTest.java
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2017 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.cts.backup.includeexcludeapp;
+
+import static android.support.test.InstrumentationRegistry.getTargetContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * Device side routines to be invoked by the host side FullbackupRulesHostSideTest. These are not
+ * designed to be called in any other way, as they rely on state set up by the host side test.
+ */
+@RunWith(AndroidJUnit4.class)
+public class IncludeExcludeTest {
+ public static final String TAG = "IncludeExcludeCTSApp";
+ private static final int FILE_SIZE_BYTES = 1024 * 1024;
+ private static final String SHARED_PREF_KEY1 = "dummy_key1";
+ private static final String SHARED_PREF_KEY2 = "dummy_key2";
+ private static final int SHARED_PREF_VALUE1 = 1337;
+ private static final int SHARED_PREF_VALUE2 = 1338;
+
+ private Context mContext;
+
+ private List<File> mIncludeFiles;
+ private List<File> mExcludeFiles;
+
+ private SharedPreferences mIncludeSharedPref;
+ private SharedPreferences mExcludeSharedPref;
+
+ @Before
+ public void setUp() {
+ mContext = getTargetContext();
+ setupFiles();
+ }
+
+ private void setupFiles() {
+
+ // We add all the files we expect to be backed up accoring to res/my_backup_rules.xml to
+ // the mIncludeFiles list, and all files expected not to be to mExcludeFiles.
+ mIncludeFiles = new ArrayList<File>();
+ mExcludeFiles = new ArrayList<File>();
+
+ // Files in the normal files directory.
+ File filesDir = mContext.getFilesDir();
+ File excludeFolder = new File(filesDir, "exclude_folder");
+ mIncludeFiles.add(new File(filesDir, "file_to_include"));
+ mExcludeFiles.add(new File(excludeFolder, "file_to_exclude"));
+
+ // Files in database directory.
+ File databaseDir = mContext.getDatabasePath("db_name");
+ mIncludeFiles.add(new File(databaseDir, "file_to_include"));
+ mExcludeFiles.add(new File(databaseDir, "file_to_exclude"));
+
+ // Files in external files directory.
+ File externalDir = mContext.getExternalFilesDir(null);
+ File excludeExternalFolder = new File(externalDir, "exclude_folder");
+ mIncludeFiles.add(new File(externalDir, "file_to_include"));
+ mExcludeFiles.add(new File(excludeExternalFolder, "file_to_exclude"));
+
+ // Files in root directory
+ File rootDir = mContext.getDataDir();
+ mIncludeFiles.add(new File(rootDir, "file_to_include"));
+ mExcludeFiles.add(new File(rootDir, "file_to_exclude"));
+
+ // Set up SharedPreferences
+ mIncludeSharedPref =
+ mContext.getSharedPreferences("include_shared_pref", Context.MODE_PRIVATE);
+ mExcludeSharedPref =
+ mContext.getSharedPreferences("exclude_shared_pref", Context.MODE_PRIVATE);
+ }
+
+ @Test
+ public void createFiles() throws Exception {
+ // Make sure the data does not exist from before
+ deleteAllFiles();
+ deleteSharedPref();
+ checkNoFilesExist();
+ checkSharedPrefDontExist();
+
+ // Create test data
+ generateFiles();
+ generateSharedPrefs();
+
+ checkAllFilesExist();
+ checkSharedPrefExist();
+ }
+
+ @Test
+ public void deleteFilesAfterBackup() throws Exception {
+ // Make sure the test data exists first
+ checkAllFilesExist();
+ checkSharedPrefExist();
+
+ // Delete test data
+ deleteAllFiles();
+ deleteSharedPref();
+
+ // Now there should be no files left
+ checkNoFilesExist();
+ checkSharedPrefDontExist();
+ }
+
+ @Test
+ public void checkRestoredFiles() throws Exception {
+ // After a restore, only files in the mIncludeFiles list should exist.
+ checkIncludeFilesDoExist();
+ checkExcludeFilesDoNotExist();
+
+ // Also check that the SharedPreferences were restored, except the excluded ones.
+ checkIncludeSharedPrefExist();
+ checkExcludeSharedPrefDoNotExist();
+ }
+
+ private void generateFiles() {
+ try {
+ // Add data to all the files we created
+ for (File file : mIncludeFiles) {
+ addData(file);
+ }
+ for (File file : mExcludeFiles) {
+ addData(file);
+ }
+ } catch (IOException e) {
+ fail("Unable to generate files: " + e);
+ }
+ }
+
+ private void deleteAllFiles() {
+ for (File file : mIncludeFiles) {
+ file.delete();
+ }
+ for (File file : mExcludeFiles) {
+ file.delete();
+ }
+ }
+
+ private void addData(File file) throws IOException {
+ file.getParentFile().mkdirs();
+
+ byte[] bytes = new byte[FILE_SIZE_BYTES];
+ new Random().nextBytes(bytes);
+
+ try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
+ bos.write(bytes, 0, bytes.length);
+ }
+ }
+
+ private void checkAllFilesExist() {
+ for (File file: mIncludeFiles) {
+ assertTrue("File did unexpectedly not exist: " + file.getAbsolutePath(), file.exists());
+ }
+ for (File file: mExcludeFiles) {
+ assertTrue("File did unexpectedly not exist: " + file.getAbsolutePath(), file.exists());
+ }
+ }
+
+ private void checkNoFilesExist() {
+ for (File file: mIncludeFiles) {
+ assertFalse("File did unexpectedly exist: " + file.getAbsolutePath(), file.exists());
+ }
+ for (File file: mExcludeFiles) {
+ assertFalse("File did unexpectedly exist: " + file.getAbsolutePath(), file.exists());
+ }
+ }
+
+ private void checkExcludeFilesDoNotExist() {
+ for (File file: mExcludeFiles) {
+ assertFalse("File expected not to be restored did exist: " + file.getAbsolutePath(),
+ file.exists());
+ }
+ }
+
+ private void checkIncludeFilesDoExist() {
+ for (File file: mIncludeFiles) {
+ assertTrue("File expected to be restored did not exist: " + file.getAbsolutePath(),
+ file.exists());
+ }
+ }
+
+ private void generateSharedPrefs() {
+ SharedPreferences.Editor editor = mIncludeSharedPref.edit();
+ editor.putInt(SHARED_PREF_KEY1, SHARED_PREF_VALUE1);
+ editor.commit();
+
+
+ editor = mExcludeSharedPref.edit();
+ editor.putInt(SHARED_PREF_KEY2, SHARED_PREF_VALUE2);
+ editor.commit();
+ }
+
+ private void checkSharedPrefExist() {
+ int value = mIncludeSharedPref.getInt(SHARED_PREF_KEY1, 0);
+ assertEquals("Shared preference did not exist", SHARED_PREF_VALUE1, value);
+
+ value = mExcludeSharedPref.getInt(SHARED_PREF_KEY2, 0);
+ assertEquals("Shared preference did not exist", SHARED_PREF_VALUE2, value);
+ }
+
+ private void deleteSharedPref() {
+ SharedPreferences.Editor editor = mIncludeSharedPref.edit();
+ editor.clear();
+ editor.commit();
+
+ editor = mExcludeSharedPref.edit();
+ editor.clear();
+ editor.commit();
+ }
+
+ private void checkSharedPrefDontExist() {
+ int value = mIncludeSharedPref.getInt(SHARED_PREF_KEY1, 0);
+ assertEquals("Shared preference did exist", 0, value);
+
+ value = mExcludeSharedPref.getInt(SHARED_PREF_KEY2, 0);
+ assertEquals("Shared preference did exist", 0, value);
+ }
+
+ private void checkIncludeSharedPrefExist() {
+ int value = mIncludeSharedPref.getInt(SHARED_PREF_KEY1, 0);
+ assertEquals("Shared preference did not exist", SHARED_PREF_VALUE1, value);
+ }
+
+ private void checkExcludeSharedPrefDoNotExist() {
+ int value = mExcludeSharedPref.getInt(SHARED_PREF_KEY2, 0);
+ assertEquals("Shared preference did exist", 0, value);
+ }
+}
diff --git a/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java
new file mode 100644
index 0000000..79ec24c
--- /dev/null
+++ b/hostsidetests/backup/src/android/cts/backup/FullbackupRulesHostSideTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2017 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.cts.backup;
+
+import static org.junit.Assert.assertTrue;
+
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test checking that files created by an app are restored successfully after a backup, but that
+ * files put in the folder provided by getNoBackupFilesDir() [files/no_backup] are NOT backed up,
+ * and that files are included/excluded according to rules defined in the manifest.
+ *
+ * Invokes device side tests provided by android.cts.backup.fullbackupapp.FullbackupTest and
+ * android.cts.backup.includeexcludeapp.IncludeExcludeTest.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class FullbackupRulesHostSideTest extends BaseBackupHostSideTest {
+
+ private static final String FULLBACKUP_TESTS_APP_NAME = "android.cts.backup.fullbackupapp";
+ private static final String FULLBACKUP_DEVICE_TEST_CLASS_NAME =
+ FULLBACKUP_TESTS_APP_NAME + ".FullbackupTest";
+
+ private static final String INCLUDE_EXCLUDE_TESTS_APP_NAME =
+ "android.cts.backup.includeexcludeapp";
+ private static final String INCLUDE_EXCLUDE_DEVICE_TEST_CLASS_NAME =
+ INCLUDE_EXCLUDE_TESTS_APP_NAME + ".IncludeExcludeTest";
+
+ @Test
+ public void testNoBackupFolder() throws Exception {
+ // Generate the files that are going to be backed up.
+ checkDeviceTest(FULLBACKUP_TESTS_APP_NAME, FULLBACKUP_DEVICE_TEST_CLASS_NAME,
+ "createFiles");
+
+ // Do a backup
+ String backupnowOutput = backupNow(FULLBACKUP_TESTS_APP_NAME);
+
+ assertBackupIsSuccessful(FULLBACKUP_TESTS_APP_NAME, backupnowOutput);
+
+ // Delete the files
+ checkDeviceTest(FULLBACKUP_TESTS_APP_NAME, FULLBACKUP_DEVICE_TEST_CLASS_NAME,
+ "deleteFilesAfterBackup");
+
+ // Do a restore
+ String restoreOutput = restore(FULLBACKUP_TESTS_APP_NAME);
+
+ assertRestoreIsSuccessful(restoreOutput);
+
+ // Check that the right files were restored
+ checkDeviceTest(FULLBACKUP_TESTS_APP_NAME, FULLBACKUP_DEVICE_TEST_CLASS_NAME,
+ "checkRestoredFiles");
+ }
+
+ @Test
+ public void testIncludeExcludeRules() throws Exception {
+ // Generate the files that are going to be backed up.
+ checkDeviceTest(INCLUDE_EXCLUDE_TESTS_APP_NAME, INCLUDE_EXCLUDE_DEVICE_TEST_CLASS_NAME,
+ "createFiles");
+
+ // Do a backup
+ String backupnowOutput = backupNow(INCLUDE_EXCLUDE_TESTS_APP_NAME);
+ assertBackupIsSuccessful(INCLUDE_EXCLUDE_TESTS_APP_NAME, backupnowOutput);
+
+ // Delete the files
+ checkDeviceTest(INCLUDE_EXCLUDE_TESTS_APP_NAME, INCLUDE_EXCLUDE_DEVICE_TEST_CLASS_NAME,
+ "deleteFilesAfterBackup");
+
+ // Do a restore
+ String restoreOutput = restore(INCLUDE_EXCLUDE_TESTS_APP_NAME);
+ assertRestoreIsSuccessful(restoreOutput);
+
+ // Check that the right files were restored
+ checkDeviceTest(INCLUDE_EXCLUDE_TESTS_APP_NAME, INCLUDE_EXCLUDE_DEVICE_TEST_CLASS_NAME,
+ "checkRestoredFiles");
+ }
+}
diff --git a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java b/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
deleted file mode 100644
index 56f8f5c..0000000
--- a/hostsidetests/backup/src/android/cts/backup/NoBackupFolderHostSideTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2017 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.cts.backup;
-
-import static org.junit.Assert.assertTrue;
-
-import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * Test checking that files created by an app are restored successfully after a backup, but that
- * files put in the folder provided by getNoBackupFilesDir() [files/no_backup] are NOT backed up.
- *
- * Invokes device side tests provided by android.cts.backup.fullbackupapp.FullbackupTest.
- */
-@RunWith(DeviceJUnit4ClassRunner.class)
-public class NoBackupFolderHostSideTest extends BaseBackupHostSideTest {
-
- private static final String TESTS_APP_NAME = "android.cts.backup.fullbackupapp";
- private static final String DEVICE_TEST_CLASS_NAME = TESTS_APP_NAME + ".FullbackupTest";
-
- @Test
- public void testNoBackupFolder() throws Exception {
- // Generate the files that are going to be backed up.
- checkDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "createFiles");
-
- // Do a backup
- String backupnowOutput = backupNow(TESTS_APP_NAME);
-
- assertBackupIsSuccessful(TESTS_APP_NAME, backupnowOutput);
-
- // Delete the files
- checkDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "deleteFilesAfterBackup");
-
- // Do a restore
- String restoreOutput = restore(TESTS_APP_NAME);
-
- assertRestoreIsSuccessful(restoreOutput);
-
- // Check that the right files were restored
- checkDeviceTest(TESTS_APP_NAME, DEVICE_TEST_CLASS_NAME, "checkRestoredFiles");
- }
-}
diff --git a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
index e593e55..507269c 100644
--- a/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
+++ b/hostsidetests/incident/src/com/android/server/cts/BatteryStatsValidationTest.java
@@ -379,6 +379,27 @@
batteryOffScreenOn();
}
+ /**
+ * Tests the total bytes reported for uploading over wifi.
+ */
+ public void testWifiUpload() throws Exception {
+ if (isTV()) {
+ return;
+ }
+ batteryOnScreenOff();
+ installPackage(DEVICE_SIDE_TEST_APK, true);
+
+ executeForeground(ACTION_WIFI_UPLOAD, 60_000);
+ int min = MIN_HTTP_HEADER_BYTES + (2 * 1024);
+ int max = min + (6 * 1024); // Add some fuzzing.
+ assertValueRange("nt", "", 7, min, max); // wifi_bytes_tx
+
+ executeBackground(ACTION_WIFI_UPLOAD, 60_000);
+ assertValueRange("nt", "", 21, min * 2, max * 2); // wifi_bytes_bg_tx
+
+ batteryOffScreenOn();
+ }
+
public void testCpuFreqData() throws Exception {
if (!CpuFreqDataHelper.doesProcFileExists(getDevice())) {
LogUtil.CLog.i("Proc file not found, skipping test %s#%s.\n",
@@ -511,27 +532,6 @@
batteryOffScreenOn();
}
- /**
- * Tests the total bytes reported for uploading over wifi.
- */
- public void testWifiUpload() throws Exception {
- if (isTV()) {
- return;
- }
- batteryOnScreenOff();
- installPackage(DEVICE_SIDE_TEST_APK, true);
-
- executeForeground(ACTION_WIFI_UPLOAD, 60_000);
- int min = MIN_HTTP_HEADER_BYTES + (2 * 1024);
- int max = min + (6 * 1024); // Add some fuzzing.
- assertValueRange("nt", "", 7, min, max); // wifi_bytes_tx
-
- executeBackground(ACTION_WIFI_UPLOAD, 60_000);
- assertValueRange("nt", "", 21, min * 2, max * 2); // wifi_bytes_bg_tx
-
- batteryOffScreenOn();
- }
-
private int getUid() throws Exception {
String uidLine = getDevice().executeShellCommand("cmd package list packages -U "
+ DEVICE_SIDE_TEST_PACKAGE);
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TestActivityWithSameAffinity.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TestActivityWithSameAffinity.java
index d835da7..db75dee 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TestActivityWithSameAffinity.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/TestActivityWithSameAffinity.java
@@ -16,6 +16,7 @@
package android.server.cts;
+import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -29,6 +30,8 @@
private static final String TAG = TestActivityWithSameAffinity.class.getSimpleName();
+ // Calls enterPictureInPicture() on creation
+ private static final String EXTRA_ENTER_PIP = "enter_pip";
// Starts the activity (component name) provided by the value at the end of onCreate
private static final String EXTRA_START_ACTIVITY = "start_activity";
// Finishes the activity at the end of onResume (after EXTRA_START_ACTIVITY is handled)
@@ -38,6 +41,11 @@
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ // Enter picture in picture if requested
+ if (getIntent().hasExtra(EXTRA_ENTER_PIP)) {
+ enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
+ }
+
// Launch a new activity if requested
String launchActivityComponent = getIntent().getStringExtra(EXTRA_START_ACTIVITY);
if (launchActivityComponent != null) {
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
index 8ccead5..cac6bd6 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/app/src/android/server/cts/tools/ActivityLauncher.java
@@ -81,8 +81,6 @@
newIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
}
- final Context launchContext = extras.getBoolean("use_application_context") ?
- context.getApplicationContext() : context;
- launchContext.startActivity(newIntent, options != null ? options.toBundle() : null);
+ context.startActivity(newIntent, options != null ? options.toBundle() : null);
}
}
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
index 01edfe7..55b41c8 100644
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
+++ b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/ActivityManagerPinnedStackTests.java
@@ -943,7 +943,7 @@
// Launch a fullscreen activity which will launch a PiP activity in a new task with the same
// affinity
launchActivity(TEST_ACTIVITY_WITH_SAME_AFFINITY);
- launchActivityInStack(PIP_ACTIVITY_WITH_SAME_AFFINITY, PINNED_STACK_ID);
+ launchActivity(PIP_ACTIVITY_WITH_SAME_AFFINITY);
assertPinnedStackExists();
// Launch the root activity again...
@@ -972,7 +972,7 @@
EXTRA_START_ACTIVITY, getActivityComponentName(TEST_ACTIVITY),
EXTRA_FINISH_SELF_ON_RESUME, "true");
mAmWmState.waitForValidState(mDevice, TEST_ACTIVITY, FULLSCREEN_WORKSPACE_STACK_ID);
- launchActivityInStack(PIP_ACTIVITY_WITH_SAME_AFFINITY, PINNED_STACK_ID);
+ launchActivity(PIP_ACTIVITY_WITH_SAME_AFFINITY);
mAmWmState.waitForValidState(mDevice, PIP_ACTIVITY_WITH_SAME_AFFINITY, PINNED_STACK_ID);
assertPinnedStackExists();
@@ -994,7 +994,8 @@
if (!supportsPip()) return;
// Launch an activity into the pinned stack with a fixed affinity
- launchActivityInStack(TEST_ACTIVITY_WITH_SAME_AFFINITY, PINNED_STACK_ID,
+ launchActivity(TEST_ACTIVITY_WITH_SAME_AFFINITY,
+ EXTRA_ENTER_PIP, "true",
EXTRA_START_ACTIVITY, getActivityComponentName(PIP_ACTIVITY),
EXTRA_FINISH_SELF_ON_RESUME, "true");
mAmWmState.waitForValidState(mDevice, PIP_ACTIVITY, PINNED_STACK_ID);
diff --git a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/StartActivityTests.java b/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/StartActivityTests.java
deleted file mode 100644
index c89ac63..0000000
--- a/hostsidetests/services/activityandwindowmanager/activitymanager/src/android/server/cts/StartActivityTests.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2017 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.server.cts;
-
-/**
- * Build: mmma -j32 cts/hostsidetests/services
- * Run: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.StartActivityTests
- */
-public class StartActivityTests extends ActivityManagerTestBase {
- private static final String TEST_ACTIVITY_NAME = "TestActivity";
-
- /**
- * Tests that starting an activity from a non-activity context will cause an exception if the
- * new task flag is not used.
- * @throws Exception
- */
- public void testStartActivityContexts() throws Exception {
- launchActivity(LAUNCHING_ACTIVITY);
- getLaunchActivityBuilder().setTargetActivityName(TEST_ACTIVITY_NAME)
- .setUseApplicationContext(true)
- .execute();
- mAmWmState.assertNotResumedActivity("The test activity should not have started",
- TEST_ACTIVITY_NAME);
- getLaunchActivityBuilder().setTargetActivityName(TEST_ACTIVITY_NAME)
- .execute();
- mAmWmState.assertResumedActivity("The test activity should have started",
- TEST_ACTIVITY_NAME);
- }
-}
diff --git a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
index 9c73c8f..972794e 100644
--- a/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activityandwindowmanager/util/src/android/server/cts/ActivityManagerTestBase.java
@@ -1129,7 +1129,6 @@
private int mDisplayId = INVALID_DISPLAY_ID;
private String mLaunchingActivityName = LAUNCHING_ACTIVITY;
private boolean mReorderToFront;
- private boolean mUseApplicationContext;
public LaunchActivityBuilder(ActivityAndWindowManagersState amWmState,
ITestDevice device) {
@@ -1172,11 +1171,6 @@
return this;
}
- public LaunchActivityBuilder setUseApplicationContext(boolean useApplicationContext) {
- mUseApplicationContext = useApplicationContext;
- return this;
- }
-
public LaunchActivityBuilder setLaunchingActivityName(String name) {
mLaunchingActivityName = name;
return this;
@@ -1208,9 +1202,6 @@
if (mDisplayId != INVALID_DISPLAY_ID) {
commandBuilder.append(" --ei display_id ").append(mDisplayId);
}
- if (mUseApplicationContext) {
- commandBuilder.append(" --ez use_application_context true");
- }
executeShellCommand(mDevice, commandBuilder.toString());
mAmWmState.waitForValidState(mDevice, new String[]{mTargetActivityName},
diff --git a/tests/autofillservice/src/android/autofillservice/cts/MultipleFragmentLoginTest.java b/tests/autofillservice/src/android/autofillservice/cts/MultipleFragmentLoginTest.java
index d474dc8..5b60e32 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/MultipleFragmentLoginTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/MultipleFragmentLoginTest.java
@@ -16,6 +16,7 @@
package android.autofillservice.cts;
+import static android.autofillservice.cts.CannedFillResponse.NO_RESPONSE;
import static android.autofillservice.cts.FragmentContainerActivity.FRAGMENT_TAG;
import static android.autofillservice.cts.Helper.FILL_TIMEOUT_MS;
import static android.autofillservice.cts.Helper.eventually;
@@ -118,8 +119,7 @@
() -> mActivity.getFragmentManager().beginTransaction().replace(
R.id.rootContainer, new FragmentWithMoreEditTexts(),
FRAGMENT_TAG).commitNow());
- EditText mEditText5 = mActivity.findViewById(R.id.editText5);
-
+ EditText editText5 = mActivity.findViewById(R.id.editText5);
fillRequest[0] = sReplier.getNextFillRequest();
// The fillRequest should have a fillContext for each partition. The first partition
@@ -159,7 +159,7 @@
sUiBot.assertShownByText("editText4-autofilled");
// Manually fill view
- mActivity.syncRunOnUiThread(() -> mEditText5.setText("editText5-manually-filled"));
+ mActivity.syncRunOnUiThread(() -> editText5.setText("editText5-manually-filled"));
// Finish activity and save data
mActivity.finish();
@@ -198,4 +198,53 @@
disableService();
}
}
+
+ @Test
+ public void uiDismissedWhenNonSavableFragmentIsGone() throws Exception {
+ uiDismissedWhenFragmentIsGoneText(false);
+ }
+
+ @Test
+ public void uiDismissedWhenSavableFragmentIsGone() throws Exception {
+ uiDismissedWhenFragmentIsGoneText(true);
+ }
+
+ private void uiDismissedWhenFragmentIsGoneText(boolean savable) throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ final CannedFillResponse.Builder response = new CannedFillResponse.Builder()
+ .addDataset(new CannedFillResponse.CannedDataset.Builder()
+ .setField("editText1", "whatever")
+ .setPresentation(createPresentation("dataset1"))
+ .build());
+ if (savable) {
+ response.setRequiredSavableIds(SAVE_DATA_TYPE_GENERIC, "editText2");
+ }
+
+ sReplier.addResponse(response.build());
+
+ // Trigger autofill
+ mActivity.syncRunOnUiThread(() -> {
+ mEditText2.requestFocus();
+ mEditText1.requestFocus();
+ });
+
+ // Check UI is shown, but don't select it.
+ sReplier.getNextFillRequest();
+ sUiBot.assertDatasets("dataset1");
+
+ // Switch fragments
+ sReplier.addResponse(NO_RESPONSE);
+ mActivity.syncRunOnUiThread(
+ () -> mActivity.getFragmentManager().beginTransaction().replace(
+ R.id.rootContainer, new FragmentWithMoreEditTexts(),
+ FRAGMENT_TAG).commitNow());
+ // Make sure UI is gone.
+ sReplier.getNextFillRequest();
+ sUiBot.assertNoDatasets();
+ }
+
+ // TODO: add similar tests for fragment with virtual view
}
diff --git a/tests/filesystem/src/android/filesystem/cts/FileUtil.java b/tests/filesystem/src/android/filesystem/cts/FileUtil.java
index 4cf07ac..386679a 100755
--- a/tests/filesystem/src/android/filesystem/cts/FileUtil.java
+++ b/tests/filesystem/src/android/filesystem/cts/FileUtil.java
@@ -147,8 +147,9 @@
byte[] data = generateRandomData(BUFFER_SIZE);
long written = 0;
while (written < length) {
- out.write(data);
- written += BUFFER_SIZE;
+ int toWrite = (int) Math.min(BUFFER_SIZE, length - written);
+ out.write(data, 0, toWrite);
+ written += toWrite;
}
out.flush();
out.close();
diff --git a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
index 5fa09c2..fe4b1dd 100644
--- a/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
+++ b/tests/tests/location/src/android/location/cts/GnssLocationValuesTest.java
@@ -37,6 +37,7 @@
private TestLocationListener mLocationListener;
private static final int LOCATION_UNCERTIANTY_MIN_YEAR = 2017;
private boolean extendedLocationAccuracyExpected = false;
+ private static final double SPEED_EPSILON = 0.001;
@Override
protected void setUp() throws Exception {
@@ -67,7 +68,7 @@
mTestLocationManager.requestLocationUpdates(mLocationListener);
boolean success = mLocationListener.await();
SoftAssert.failOrWarning(isMeasurementTestStrict(),
- "Time elapsed without getting the GPS locations."
+ "Time elapsed without getting the GNSS locations."
+ " Possibly, the test has been run deep indoors."
+ " Consider retrying test outdoors.",
success);
@@ -89,24 +90,28 @@
location.getAccuracy() > 0);
}
- if(!extendedLocationAccuracyExpected) {
+ if (!extendedLocationAccuracyExpected) {
return;
}
Log.i(TAG, "This is a device from 2017 or later.");
- softAssert.assertTrue("All GPS locations generated by the LocationManager "
- + "must have a bearing accuracy.", location.hasBearingAccuracy());
- if (location.hasBearingAccuracy()) {
- softAssert.assertTrue("Bearing Accuracy should be greater than 0.",
- location.getBearingAccuracyDegrees() > 0);
+ // When speed = 0, the Qualcomm HAL is not filling bearing accuracy.
+ if (location.hasSpeed() && location.getSpeed() > SPEED_EPSILON) {
+ softAssert.assertTrue("When speed is greater than 0, all GNSS locations generated by "
+ + "the LocationManager must have bearing accuracies.", location.hasBearingAccuracy());
+ if (location.hasBearingAccuracy()) {
+ softAssert.assertTrue("Bearing Accuracy should be greater than 0.",
+ location.getBearingAccuracyDegrees() > 0);
+ }
}
- softAssert.assertTrue("All GPS locations generated by the LocationManager "
+
+ softAssert.assertTrue("All GNSS locations generated by the LocationManager "
+ "must have a speed accuracy.", location.hasSpeedAccuracy());
if (location.hasSpeedAccuracy()) {
softAssert.assertTrue("Speed Accuracy should be greater than 0.",
location.getSpeedAccuracyMetersPerSecond() > 0);
}
- softAssert.assertTrue("All GPS locations generated by the LocationManager "
+ softAssert.assertTrue("All GNSS locations generated by the LocationManager "
+ "must have a vertical accuracy.", location.hasVerticalAccuracy());
if (location.hasVerticalAccuracy()) {
softAssert.assertTrue("Vertical Accuracy should be greater than 0.",
@@ -122,7 +127,7 @@
mTestLocationManager.requestLocationUpdates(mLocationListener);
boolean success = mLocationListener.await();
SoftAssert.failOrWarning(isMeasurementTestStrict(),
- "Time elapsed without getting the GPS locations."
+ "Time elapsed without getting the GNSS locations."
+ " Possibly, the test has been run deep indoors."
+ " Consider retrying test outdoors.",
success);
@@ -139,6 +144,9 @@
// For the altitude: the unit is meter
// The lowest exposed land on Earth is at the Dead Sea shore, at -413 meters.
// Whilst University of Tokyo Atacama Obsevatory is on 5,640m above sea level.
+
+ softAssert.assertTrue("All GNSS locations generated by the LocationManager "
+ + "must have altitudes.", location.hasAltitude());
if(location.hasAltitude()) {
softAssert.assertTrue("Altitude should be greater than -500 (meters).",
location.getAltitude() >= -500);
@@ -148,9 +156,14 @@
// It is guaranteed to be in the range [0.0, 360.0] if the device has a bearing.
// The API will return 0.0 if there is no bearing
- if(location.hasBearing()) {
- softAssert.assertTrue("Bearing should be in the range of [0.0, 360.0]",
- location.getBearing() >= 0 && location.getBearing() <= 360);
+ // When speed = 0, the Qualcomm HAL is not filling the bearing.
+ if (location.hasSpeed() && location.getSpeed() > SPEED_EPSILON) {
+ softAssert.assertTrue("When speed is greater than 0, all GNSS locations generated by "
+ + "the LocationManager must have bearings.", location.hasBearing());
+ if(location.hasBearing()) {
+ softAssert.assertTrue("Bearing should be in the range of [0.0, 360.0]",
+ location.getBearing() >= 0 && location.getBearing() <= 360);
+ }
}
softAssert.assertTrue("ElapsedRaltimeNanos should be great than 0.",
@@ -165,11 +178,15 @@
softAssert.assertTrue("Latitude should be in the range of [-90.0, 90.0] degrees",
location.getLatitude() >= -90 && location.getLatitude() <= 90);
+ softAssert.assertTrue("All GNSS locations generated by the LocationManager "
+ + "must have speeds.", location.hasSpeed());
+
// For the speed, during the cts test device shouldn't move faster than 1m/s
if(location.hasSpeed()) {
softAssert.assertTrue("In the test enviorment, speed should be in the range of [0, 1] m/s",
location.getSpeed() >= 0 && location.getSpeed() <= 1);
}
+
}
}
\ No newline at end of file
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index 82b992d..d2b7f23 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -194,6 +194,10 @@
playVideoWithRetries(path, null, null, playTime);
}
+ protected void playLiveAudioOnlyTest(String path, int playTime) throws Exception {
+ playVideoWithRetries(path, -1, -1, playTime);
+ }
+
protected void playVideoTest(String path, int width, int height) throws Exception {
playVideoWithRetries(path, width, height, 0);
}
@@ -265,6 +269,9 @@
final float leftVolume = 0.5f;
final float rightVolume = 0.5f;
+ boolean audioOnly = (width != null && width.intValue() == -1) ||
+ (height != null && height.intValue() == -1);
+
mMediaPlayer.setDisplay(mActivity.getSurfaceHolder());
mMediaPlayer.setScreenOnWhilePlaying(true);
mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
@@ -308,8 +315,10 @@
}
mMediaPlayer.start();
- mOnVideoSizeChangedCalled.waitForSignal();
- mOnVideoRenderingStartCalled.waitForSignal();
+ if (!audioOnly) {
+ mOnVideoSizeChangedCalled.waitForSignal();
+ mOnVideoRenderingStartCalled.waitForSignal();
+ }
mMediaPlayer.setVolume(leftVolume, rightVolume);
// waiting to complete
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index 6b2a0b5..ab54e75 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -229,7 +229,7 @@
String testUrl = (mInputUrl != null) ? mInputUrl : defaultUrl;
// Play stream for 60 seconds
- playLiveVideoTest(
+ playLiveAudioOnlyTest(
testUrl,
60 * 1000);
}
diff --git a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
index 94a9923..cc86808 100644
--- a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
@@ -36,6 +36,7 @@
import android.content.Context;
import android.os.Parcelable;
import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
@@ -290,6 +291,9 @@
ViewGroup.LayoutParams.MATCH_PARENT)), true);
mActivityRule.runOnUiThread(() -> setArrayAdapter(mAdapterView));
+ // Wait for the UI to "settle down" since selection is fired asynchronously
+ // on the next layout pass, and we don't want to trigger the listener too early
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
AdapterView.OnItemSelectedListener mockSelectedListener =
mock(AdapterView.OnItemSelectedListener.class);
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 3207773..7b54c11 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -7238,6 +7238,70 @@
}
@Test
+ public void testAutoSizeUniform_equivalentConfigurations() throws Throwable {
+ final DisplayMetrics dm = mActivity.getResources().getDisplayMetrics();
+ final int minTextSize = 10;
+ final int maxTextSize = 20;
+ final int granularity = 2;
+ final int unit = TypedValue.COMPLEX_UNIT_SP;
+
+ final TextView granularityTextView = new TextView(mActivity);
+ granularityTextView.setAutoSizeTextTypeUniformWithConfiguration(
+ minTextSize, maxTextSize, granularity, unit);
+
+ final TextView presetTextView = new TextView(mActivity);
+ presetTextView.setAutoSizeTextTypeUniformWithPresetSizes(
+ new int[] {minTextSize, 12, 14, 16, 18, maxTextSize}, unit);
+
+ // The TextViews have been configured differently but the end result should be nearly
+ // identical.
+ final int expectedAutoSizeType = TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM;
+ assertEquals(expectedAutoSizeType, granularityTextView.getAutoSizeTextType());
+ assertEquals(expectedAutoSizeType, presetTextView.getAutoSizeTextType());
+
+ final int expectedMinTextSizeInPx = Math.round(
+ TypedValue.applyDimension(unit, minTextSize, dm));
+ assertEquals(expectedMinTextSizeInPx, granularityTextView.getAutoSizeMinTextSize());
+ assertEquals(expectedMinTextSizeInPx, presetTextView.getAutoSizeMinTextSize());
+
+ final int expectedMaxTextSizeInPx = Math.round(
+ TypedValue.applyDimension(unit, maxTextSize, dm));
+ assertEquals(expectedMaxTextSizeInPx, granularityTextView.getAutoSizeMaxTextSize());
+ assertEquals(expectedMaxTextSizeInPx, presetTextView.getAutoSizeMaxTextSize());
+
+ // Configured with granularity.
+ assertEquals(Math.round(TypedValue.applyDimension(unit, granularity, dm)),
+ granularityTextView.getAutoSizeStepGranularity());
+ // Configured with preset values, there is no granularity.
+ assertEquals(-1, presetTextView.getAutoSizeStepGranularity());
+
+ // Both TextViews generate exactly the same sizes in pixels to choose from when auto-sizing.
+ assertArrayEquals(
+ granularityTextView.getAutoSizeTextAvailableSizes(),
+ presetTextView.getAutoSizeTextAvailableSizes());
+
+ final String someText = "This is a string";
+ final int widthHeight = 600;
+ // Configure identically and attach to layout.
+ mActivityRule.runOnUiThread(() -> {
+ LinearLayout ll = mActivity.findViewById(R.id.layout_textviewtest);
+ ll.addView(granularityTextView);
+ ll.addView(presetTextView);
+
+ granularityTextView.setWidth(widthHeight);
+ granularityTextView.setHeight(widthHeight);
+ granularityTextView.setText(someText);
+
+ presetTextView.setWidth(widthHeight);
+ presetTextView.setHeight(widthHeight);
+ presetTextView.setText(someText);
+ });
+ mInstrumentation.waitForIdleSync();
+
+ assertEquals(granularityTextView.getTextSize(), presetTextView.getTextSize(), 0f);
+ }
+
+ @Test
public void testAutoSizeUniform_getSetAutoSizeMaxTextSize() {
final TextView textView = new TextView(mActivity);
textView.setAutoSizeTextTypeWithDefaults(TextView.AUTO_SIZE_TEXT_TYPE_UNIFORM);
@@ -7264,8 +7328,8 @@
TypedValue.COMPLEX_UNIT_SP);
// It does not matter which unit has been used to set the max size, the getter always
// returns it in pixels.
- assertEquals((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, newMaxSize,
- mActivity.getResources().getDisplayMetrics()), textView.getAutoSizeMaxTextSize());
+ assertEquals(Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, newMaxSize,
+ mActivity.getResources().getDisplayMetrics())), textView.getAutoSizeMaxTextSize());
}
@Test
diff --git a/tools/cts-tradefed/res/config/cts-known-failures.xml b/tools/cts-tradefed/res/config/cts-known-failures.xml
index d73efb2..aaf1f81 100644
--- a/tools/cts-tradefed/res/config/cts-known-failures.xml
+++ b/tools/cts-tradefed/res/config/cts-known-failures.xml
@@ -97,22 +97,6 @@
<option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryW" />
<option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.VideoEncoderTest#testGoogH264SurfArbitraryW" />
- <!-- b/30932589 -->
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromExifByteOrderIIJpeg" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromExifByteOrderMMJpeg" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromLgG4Iso800Dng" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testDoNotFailOnCorruptedImage" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromVolantisJpg" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromSonyRX100Arw" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromCanonG7XCr2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromFujiX20Raf" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromNikon1AW1Nef" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromNikonP330Nrw" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromOlympusEPL3Orf" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromPanasonicGM5Rw2" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromPentaxK5Pef" />
- <option name="compatibility:exclude-filter" value="CtsMediaTestCases android.media.cts.ExifInterfaceTest#testReadExifDataFromSamsungNX3000Srw" />
-
<!-- b/25651805 -->
<option name="compatibility:exclude-filter" value="CtsNetTestCases android.net.cts.ConnectivityManagerTest#testRestrictedNetworks" />
<!-- b/18682315 -->