Merge "DocumentsUI: Declare intents for App enumeration" into rvc-dev
diff --git a/Android.bp b/Android.bp
index 07d0f57..b2569c4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -98,7 +98,7 @@
}
android_library {
- name: "DocumentsUI-res-lib-tests",
+ name: "DocumentsUIUnitTests-res-lib",
manifest: "AndroidManifestForUnitTests.xml",
diff --git a/AndroidManifestForUnitTests.xml b/AndroidManifestForUnitTests.xml
index 717cddf..993d440 100644
--- a/AndroidManifestForUnitTests.xml
+++ b/AndroidManifestForUnitTests.xml
@@ -35,97 +35,5 @@
<uses-permission
android:name="android.permission.READ_COMPAT_CHANGE_CONFIG" />
- <application android:name=".DocumentsApplication"
- android:label="@string/app_label" android:icon="@drawable/app_icon"
- android:supportsRtl="true" android:allowBackup="true"
- android:backupAgent=".prefs.BackupAgent"
- android:fullBackupOnly="false" android:crossProfile="true">
-
- <activity android:name=".picker.PickActivity"
- android:theme="@style/DocumentsTheme"
- android:visibleToInstantApps="true">
- <intent-filter android:priority="100">
- <action android:name="android.intent.action.OPEN_DOCUMENT" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.OPENABLE" />
- <data android:mimeType="*/*" />
- </intent-filter>
- <intent-filter android:priority="100">
- <action android:name="android.intent.action.CREATE_DOCUMENT" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.OPENABLE" />
- <data android:mimeType="*/*" />
- </intent-filter>
- <intent-filter android:priority="100">
- <action android:name="android.intent.action.GET_CONTENT" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.OPENABLE" />
- <data android:mimeType="*/*" />
- </intent-filter>
- <intent-filter android:priority="100">
- <action android:name="android.intent.action.OPEN_DOCUMENT_TREE" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
-
- <activity android:name=".files.LauncherActivity"
- android:label="@string/launcher_label"
- android:icon="@drawable/launcher_icon"
- android:theme="@android:style/Theme.NoDisplay"></activity>
-
- <activity android:name=".inspector.InspectorActivity"
- android:label="@string/menu_inspect"
- android:icon="@drawable/launcher_icon"
- android:theme="@style/DocumentsTheme"></activity>
-
- <!-- Preserve original launcher activity from Nougat. -->
- <activity-alias android:name=".LauncherActivity"
- android:targetActivity=".files.LauncherActivity"
- android:label="@string/launcher_label"
- android:icon="@drawable/launcher_icon">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- <category android:name="android.intent.category.APP_FILES" />
- </intent-filter>
- <meta-data android:name="android.app.shortcuts"
- android:resource="@xml/shortcuts" />
- </activity-alias>
-
- <activity android:name=".files.FilesActivity"
- android:documentLaunchMode="intoExisting"
- android:theme="@style/DocumentsTheme">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.document/root" />
- </intent-filter>
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.document/directory" />
- </intent-filter>
- </activity>
-
- <activity-alias android:name=".ViewDownloadsActivity"
- android:targetActivity=".files.FilesActivity"
- android:enabled="@bool/handle_view_downloads_intent">
- <intent-filter>
- <action android:name="android.intent.action.VIEW_DOWNLOADS" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity-alias>
-
- <activity android:name=".ScopedAccessActivity"
- android:theme="@android:style/Theme.Translucent.NoTitleBar">
- <intent-filter>
- <action android:name="android.os.storage.action.OPEN_EXTERNAL_DIRECTORY" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- </application>
</manifest>
diff --git a/res/values-ar/strings.xml b/res/values-ar/strings.xml
index 9ea8177..86e23f2 100644
--- a/res/values-ar/strings.xml
+++ b/res/values-ar/strings.xml
@@ -46,7 +46,7 @@
<string name="menu_rename" msgid="1883113442688817554">"إعادة تسمية"</string>
<string name="menu_inspect" msgid="7279855349299446224">"الحصول على المعلومات"</string>
<string name="menu_show_hidden_files" msgid="5140676344684492769">"إظهار الملفات المخفية"</string>
- <string name="menu_hide_hidden_files" msgid="5654495713350153702">"عدم إظهار الملفات المخفية."</string>
+ <string name="menu_hide_hidden_files" msgid="5654495713350153702">"عدم إظهار الملفات المخفية"</string>
<string name="menu_view_in_owner" msgid="7228948660557554770">"العرض في <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
<string name="menu_new_window" msgid="2947837751796109126">"نافذة جديدة"</string>
<string name="menu_cut_to_clipboard" msgid="2878752142015026229">"قص"</string>
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index e435a41..cf701bb 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -278,5 +278,5 @@
<string name="personal_tab" msgid="3878576287868528503">"Pertsonala"</string>
<string name="work_tab" msgid="7265359366883747413">"Lanekoa"</string>
<string name="a11y_work" msgid="7504431382825242153">"Lana"</string>
- <string name="drag_from_another_app" msgid="8310249276199969905">"Ezin dituzu beste aplikazioetako fitxategiak mugitu."</string>
+ <string name="drag_from_another_app" msgid="8310249276199969905">"Ezin dituzu mugitu beste aplikazio batzuetako fitxategiak."</string>
</resources>
diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml
index eded711..c58cfa4 100644
--- a/res/values-fr-rCA/strings.xml
+++ b/res/values-fr-rCA/strings.xml
@@ -46,7 +46,7 @@
<string name="menu_rename" msgid="1883113442688817554">"Renommer"</string>
<string name="menu_inspect" msgid="7279855349299446224">"En savoir plus"</string>
<string name="menu_show_hidden_files" msgid="5140676344684492769">"Afficher les fichiers masqués"</string>
- <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Ne pas aff. fichiers masqués"</string>
+ <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Ne pas afficher les fichiers masqués"</string>
<string name="menu_view_in_owner" msgid="7228948660557554770">"Afficher dans <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
<string name="menu_new_window" msgid="2947837751796109126">"Nouvelle fenêtre"</string>
<string name="menu_cut_to_clipboard" msgid="2878752142015026229">"Couper"</string>
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 72593a5..dbd6cf8 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -45,8 +45,8 @@
<string name="menu_extract" msgid="8171946945982532262">"Extraire sur…"</string>
<string name="menu_rename" msgid="1883113442688817554">"Renommer"</string>
<string name="menu_inspect" msgid="7279855349299446224">"Obtenir les informations"</string>
- <string name="menu_show_hidden_files" msgid="5140676344684492769">"Afficher fichiers masqués"</string>
- <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Ne pas afficher fichiers masqués"</string>
+ <string name="menu_show_hidden_files" msgid="5140676344684492769">"Afficher les fichiers masqués"</string>
+ <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Ne pas afficher les fichiers masqués"</string>
<string name="menu_view_in_owner" msgid="7228948660557554770">"Afficher dans <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
<string name="menu_new_window" msgid="2947837751796109126">"Nouvelle fenêtre"</string>
<string name="menu_cut_to_clipboard" msgid="2878752142015026229">"Couper"</string>
diff --git a/res/values-ky/strings.xml b/res/values-ky/strings.xml
index 2b0d1a9..6d3cb37 100644
--- a/res/values-ky/strings.xml
+++ b/res/values-ky/strings.xml
@@ -46,7 +46,7 @@
<string name="menu_rename" msgid="1883113442688817554">"Аталышын өзгөртүү"</string>
<string name="menu_inspect" msgid="7279855349299446224">"Маалымат алуу"</string>
<string name="menu_show_hidden_files" msgid="5140676344684492769">"Жашырылган файлдар көрсөтүлсүн"</string>
- <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Жашырылган файлдар көрсөтүлбөсүн"</string>
+ <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Жашырылган файлдар көрүнбөсүн"</string>
<string name="menu_view_in_owner" msgid="7228948660557554770">"<xliff:g id="SOURCE">%1$s</xliff:g> аркылуу көрүү"</string>
<string name="menu_new_window" msgid="2947837751796109126">"Жаңы терезе"</string>
<string name="menu_cut_to_clipboard" msgid="2878752142015026229">"Кесүү"</string>
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
index a7ba770..b95990f 100644
--- a/res/values-ms/strings.xml
+++ b/res/values-ms/strings.xml
@@ -46,7 +46,7 @@
<string name="menu_rename" msgid="1883113442688817554">"Namakan semula"</string>
<string name="menu_inspect" msgid="7279855349299446224">"Dapatkan maklumat"</string>
<string name="menu_show_hidden_files" msgid="5140676344684492769">"Tunjukkan fail tersembunyi"</string>
- <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Jgn tunjukkan fail trsmbunyi"</string>
+ <string name="menu_hide_hidden_files" msgid="5654495713350153702">"Jangan tunjukkan fail tersembunyi"</string>
<string name="menu_view_in_owner" msgid="7228948660557554770">"Lihat dalam <xliff:g id="SOURCE">%1$s</xliff:g>"</string>
<string name="menu_new_window" msgid="2947837751796109126">"Tetingkap baharu"</string>
<string name="menu_cut_to_clipboard" msgid="2878752142015026229">"Potong"</string>
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index f9fd4b6..4f4eea1 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -278,5 +278,5 @@
<string name="personal_tab" msgid="3878576287868528503">"Binafsi"</string>
<string name="work_tab" msgid="7265359366883747413">"Kazini"</string>
<string name="a11y_work" msgid="7504431382825242153">"Kazi"</string>
- <string name="drag_from_another_app" msgid="8310249276199969905">"Huwezi kuhamisha programu kutoka faili nyingine."</string>
+ <string name="drag_from_another_app" msgid="8310249276199969905">"Huwezi kuhamisha faili kutoka programu nyingine."</string>
</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index fbd38e8..5d0882a 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -278,5 +278,5 @@
<string name="personal_tab" msgid="3878576287868528503">"個人"</string>
<string name="work_tab" msgid="7265359366883747413">"工作"</string>
<string name="a11y_work" msgid="7504431382825242153">"工作"</string>
- <string name="drag_from_another_app" msgid="8310249276199969905">"你無法移動其他應用程式中的檔案。"</string>
+ <string name="drag_from_another_app" msgid="8310249276199969905">"你無法將其他應用程式中的檔案移動至此。"</string>
</resources>
diff --git a/tests/unit/com/android/documentsui/archives/ArchiveFileTestRule.java b/tests/functional/com/android/documentsui/archives/ArchiveFileTestRule.java
similarity index 98%
rename from tests/unit/com/android/documentsui/archives/ArchiveFileTestRule.java
rename to tests/functional/com/android/documentsui/archives/ArchiveFileTestRule.java
index f3ef5ba..646dab1 100644
--- a/tests/unit/com/android/documentsui/archives/ArchiveFileTestRule.java
+++ b/tests/functional/com/android/documentsui/archives/ArchiveFileTestRule.java
@@ -16,9 +16,13 @@
package com.android.documentsui.archives;
+import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
+
import android.os.ParcelFileDescriptor;
import android.util.Log;
+import androidx.test.platform.app.InstrumentationRegistry;
+
import org.apache.commons.compress.utils.IOUtils;
import org.junit.rules.TestName;
import org.junit.runner.Description;
@@ -38,10 +42,6 @@
import java.util.Locale;
import java.util.Set;
-import androidx.test.platform.app.InstrumentationRegistry;
-
-import static android.os.ParcelFileDescriptor.MODE_READ_ONLY;
-
public class ArchiveFileTestRule extends TestName {
private static final String TAG = ArchiveFileTestRule.class.getSimpleName();
@@ -156,7 +156,7 @@
ParcelFileDescriptor parcelFileDescriptor = openAssetFile(assetPath, ".text");
try (FileInputStream fileInputStream =
- new FileInputStream(parcelFileDescriptor.getFileDescriptor())){
+ new FileInputStream(parcelFileDescriptor.getFileDescriptor())) {
return getStringFromInputStream(fileInputStream);
}
}
diff --git a/tests/unit/com/android/documentsui/archives/ArchiveHandleTest.java b/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java
similarity index 99%
rename from tests/unit/com/android/documentsui/archives/ArchiveHandleTest.java
rename to tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java
index d962f91..ff43caf 100644
--- a/tests/unit/com/android/documentsui/archives/ArchiveHandleTest.java
+++ b/tests/functional/com/android/documentsui/archives/ArchiveHandleTest.java
@@ -17,6 +17,7 @@
package com.android.documentsui.archives;
import static com.google.common.truth.Truth.assertThat;
+
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -27,6 +28,13 @@
import androidx.annotation.Nullable;
import androidx.test.runner.AndroidJUnit4;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.compressors.CompressorException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -36,13 +44,6 @@
import java.util.List;
import java.util.Locale;
-import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.ArchiveException;
-import org.apache.commons.compress.compressors.CompressorException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
@RunWith(AndroidJUnit4.class)
public class ArchiveHandleTest {
@Rule
@@ -201,7 +202,7 @@
@Test
public void buildArchiveHandle_tarFile_shouldNotNull() throws Exception {
ArchiveHandle archiveHandle = prepareArchiveHandle("archives/tar/hello.tar",
- ".tar","application/x-gtar");
+ ".tar", "application/x-gtar");
assertThat(archiveHandle).isNotNull();
}
@@ -606,4 +607,4 @@
assertThat(transformToIterable(archiveHandle.getEntries()))
.containsAllIn(sExpectEntries);
}
-}
\ No newline at end of file
+}
diff --git a/tests/unit/com/android/documentsui/archives/ReadableArchiveTest.java b/tests/functional/com/android/documentsui/archives/ReadableArchiveTest.java
similarity index 98%
rename from tests/unit/com/android/documentsui/archives/ReadableArchiveTest.java
rename to tests/functional/com/android/documentsui/archives/ReadableArchiveTest.java
index f6378e3..33e1671 100644
--- a/tests/unit/com/android/documentsui/archives/ReadableArchiveTest.java
+++ b/tests/functional/com/android/documentsui/archives/ReadableArchiveTest.java
@@ -38,12 +38,6 @@
import com.android.documentsui.tests.R;
-import java.io.IOException;
-import java.util.Scanner;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.compressors.CompressorException;
import org.junit.After;
@@ -51,9 +45,16 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.io.IOException;
+import java.util.Scanner;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
@RunWith(AndroidJUnit4.class)
@MediumTest
public class ReadableArchiveTest {
+
private static final Uri ARCHIVE_URI = Uri.parse("content://i/love/strawberries");
private static final String NOTIFICATION_URI =
"content://com.android.documentsui.archives/notification-uri";
@@ -145,7 +146,6 @@
assertEquals(0,
cursor.getInt(cursor.getColumnIndexOrThrow(Document.COLUMN_SIZE)));
-
// Check if querying children works too.
final Cursor childCursor = mArchive.queryChildDocuments(
createArchiveId("/dir1/").toDocumentId(), null, null);
@@ -170,7 +170,7 @@
throws IOException, CompressorException, ArchiveException {
loadArchive(mTestUtils.getNonSeekableDescriptor(R.raw.no_dirs));
final Cursor cursor = mArchive.queryChildDocuments(
- createArchiveId("/").toDocumentId(), null, null);
+ createArchiveId("/").toDocumentId(), null, null);
assertTrue(cursor.moveToFirst());
assertEquals(
@@ -394,7 +394,7 @@
createArchiveId("/dir2/strawberries.txt").toDocumentId(),
"r", null /* signal */);
assertTrue(Archive.canSeek(descriptor));
- try (final ParcelFileDescriptor.AutoCloseInputStream inputStream =
+ try (ParcelFileDescriptor.AutoCloseInputStream inputStream =
new ParcelFileDescriptor.AutoCloseInputStream(descriptor)) {
Os.lseek(descriptor.getFileDescriptor(), "I love ".length(), OsConstants.SEEK_SET);
assertEquals("strawberries!", new Scanner(inputStream).nextLine());
diff --git a/tests/unit/com/android/documentsui/archives/ResourcesProvider.java b/tests/functional/com/android/documentsui/archives/ResourcesProvider.java
similarity index 96%
rename from tests/unit/com/android/documentsui/archives/ResourcesProvider.java
rename to tests/functional/com/android/documentsui/archives/ResourcesProvider.java
index 64764ec..6fdd90f 100644
--- a/tests/unit/com/android/documentsui/archives/ResourcesProvider.java
+++ b/tests/functional/com/android/documentsui/archives/ResourcesProvider.java
@@ -16,25 +16,20 @@
package com.android.documentsui.archives;
-import com.android.documentsui.tests.R;
-
-import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
-import android.net.Uri;
import android.os.CancellationSignal;
+import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
-import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
import android.webkit.MimeTypeMap;
-import android.os.FileUtils;
+import com.android.documentsui.tests.R;
-import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
@@ -43,17 +38,19 @@
public class ResourcesProvider extends DocumentsProvider {
+
public static final String AUTHORITY = "com.android.documentsui.archives.resourcesprovider";
- private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
+ private static final String[] DEFAULT_ROOT_PROJECTION = new String[]{
Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_TITLE, Root.COLUMN_DOCUMENT_ID
};
- private static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[] {
+ private static final String[] DEFAULT_DOCUMENT_PROJECTION = new String[]{
Document.COLUMN_DOCUMENT_ID, Document.COLUMN_MIME_TYPE, Document.COLUMN_DISPLAY_NAME,
Document.COLUMN_LAST_MODIFIED, Document.COLUMN_FLAGS, Document.COLUMN_SIZE,
};
private static final Map<String, Integer> RESOURCES = new HashMap<>();
+
static {
RESOURCES.put("archive.zip", R.raw.archive);
RESOURCES.put("broken.zip", R.raw.broken);
@@ -149,14 +146,13 @@
row.add(Document.COLUMN_DISPLAY_NAME, documentId);
final int lastDot = documentId.lastIndexOf('.');
- assert(lastDot > 0);
+ assert (lastDot > 0);
final String extension = documentId.substring(lastDot + 1).toLowerCase();
final String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
row.add(Document.COLUMN_MIME_TYPE, mimeType);
row.add(Document.COLUMN_SIZE, fd.getLength());
- }
- finally {
+ } finally {
FileUtils.closeQuietly(fd);
}
}
diff --git a/tests/unit/com/android/documentsui/archives/TestUtils.java b/tests/functional/com/android/documentsui/archives/TestUtils.java
similarity index 76%
rename from tests/unit/com/android/documentsui/archives/TestUtils.java
rename to tests/functional/com/android/documentsui/archives/TestUtils.java
index ce4b79e..4e58f6a 100644
--- a/tests/unit/com/android/documentsui/archives/TestUtils.java
+++ b/tests/functional/com/android/documentsui/archives/TestUtils.java
@@ -16,9 +16,6 @@
package com.android.documentsui.archives;
-import com.android.documentsui.archives.Archive;
-import com.android.documentsui.tests.R;
-
import android.content.Context;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
@@ -29,9 +26,8 @@
import java.io.InputStream;
import java.util.concurrent.ExecutorService;
-import android.util.Log;
-
public class TestUtils {
+
public static final Uri ARCHIVE_URI = Uri.parse("content://i/love/strawberries");
public static final String NOTIFICATION_URI = "content://notification-uri";
@@ -54,8 +50,7 @@
}
/**
- * Opens a resource and returns the contents via file descriptor to a local
- * snapshot file.
+ * Opens a resource and returns the contents via file descriptor to a local snapshot file.
*/
public ParcelFileDescriptor getSeekableDescriptor(int resource) {
// Extract the file from resources.
@@ -64,14 +59,14 @@
file = File.createTempFile("com.android.documentsui.archives.tests{",
"}.zip", mTargetContext.getCacheDir());
try (
- final FileOutputStream outputStream =
- new ParcelFileDescriptor.AutoCloseOutputStream(
- ParcelFileDescriptor.open(
- file, ParcelFileDescriptor.MODE_WRITE_ONLY));
- final InputStream inputStream =
- mTestContext.getResources().openRawResource(resource);
+ FileOutputStream outputStream =
+ new ParcelFileDescriptor.AutoCloseOutputStream(
+ ParcelFileDescriptor.open(
+ file, ParcelFileDescriptor.MODE_WRITE_ONLY));
+ InputStream inputStream =
+ mTestContext.getResources().openRawResource(resource);
) {
- final byte[] buffer = new byte[32 * 1024];
+ byte[] buffer = new byte[32 * 1024];
int bytes;
while ((bytes = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytes);
@@ -103,19 +98,19 @@
@Override
public void run() {
try (
- final ParcelFileDescriptor.AutoCloseOutputStream outputStream =
- new ParcelFileDescriptor.
- AutoCloseOutputStream(finalOutputPipe);
- final InputStream inputStream =
- mTestContext.getResources().openRawResource(resource);
+ ParcelFileDescriptor.AutoCloseOutputStream outputStream =
+ new ParcelFileDescriptor.AutoCloseOutputStream(
+ finalOutputPipe);
+ InputStream inputStream =
+ mTestContext.getResources().openRawResource(resource);
) {
- final byte[] buffer = new byte[32 * 1024];
+ byte[] buffer = new byte[32 * 1024];
int bytes;
while ((bytes = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytes);
}
} catch (IOException e) {
- throw new IllegalStateException("Piping resource failed.", e);
+ throw new IllegalStateException("Piping resource failed.", e);
}
}
});
diff --git a/tests/unit/com/android/documentsui/archives/WriteableArchiveTest.java b/tests/functional/com/android/documentsui/archives/WriteableArchiveTest.java
similarity index 97%
rename from tests/unit/com/android/documentsui/archives/WriteableArchiveTest.java
rename to tests/functional/com/android/documentsui/archives/WriteableArchiveTest.java
index f066dc6..7092d12 100644
--- a/tests/unit/com/android/documentsui/archives/WriteableArchiveTest.java
+++ b/tests/functional/com/android/documentsui/archives/WriteableArchiveTest.java
@@ -25,8 +25,6 @@
import androidx.test.InstrumentationRegistry;
-import com.android.documentsui.archives.WriteableArchive;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -40,6 +38,7 @@
@MediumTest
public class WriteableArchiveTest extends AndroidTestCase {
+
private static final Uri ARCHIVE_URI = Uri.parse("content://i/love/strawberries");
private static final String NOTIFICATION_URI =
"content://com.android.documentsui.archives/notification-uri";
@@ -221,7 +220,7 @@
}
final ParcelFileDescriptor fd = mArchive.openDocument(documentId, "w", null);
- try (final ParcelFileDescriptor.AutoCloseOutputStream outputStream =
+ try (ParcelFileDescriptor.AutoCloseOutputStream outputStream =
new ParcelFileDescriptor.AutoCloseOutputStream(fd)) {
outputStream.write("Hello world!".getBytes());
}
@@ -251,7 +250,7 @@
ZipFile zip = null;
try {
try {
- zip = new ZipFile(mFile);
+ zip = new ZipFile(mFile);
} catch (Exception e) {
throw new IOException(mFile.getAbsolutePath());
}
@@ -280,7 +279,7 @@
ZipFile zip = null;
try {
try {
- zip = new ZipFile(mFile);
+ zip = new ZipFile(mFile);
} catch (Exception e) {
throw new IOException(mFile.getAbsolutePath());
}
diff --git a/tests/unit/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java b/tests/functional/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java
similarity index 98%
rename from tests/unit/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java
rename to tests/functional/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java
index 54c5632..303c8e5 100644
--- a/tests/unit/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java
+++ b/tests/functional/com/android/documentsui/dirlist/DirectoryAddonsAdapterTest.java
@@ -187,10 +187,16 @@
}
private static class DummyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
+
@Override
- public int getItemCount() { return 0; }
+ public int getItemCount() {
+ return 0;
+ }
+
@Override
- public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {}
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ }
+
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return null;
diff --git a/tests/unit/com/android/documentsui/dirlist/ModelBackedDocumentsAdapterTest.java b/tests/functional/com/android/documentsui/dirlist/ModelBackedDocumentsAdapterTest.java
similarity index 100%
rename from tests/unit/com/android/documentsui/dirlist/ModelBackedDocumentsAdapterTest.java
rename to tests/functional/com/android/documentsui/dirlist/ModelBackedDocumentsAdapterTest.java
diff --git a/tests/unit/com/android/documentsui/inspector/DocumentLoaderPerfTest.java b/tests/functional/com/android/documentsui/inspector/DocumentLoaderPerfTest.java
similarity index 97%
rename from tests/unit/com/android/documentsui/inspector/DocumentLoaderPerfTest.java
rename to tests/functional/com/android/documentsui/inspector/DocumentLoaderPerfTest.java
index 10b53cb..5755565 100644
--- a/tests/unit/com/android/documentsui/inspector/DocumentLoaderPerfTest.java
+++ b/tests/functional/com/android/documentsui/inspector/DocumentLoaderPerfTest.java
@@ -16,11 +16,10 @@
package com.android.documentsui.inspector;
import android.content.Context;
+
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
-import org.junit.Before;
-
/**
* This test just like DocumentLoaderTest except that this test runs in real context environment.
*/
diff --git a/tests/unit/com/android/documentsui/inspector/DocumentLoaderTest.java b/tests/functional/com/android/documentsui/inspector/DocumentLoaderTest.java
similarity index 95%
rename from tests/unit/com/android/documentsui/inspector/DocumentLoaderTest.java
rename to tests/functional/com/android/documentsui/inspector/DocumentLoaderTest.java
index fe97c2c..8a2b21f 100644
--- a/tests/unit/com/android/documentsui/inspector/DocumentLoaderTest.java
+++ b/tests/functional/com/android/documentsui/inspector/DocumentLoaderTest.java
@@ -94,8 +94,6 @@
/**
* Tests the loader using the Inspector Content provider. This test that we got valid info back
* from the loader.
- *
- * @throws Exception
*/
@Test
public void testLoadsDocument() throws Exception {
@@ -116,8 +114,6 @@
/**
* Test invalid uri, DocumentInfo returned should be null.
- *
- * @throws Exception
*/
@Test
public void testInvalidInput() throws Exception {
@@ -144,13 +140,14 @@
// this is a test double that requires explicitly loading. @see TestLoaderManager
mLoaderManager.getLoader(0).startLoading();
fail("Should have thrown exception.");
- } catch (Exception expected) {}
+ } catch (Exception expected) {
+ }
}
@Test
public void testDir_loadNumberOfChildren() throws Exception {
Uri dirUri = DocumentsContract.buildDocumentUri(
- InspectorProvider.AUTHORITY, DIR_TOP);
+ InspectorProvider.AUTHORITY, DIR_TOP);
DocumentInfo info = DocumentInfo.fromUri(mResolver, dirUri, mUserId);
@@ -165,7 +162,7 @@
@Test
public void testDir_notADirectory() throws Exception {
Uri uri = DocumentsContract.buildDocumentUri(
- InspectorProvider.AUTHORITY, NOT_DIRECTORY);
+ InspectorProvider.AUTHORITY, NOT_DIRECTORY);
DocumentInfo info = DocumentInfo.fromUri(mResolver, uri, mUserId);
LatchedConsumer<Integer> consumer = new LatchedConsumer<>(1);
@@ -174,11 +171,12 @@
mLoader.loadDirCount(info, consumer);
mLoaderManager.getLoader(0).startLoading();
fail("should have thrown exception");
- } catch (Exception expected) {}
+ } catch (Exception expected) {
+ }
}
@Test
- public void testLoadMetadata() throws Exception {
+ public void testLoadMetadata() throws Exception {
Uri uri = DocumentsContract.buildDocumentUri(
InspectorProvider.AUTHORITY, InspectorProvider.TEST_JPEG);
LatchedConsumer<Bundle> consumer = new LatchedConsumer<>(1);
@@ -195,7 +193,7 @@
}
@Test
- public void testLoadMetadata_Unsupported() throws Exception {
+ public void testLoadMetadata_Unsupported() throws Exception {
Uri uri = DocumentsContract.buildDocumentUri(
InspectorProvider.AUTHORITY, InspectorProvider.INVALID_JPEG);
LatchedConsumer<Bundle> consumer = new LatchedConsumer<>(1);
diff --git a/tests/unit/com/android/documentsui/overlay/OverlayableTest.java b/tests/functional/com/android/documentsui/overlay/OverlayableTest.java
similarity index 96%
rename from tests/unit/com/android/documentsui/overlay/OverlayableTest.java
rename to tests/functional/com/android/documentsui/overlay/OverlayableTest.java
index 17d437e..d56470a 100644
--- a/tests/unit/com/android/documentsui/overlay/OverlayableTest.java
+++ b/tests/functional/com/android/documentsui/overlay/OverlayableTest.java
@@ -99,10 +99,10 @@
@Test
public void testDimen_gridItemRadius_isReasonable() {
- int MAX_RADIUS = 160;
+ int maxRadius = 160;
assertThat(
mTargetContext.getResources().getDimensionPixelSize(
- R.dimen.grid_item_radius)).isLessThan(MAX_RADIUS);
+ R.dimen.grid_item_radius)).isLessThan(maxRadius);
assertThat(
mTargetContext.getResources().getDimensionPixelSize(
R.dimen.grid_item_radius)).isAtLeast(0);
diff --git a/tests/unit/com/android/documentsui/services/AbstractCopyJobTest.java b/tests/functional/com/android/documentsui/services/AbstractCopyJobTest.java
similarity index 100%
rename from tests/unit/com/android/documentsui/services/AbstractCopyJobTest.java
rename to tests/functional/com/android/documentsui/services/AbstractCopyJobTest.java
diff --git a/tests/unit/com/android/documentsui/services/AbstractJobTest.java b/tests/functional/com/android/documentsui/services/AbstractJobTest.java
similarity index 98%
rename from tests/unit/com/android/documentsui/services/AbstractJobTest.java
rename to tests/functional/com/android/documentsui/services/AbstractJobTest.java
index 19138f9..290d242 100644
--- a/tests/unit/com/android/documentsui/services/AbstractJobTest.java
+++ b/tests/functional/com/android/documentsui/services/AbstractJobTest.java
@@ -45,7 +45,7 @@
@MediumTest
public abstract class AbstractJobTest<T extends Job> extends AndroidTestCase {
- static String AUTHORITY = StubProvider.DEFAULT_AUTHORITY;
+ static final String AUTHORITY = StubProvider.DEFAULT_AUTHORITY;
static final byte[] HAM_BYTES = "ham and cheese".getBytes();
static final byte[] FRUITY_BYTES = "I love fruit cakes!".getBytes();
diff --git a/tests/unit/com/android/documentsui/services/CopyJobTest.java b/tests/functional/com/android/documentsui/services/CopyJobTest.java
similarity index 99%
rename from tests/unit/com/android/documentsui/services/CopyJobTest.java
rename to tests/functional/com/android/documentsui/services/CopyJobTest.java
index 8d98b27..fd552d1 100644
--- a/tests/unit/com/android/documentsui/services/CopyJobTest.java
+++ b/tests/functional/com/android/documentsui/services/CopyJobTest.java
@@ -17,6 +17,7 @@
package com.android.documentsui.services;
import static com.android.documentsui.services.FileOperationService.OPERATION_COPY;
+
import static com.google.common.collect.Lists.newArrayList;
import android.net.Uri;
diff --git a/tests/unit/com/android/documentsui/services/DeleteJobTest.java b/tests/functional/com/android/documentsui/services/DeleteJobTest.java
similarity index 96%
rename from tests/unit/com/android/documentsui/services/DeleteJobTest.java
rename to tests/functional/com/android/documentsui/services/DeleteJobTest.java
index a200b3e..55e8044 100644
--- a/tests/unit/com/android/documentsui/services/DeleteJobTest.java
+++ b/tests/functional/com/android/documentsui/services/DeleteJobTest.java
@@ -17,6 +17,7 @@
package com.android.documentsui.services;
import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE;
+
import static com.google.common.collect.Lists.newArrayList;
import android.net.Uri;
@@ -59,7 +60,7 @@
/**
* Creates a job with a stack consisting to the default src directory.
*/
- private final DeleteJob createJob(List<Uri> srcs, Uri srcParent) throws Exception {
+ private DeleteJob createJob(List<Uri> srcs, Uri srcParent) throws Exception {
Uri stack = DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId);
return createJob(OPERATION_DELETE, srcs, srcParent, stack);
}
diff --git a/tests/unit/com/android/documentsui/services/FileOperationServiceTest.java b/tests/functional/com/android/documentsui/services/FileOperationServiceTest.java
similarity index 96%
rename from tests/unit/com/android/documentsui/services/FileOperationServiceTest.java
rename to tests/functional/com/android/documentsui/services/FileOperationServiceTest.java
index 9670747..1816ed5 100644
--- a/tests/unit/com/android/documentsui/services/FileOperationServiceTest.java
+++ b/tests/functional/com/android/documentsui/services/FileOperationServiceTest.java
@@ -134,7 +134,7 @@
try {
startService(createCopyIntent(new ArrayList<>(), BETA_DOC));
fail("Should have throw exception.");
- } catch(IllegalArgumentException expected) {
+ } catch (IllegalArgumentException expected) {
// We're sending a naughty empty list that should result in an IllegalArgumentException.
}
startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC));
@@ -328,7 +328,7 @@
stack.push(dest);
List<Uri> uris = new ArrayList<>(files.size());
- for (DocumentInfo file: files) {
+ for (DocumentInfo file : files) {
uris.add(file.derivedUri);
}
@@ -342,7 +342,7 @@
DocumentStack stack = new DocumentStack();
List<Uri> uris = new ArrayList<>(files.size());
- for (DocumentInfo file: files) {
+ for (DocumentInfo file : files) {
uris.add(file.derivedUri);
}
@@ -443,15 +443,15 @@
public Parcelable.Creator<TestFileOperation> CREATOR =
new Parcelable.Creator<TestFileOperation>() {
- @Override
- public TestFileOperation createFromParcel(Parcel source) {
- throw new UnsupportedOperationException("Can't create from a parcel.");
- }
+ @Override
+ public TestFileOperation createFromParcel(Parcel source) {
+ throw new UnsupportedOperationException("Can't create from a parcel.");
+ }
- @Override
- public TestFileOperation[] newArray(int size) {
- throw new UnsupportedOperationException("Can't create a new array.");
- }
- };
+ @Override
+ public TestFileOperation[] newArray(int size) {
+ throw new UnsupportedOperationException("Can't create a new array.");
+ }
+ };
}
}
diff --git a/tests/unit/com/android/documentsui/services/JobErrorHandlingTest.java b/tests/functional/com/android/documentsui/services/JobErrorHandlingTest.java
similarity index 97%
rename from tests/unit/com/android/documentsui/services/JobErrorHandlingTest.java
rename to tests/functional/com/android/documentsui/services/JobErrorHandlingTest.java
index 680f945..ba3373f 100644
--- a/tests/unit/com/android/documentsui/services/JobErrorHandlingTest.java
+++ b/tests/functional/com/android/documentsui/services/JobErrorHandlingTest.java
@@ -17,6 +17,7 @@
package com.android.documentsui.services;
import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE;
+
import static com.google.common.collect.Lists.newArrayList;
import android.net.Uri;
@@ -78,7 +79,7 @@
/**
* Creates a job with a stack consisting to the default src directory.
*/
- private final DeleteJob createJob(List<Uri> srcs, Uri srcParent) throws Exception {
+ private DeleteJob createJob(List<Uri> srcs, Uri srcParent) throws Exception {
Uri stack = DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId);
return createJob(OPERATION_DELETE, srcs, srcParent, stack);
}
diff --git a/tests/unit/com/android/documentsui/services/MoveJobTest.java b/tests/functional/com/android/documentsui/services/MoveJobTest.java
similarity index 99%
rename from tests/unit/com/android/documentsui/services/MoveJobTest.java
rename to tests/functional/com/android/documentsui/services/MoveJobTest.java
index 1fc2fd3..4b032f5 100644
--- a/tests/unit/com/android/documentsui/services/MoveJobTest.java
+++ b/tests/functional/com/android/documentsui/services/MoveJobTest.java
@@ -17,6 +17,7 @@
package com.android.documentsui.services;
import static com.android.documentsui.services.FileOperationService.OPERATION_MOVE;
+
import static com.google.common.collect.Lists.newArrayList;
import android.net.Uri;
diff --git a/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java b/tests/functional/com/android/documentsui/ui/DarkThemeUiTest.java
similarity index 99%
rename from tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java
rename to tests/functional/com/android/documentsui/ui/DarkThemeUiTest.java
index 33938a2..870e8ac 100644
--- a/tests/unit/com/android/documentsui/ui/DarkThemeUiTest.java
+++ b/tests/functional/com/android/documentsui/ui/DarkThemeUiTest.java
@@ -89,4 +89,4 @@
assertTheme(R.styleable.ThemeColor, R.styleable.ThemeColor_android_colorPrimary,
mTheme.getResources().getColor(com.android.documentsui.R.color.primary, mTheme));
}
-}
\ No newline at end of file
+}
diff --git a/tests/unit/com/android/documentsui/ui/SearchBarScrollingViewBehaviorTest.java b/tests/functional/com/android/documentsui/ui/SearchBarScrollingViewBehaviorTest.java
similarity index 100%
rename from tests/unit/com/android/documentsui/ui/SearchBarScrollingViewBehaviorTest.java
rename to tests/functional/com/android/documentsui/ui/SearchBarScrollingViewBehaviorTest.java
diff --git a/tests/unit/com/android/documentsui/ui/ThemeUiTest.java b/tests/functional/com/android/documentsui/ui/ThemeUiTest.java
similarity index 100%
rename from tests/unit/com/android/documentsui/ui/ThemeUiTest.java
rename to tests/functional/com/android/documentsui/ui/ThemeUiTest.java
diff --git a/tests/unit/com/android/documentsui/ui/ThemeUiTestBase.java b/tests/functional/com/android/documentsui/ui/ThemeUiTestBase.java
similarity index 100%
rename from tests/unit/com/android/documentsui/ui/ThemeUiTestBase.java
rename to tests/functional/com/android/documentsui/ui/ThemeUiTestBase.java