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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/input/SelectFileDialogTest.java

Issue 443683002: Allow <input type="file" multiple /> to be used on Android JB MR2+. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.input; 5 package org.chromium.chrome.browser.input;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.provider.MediaStore; 9 import android.provider.MediaStore;
10 import android.test.suitebuilder.annotation.MediumTest; 10 import android.test.suitebuilder.annotation.MediumTest;
(...skipping 12 matching lines...) Expand all
23 23
24 /** 24 /**
25 * Integration test for select file dialog used for <input type="file" /> 25 * Integration test for select file dialog used for <input type="file" />
26 */ 26 */
27 public class SelectFileDialogTest extends ChromeShellTestBase { 27 public class SelectFileDialogTest extends ChromeShellTestBase {
28 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( 28 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
29 "<html><head><meta name=\"viewport\"" + 29 "<html><head><meta name=\"viewport\"" +
30 "content=\"width=device-width, initial-scale=2.0, maximum-scale=2.0\ " /></head>" + 30 "content=\"width=device-width, initial-scale=2.0, maximum-scale=2.0\ " /></head>" +
31 "<body><form action=\"about:blank\">" + 31 "<body><form action=\"about:blank\">" +
32 "<input id=\"input_file\" type=\"file\" /><br/>" + 32 "<input id=\"input_file\" type=\"file\" /><br/>" +
33 "<input id=\"input_file_multiple\" type=\"file\" multiple /><br />" +
33 "<input id=\"input_image\" type=\"file\" accept=\"image/*\" capture /><br/>" + 34 "<input id=\"input_image\" type=\"file\" accept=\"image/*\" capture /><br/>" +
34 "<input id=\"input_audio\" type=\"file\" accept=\"audio/*\" capture />" + 35 "<input id=\"input_audio\" type=\"file\" accept=\"audio/*\" capture />" +
35 "</form>" + 36 "</form>" +
36 "</body></html>"); 37 "</body></html>");
37 38
38 private ContentViewCore mContentViewCore; 39 private ContentViewCore mContentViewCore;
39 private ActivityWindowAndroidForTest mActivityWindowAndroidForTest; 40 private ActivityWindowAndroidForTest mActivityWindowAndroidForTest;
40 41
41 private static class ActivityWindowAndroidForTest extends ActivityWindowAndr oid { 42 private static class ActivityWindowAndroidForTest extends ActivityWindowAndr oid {
42 public Intent lastIntent; 43 public Intent lastIntent;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 */ 90 */
90 @MediumTest 91 @MediumTest
91 @Feature({"TextInput", "Main"}) 92 @Feature({"TextInput", "Main"})
92 public void testSelectFileAndCancelRequest() throws Throwable { 93 public void testSelectFileAndCancelRequest() throws Throwable {
93 DOMUtils.clickNode(this, mContentViewCore, "input_file"); 94 DOMUtils.clickNode(this, mContentViewCore, "input_file");
94 assertTrue("SelectFileDialog never sent an intent.", 95 assertTrue("SelectFileDialog never sent an intent.",
95 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 96 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
96 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction()); 97 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction());
97 resetActivityWindowAndroidForTest(); 98 resetActivityWindowAndroidForTest();
98 99
100 DOMUtils.clickNode(this, mContentViewCore, "input_file_multiple");
101 assertTrue("SelectFileDialog never sent an intent.",
102 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
103 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction());
104 Intent contentIntent = (Intent)
105 mActivityWindowAndroidForTest.lastIntent.getParcelableExtra(Inte nt.EXTRA_INTENT);
106 assertNotNull(contentIntent);
107 assertTrue(contentIntent.hasExtra(Intent.EXTRA_ALLOW_MULTIPLE));
108 resetActivityWindowAndroidForTest();
109
99 DOMUtils.clickNode(this, mContentViewCore, "input_image"); 110 DOMUtils.clickNode(this, mContentViewCore, "input_image");
100 assertTrue("SelectFileDialog never sent an intent.", 111 assertTrue("SelectFileDialog never sent an intent.",
101 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 112 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
102 assertEquals(MediaStore.ACTION_IMAGE_CAPTURE, 113 assertEquals(MediaStore.ACTION_IMAGE_CAPTURE,
103 mActivityWindowAndroidForTest.lastIntent.getAction()); 114 mActivityWindowAndroidForTest.lastIntent.getAction());
104 resetActivityWindowAndroidForTest(); 115 resetActivityWindowAndroidForTest();
105 116
106 DOMUtils.clickNode(this, mContentViewCore, "input_audio"); 117 DOMUtils.clickNode(this, mContentViewCore, "input_audio");
107 assertTrue("SelectFileDialog never sent an intent.", 118 assertTrue("SelectFileDialog never sent an intent.",
108 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 119 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
109 assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION, 120 assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION,
110 mActivityWindowAndroidForTest.lastIntent.getAction()); 121 mActivityWindowAndroidForTest.lastIntent.getAction());
111 resetActivityWindowAndroidForTest(); 122 resetActivityWindowAndroidForTest();
112 } 123 }
113 124
114 private void resetActivityWindowAndroidForTest() { 125 private void resetActivityWindowAndroidForTest() {
115 UiUtils.runOnUiThread(getActivity(), new Runnable() { 126 UiUtils.runOnUiThread(getActivity(), new Runnable() {
116 @Override 127 @Override
117 public void run() { 128 public void run() {
118 mActivityWindowAndroidForTest.lastCallback.onIntentCompleted( 129 mActivityWindowAndroidForTest.lastCallback.onIntentCompleted(
119 mActivityWindowAndroidForTest, Activity.RESULT_CANCELED, null, null); 130 mActivityWindowAndroidForTest, Activity.RESULT_CANCELED, null, null);
120 } 131 }
121 }); 132 });
122 mActivityWindowAndroidForTest.lastCallback = null; 133 mActivityWindowAndroidForTest.lastCallback = null;
123 mActivityWindowAndroidForTest.lastIntent = null; 134 mActivityWindowAndroidForTest.lastIntent = null;
124 } 135 }
125 } 136 }
OLDNEW
« no previous file with comments | « no previous file | ui/android/java/src/org/chromium/ui/base/SelectFileDialog.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698