Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: ui/android/junit/src/org/chromium/ui/base/SelectFileDialogTest.java

Issue 2663523002: Record whether a file picker specialized for media content can be used (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/junit/src/org/chromium/ui/base/SelectFileDialogTest.java
diff --git a/ui/android/junit/src/org/chromium/ui/base/SelectFileDialogTest.java b/ui/android/junit/src/org/chromium/ui/base/SelectFileDialogTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c195f11a9856e7ac69e0ff97f461caa60034e68
--- /dev/null
+++ b/ui/android/junit/src/org/chromium/ui/base/SelectFileDialogTest.java
@@ -0,0 +1,62 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.ui.base;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Tests logic in the SelectFileDialog class.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class SelectFileDialogTest {
+ /**
+ * Returns the determined scope for the accepted |fileTypes|.
+ */
+ private int scopeForFileTypes(String... fileTypes) {
+ SelectFileDialog instance = SelectFileDialog.create((long) 0 /* nativeSelectFileDialog */);
+ instance.setFileTypesForTests(new ArrayList<String>(Arrays.asList(fileTypes)));
+
+ return instance.determineSelectFileDialogScope();
+ }
+
+ @Test
+ public void testDetermineSelectFileDialogScope() {
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC, scopeForFileTypes());
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC, scopeForFileTypes("*/*"));
+ assertEquals(
+ SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC, scopeForFileTypes("text/plain"));
+
+ assertEquals(
+ SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_IMAGES, scopeForFileTypes("image/*"));
+ assertEquals(
+ SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_IMAGES, scopeForFileTypes("image/png"));
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC,
+ scopeForFileTypes("image/*", "test/plain"));
+
+ assertEquals(
+ SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_VIDEOS, scopeForFileTypes("video/*"));
+ assertEquals(
+ SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_VIDEOS, scopeForFileTypes("video/ogg"));
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC,
+ scopeForFileTypes("video/*", "test/plain"));
+
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_IMAGES_AND_VIDEOS,
+ scopeForFileTypes("video/*", "image/*"));
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_IMAGES_AND_VIDEOS,
+ scopeForFileTypes("image/jpeg", "video/ogg"));
+ assertEquals(SelectFileDialog.SELECT_FILE_DIALOG_SCOPE_GENERIC,
+ scopeForFileTypes("video/*", "image/*", "text/plain"));
+ }
+}
« no previous file with comments | « ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698