setupNewPublicVolume shouldn't run as PublicVolumeTest

If we run setupNewPublicVolume as a test in PublicVolumeTest, we will
call setup() method before running setupNewPublicVolume. setup() method
expects that public volume is already setup, and fails if it is not.
Hence we shouldn't run setupNewPublicVolume device test in the same
class.

Moved setupNewPublicVolume to a new helper class. As
setupNewPublicVolume itself is a setup method, we don't need any setup
methods in this class.

Bug: 158964245
Test: atest CtsPublicVolumeHostTest
Change-Id: I52c33b70cc72dda93a1413cf31aacd4f4af8dc0a
Merged-In: I52c33b70cc72dda93a1413cf31aacd4f4af8dc0a
(cherry picked from commit 0e89756ca48bde9538f6609658289d832667bc27)
diff --git a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeHostTest.java b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeHostTest.java
index 33e3e94..dbfa9fb 100644
--- a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeHostTest.java
+++ b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeHostTest.java
@@ -33,7 +33,8 @@
 
     private void setupNewPublicVolume() throws Exception {
         if (!mIsPublicVolumeSetup) {
-            runDeviceTest("setupNewPublicVolume");
+            assertTrue(runDeviceTests("android.scopedstorage.cts",
+                    "android.scopedstorage.cts.PublicVolumeTestHelper", "setupNewPublicVolume"));
             mIsPublicVolumeSetup = true;
         }
     }
diff --git a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeLegacyHostTest.java b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeLegacyHostTest.java
index 8ed0101..c9bd65f 100644
--- a/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeLegacyHostTest.java
+++ b/hostsidetests/scopedstorage/host/src/android/scopedstorage/cts/host/PublicVolumeLegacyHostTest.java
@@ -33,7 +33,8 @@
 
     private void setupNewPublicVolume() throws Exception {
         if (!mIsPublicVolumeSetup) {
-            runDeviceTest("setupNewPublicVolume");
+            assertTrue(runDeviceTests("android.scopedstorage.cts",
+                    "android.scopedstorage.cts.PublicVolumeTestHelper", "setupNewPublicVolume"));
             mIsPublicVolumeSetup = true;
         }
     }
diff --git a/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/PublicVolumeLegacyTest.java b/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/PublicVolumeLegacyTest.java
index 57ddf29..7e59505 100644
--- a/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/PublicVolumeLegacyTest.java
+++ b/hostsidetests/scopedstorage/legacy/src/android/scopedstorage/cts/legacy/PublicVolumeLegacyTest.java
@@ -23,7 +23,6 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import org.junit.Before;
-import org.junit.Test;
 import org.junit.runner.RunWith;
 
 /**
@@ -39,13 +38,4 @@
         TestUtils.setExternalStorageVolume(volumeName);
         super.setup();
     }
-
-    /**
-     * This is not an actual test, but rather just a one time setup method that creates the new
-     * public volume on which the test would run.
-     */
-    @Test
-    public void setupNewPublicVolume() throws Exception {
-        TestUtils.createNewPublicVolume();
-    }
 }
diff --git a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTest.java b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTest.java
index b0bf57e..e1fed5d 100644
--- a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTest.java
+++ b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTest.java
@@ -23,7 +23,6 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import org.junit.Before;
-import org.junit.Test;
 import org.junit.runner.RunWith;
 
 /**
@@ -39,13 +38,4 @@
         TestUtils.setExternalStorageVolume(volumeName);
         super.setup();
     }
-
-    /**
-     * This is not an actual test, but rather just a one time setup method that creates the new
-     * public volume on which the test would run.
-     */
-    @Test
-    public void setupNewPublicVolume() throws Exception {
-        TestUtils.createNewPublicVolume();
-    }
 }
diff --git a/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTestHelper.java b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTestHelper.java
new file mode 100644
index 0000000..ce5d2a2
--- /dev/null
+++ b/hostsidetests/scopedstorage/src/android/scopedstorage/cts/PublicVolumeTestHelper.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 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.scopedstorage.cts;
+
+import android.scopedstorage.cts.lib.TestUtils;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Creates public volume for running tests from {@link PublicVolumeTest} and
+ * {@link PublicVolumeLegacyTest}
+ */
+@RunWith(AndroidJUnit4.class)
+public class PublicVolumeTestHelper {
+    /**
+     * This is not an actual test, but rather just a one time setup method that creates the new
+     * public volume on which the test would run.
+     */
+    @Test
+    public void setupNewPublicVolume() throws Exception {
+        TestUtils.createNewPublicVolume();
+    }
+}