summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2019-12-04 06:28:37 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2019-12-04 06:28:37 +0000
commita9374d1f74ba302493fcd90ac5a548c84f748e6d (patch)
treed0ed1cf8b6e492949aeac29031648d874e2d22bd
parent45d0d679283017a2b0f0c3930c3ffa091e5091de (diff)
parentf5aadcaaed9d98be02b7a2f22ff4ce7420db915f (diff)
downloadandroid_packages_apps_DocumentsUI-a9374d1f74ba302493fcd90ac5a548c84f748e6d.tar.gz
android_packages_apps_DocumentsUI-a9374d1f74ba302493fcd90ac5a548c84f748e6d.tar.bz2
android_packages_apps_DocumentsUI-a9374d1f74ba302493fcd90ac5a548c84f748e6d.zip
Fix flaky test cases and OEM device failed test cases am: f5aadcaaed
Change-Id: I46cdc3dbb158a4f2f7d45cb9afc20d85b4c94499
-rw-r--r--tests/functional/com/android/documentsui/FileCopyUiTest.java25
-rw-r--r--tests/functional/com/android/documentsui/FileDeleteUiTest.java8
2 files changed, 21 insertions, 12 deletions
diff --git a/tests/functional/com/android/documentsui/FileCopyUiTest.java b/tests/functional/com/android/documentsui/FileCopyUiTest.java
index d78f3f07d..2dd2742f1 100644
--- a/tests/functional/com/android/documentsui/FileCopyUiTest.java
+++ b/tests/functional/com/android/documentsui/FileCopyUiTest.java
@@ -26,7 +26,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.net.Uri;
-import android.os.Build;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -78,7 +77,9 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
mErrorReason = intent.getStringExtra(
TestNotificationService.EXTRA_ERROR_REASON);
}
- mCountDownLatch.countDown();
+ if (mCountDownLatch != null) {
+ mCountDownLatch.countDown();
+ }
}
}
};
@@ -101,6 +102,8 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
private int mPreTestStayAwakeValue;
+ private String mDeviceLabel;
+
public FileCopyUiTest() {
super(FilesActivity.class);
}
@@ -124,6 +127,11 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
device.executeShellCommand("settings put global stay_on_while_plugged_in 3");
+ mDeviceLabel = Settings.Global.getString(context.getContentResolver(),
+ Settings.Global.DEVICE_NAME);
+ // If null or empty, use default name.
+ mDeviceLabel = TextUtils.isEmpty(mDeviceLabel) ? "Internal Storage" : mDeviceLabel;
+
// If Internal Storage is not shown, turn on.
State state = ((FilesActivity) getActivity()).getDisplayState();
if (!state.showAdvanced) {
@@ -161,7 +169,7 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
@Override
public void tearDown() throws Exception {
// Delete created files
- deleteDocuments(Build.MODEL);
+ deleteDocuments(mDeviceLabel);
deleteDocuments(mSdCardLabel);
if (mIsVirtualSdCard) {
@@ -172,6 +180,7 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
+ mPreTestStayAwakeValue);
context.unregisterReceiver(mReceiver);
+ mCountDownLatch = null;
try {
bots.notifications.setNotificationAccess(getActivity(), false);
} catch (Exception e) {
@@ -389,24 +398,24 @@ public class FileCopyUiTest extends ActivityTest<FilesActivity> {
@HugeLongTest
public void testCopyDocuments_FromSdCard() throws Exception {
createDocuments(mSdCardLabel, mSdCardRoot, mStorageDocsHelper);
- copyFiles(mSdCardLabel, Build.MODEL);
+ copyFiles(mSdCardLabel, mDeviceLabel);
// Check that original folder exists
bots.roots.openRoot(mSdCardLabel);
bots.directory.assertDocumentsPresent(TARGET_FOLDER);
// Check that copied files exist
- assertFilesCopied(Build.MODEL, mPrimaryRoot, mStorageDocsHelper);
+ assertFilesCopied(mDeviceLabel, mPrimaryRoot, mStorageDocsHelper);
}
// Copy Internal Storage -> SD Card //
@HugeLongTest
public void testCopyDocuments_ToSdCard() throws Exception {
- createDocuments(Build.MODEL, mPrimaryRoot, mStorageDocsHelper);
- copyFiles(Build.MODEL, mSdCardLabel);
+ createDocuments(mDeviceLabel, mPrimaryRoot, mStorageDocsHelper);
+ copyFiles(mDeviceLabel, mSdCardLabel);
// Check that original folder exists
- bots.roots.openRoot(Build.MODEL);
+ bots.roots.openRoot(mDeviceLabel);
bots.directory.assertDocumentsPresent(TARGET_FOLDER);
// Check that copied files exist
diff --git a/tests/functional/com/android/documentsui/FileDeleteUiTest.java b/tests/functional/com/android/documentsui/FileDeleteUiTest.java
index f4efd15b7..d68dbd652 100644
--- a/tests/functional/com/android/documentsui/FileDeleteUiTest.java
+++ b/tests/functional/com/android/documentsui/FileDeleteUiTest.java
@@ -66,7 +66,9 @@ public class FileDeleteUiTest extends ActivityTest<FilesActivity> {
mErrorReason = intent.getStringExtra(
TestNotificationService.EXTRA_ERROR_REASON);
}
- mCountDownLatch.countDown();
+ if (mCountDownLatch != null) {
+ mCountDownLatch.countDown();
+ }
}
}
};
@@ -111,10 +113,8 @@ public class FileDeleteUiTest extends ActivityTest<FilesActivity> {
@Override
public void tearDown() throws Exception {
- mCountDownLatch.countDown();
- mCountDownLatch = null;
-
context.unregisterReceiver(mReceiver);
+ mCountDownLatch = null;
try {
bots.notifications.setNotificationAccess(getActivity(), false);
} catch (Exception e) {