Merge "Attempt at fixing broken tests and regressing performance."
diff --git a/packages/DocumentsUI/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java b/packages/DocumentsUI/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
index cb2d904..9925d5b 100644
--- a/packages/DocumentsUI/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
+++ b/packages/DocumentsUI/perf-tests/src/com/android/documentsui/FilesJankPerfTest.java
@@ -56,6 +56,10 @@
         final Intent intent = new Intent(context, FilesActivity.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mActivity = getInstrumentation().startActivitySync(intent);
+        try {
+            device.setOrientationNatural();
+        } catch (RemoteException e) {
+        }
     }
 
     public void tearDownInLoop() {
@@ -63,6 +67,11 @@
             mActivity.finish();
             mActivity = null;
         }
+        try {
+            final UiDevice device = UiDevice.getInstance(getInstrumentation());
+            device.unfreezeRotation();
+        } catch (RemoteException e) {
+        }
     }
 
     public void setupAndOpenInLoop() throws Exception {
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/FileManagementUiTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/FileManagementUiTest.java
index 623f68a..44f417d 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/FileManagementUiTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/FileManagementUiTest.java
@@ -67,17 +67,6 @@
         bots.directory.waitForDocument("Kung Fu Panda");
     }
 
-    public void testDeleteDocument() throws Exception {
-        bots.directory.clickDocument("file1.png");
-        device.waitForIdle();
-        bots.main.clickToolbarItem(R.id.menu_delete);
-
-        bots.main.clickDialogOkButton();
-        device.waitForIdle();
-
-        bots.directory.assertDocumentsAbsent("file1.png");
-    }
-
     public void testKeyboard_CutDocument() throws Exception {
         bots.directory.clickDocument("file1.png");
         device.waitForIdle();
@@ -111,7 +100,7 @@
         bots.directory.waitForDocument("file1.png");
     }
 
-    public void testDeleteDocument_Cancel() throws Exception {
+    public void testDeleteDocument_Cancel_ThenOK() throws Exception {
         bots.directory.clickDocument("file1.png");
         device.waitForIdle();
         bots.main.clickToolbarItem(R.id.menu_delete);
@@ -119,5 +108,13 @@
         bots.main.clickDialogCancelButton();
 
         bots.directory.waitForDocument("file1.png");
+
+        device.waitForIdle();
+        bots.main.clickToolbarItem(R.id.menu_delete);
+
+        bots.main.clickDialogOkButton();
+        device.waitForIdle();
+
+        bots.directory.assertDocumentsAbsent("file1.png");
     }
 }