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

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

Issue 460453002: Fixed Compilation issues related to API Level of Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added call to quit() for OS version less than JELLY_BEAN_MR2 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
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.annotation.TargetApi;
7 import android.app.Activity; 8 import android.app.Activity;
8 import android.content.Intent; 9 import android.content.Intent;
10 import android.os.Build;
9 import android.provider.MediaStore; 11 import android.provider.MediaStore;
10 import android.test.suitebuilder.annotation.MediumTest; 12 import android.test.suitebuilder.annotation.MediumTest;
11 13
12 import org.chromium.base.test.util.Feature; 14 import org.chromium.base.test.util.Feature;
13 import org.chromium.base.test.util.UrlUtils; 15 import org.chromium.base.test.util.UrlUtils;
14 import org.chromium.chrome.shell.ChromeShellActivity; 16 import org.chromium.chrome.shell.ChromeShellActivity;
15 import org.chromium.chrome.shell.ChromeShellActivity.ActivityWindowAndroidFactor y; 17 import org.chromium.chrome.shell.ChromeShellActivity.ActivityWindowAndroidFactor y;
16 import org.chromium.chrome.shell.ChromeShellTestBase; 18 import org.chromium.chrome.shell.ChromeShellTestBase;
17 import org.chromium.content.browser.ContentViewCore; 19 import org.chromium.content.browser.ContentViewCore;
18 import org.chromium.content.browser.test.util.Criteria; 20 import org.chromium.content.browser.test.util.Criteria;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 mContentViewCore = getActivity().getActiveContentViewCore(); 83 mContentViewCore = getActivity().getActiveContentViewCore();
82 // TODO(aurimas) remove this wait once crbug.com/179511 is fixed. 84 // TODO(aurimas) remove this wait once crbug.com/179511 is fixed.
83 assertWaitForPageScaleFactorMatch(2); 85 assertWaitForPageScaleFactorMatch(2);
84 assertTrue( 86 assertTrue(
85 DOMUtils.waitForNonZeroNodeBounds(mContentViewCore, "input_file" )); 87 DOMUtils.waitForNonZeroNodeBounds(mContentViewCore, "input_file" ));
86 } 88 }
87 89
88 /** 90 /**
89 * Tests that clicks on <input type="file" /> trigger intent calls to Activi tyWindowAndroid. 91 * Tests that clicks on <input type="file" /> trigger intent calls to Activi tyWindowAndroid.
90 */ 92 */
93 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
91 @MediumTest 94 @MediumTest
92 @Feature({"TextInput", "Main"}) 95 @Feature({"TextInput", "Main"})
93 public void testSelectFileAndCancelRequest() throws Throwable { 96 public void testSelectFileAndCancelRequest() throws Throwable {
94 DOMUtils.clickNode(this, mContentViewCore, "input_file"); 97 DOMUtils.clickNode(this, mContentViewCore, "input_file");
95 assertTrue("SelectFileDialog never sent an intent.", 98 assertTrue("SelectFileDialog never sent an intent.",
96 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 99 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
97 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction()); 100 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction());
98 resetActivityWindowAndroidForTest(); 101 resetActivityWindowAndroidForTest();
99 102
100 DOMUtils.clickNode(this, mContentViewCore, "input_file_multiple"); 103 DOMUtils.clickNode(this, mContentViewCore, "input_file_multiple");
101 assertTrue("SelectFileDialog never sent an intent.", 104 assertTrue("SelectFileDialog never sent an intent.",
102 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 105 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
103 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction()); 106 assertEquals(Intent.ACTION_CHOOSER, mActivityWindowAndroidForTest.lastIn tent.getAction());
104 Intent contentIntent = (Intent) 107 Intent contentIntent = (Intent)
105 mActivityWindowAndroidForTest.lastIntent.getParcelableExtra(Inte nt.EXTRA_INTENT); 108 mActivityWindowAndroidForTest.lastIntent.getParcelableExtra(Inte nt.EXTRA_INTENT);
106 assertNotNull(contentIntent); 109 assertNotNull(contentIntent);
107 assertTrue(contentIntent.hasExtra(Intent.EXTRA_ALLOW_MULTIPLE)); 110 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
111 assertTrue(contentIntent.hasExtra(Intent.EXTRA_ALLOW_MULTIPLE));
112 }
108 resetActivityWindowAndroidForTest(); 113 resetActivityWindowAndroidForTest();
109 114
110 DOMUtils.clickNode(this, mContentViewCore, "input_image"); 115 DOMUtils.clickNode(this, mContentViewCore, "input_image");
111 assertTrue("SelectFileDialog never sent an intent.", 116 assertTrue("SelectFileDialog never sent an intent.",
112 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 117 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
113 assertEquals(MediaStore.ACTION_IMAGE_CAPTURE, 118 assertEquals(MediaStore.ACTION_IMAGE_CAPTURE,
114 mActivityWindowAndroidForTest.lastIntent.getAction()); 119 mActivityWindowAndroidForTest.lastIntent.getAction());
115 resetActivityWindowAndroidForTest(); 120 resetActivityWindowAndroidForTest();
116 121
117 DOMUtils.clickNode(this, mContentViewCore, "input_audio"); 122 DOMUtils.clickNode(this, mContentViewCore, "input_audio");
118 assertTrue("SelectFileDialog never sent an intent.", 123 assertTrue("SelectFileDialog never sent an intent.",
119 CriteriaHelper.pollForCriteria(new IntentSentCriteria())); 124 CriteriaHelper.pollForCriteria(new IntentSentCriteria()));
120 assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION, 125 assertEquals(MediaStore.Audio.Media.RECORD_SOUND_ACTION,
121 mActivityWindowAndroidForTest.lastIntent.getAction()); 126 mActivityWindowAndroidForTest.lastIntent.getAction());
122 resetActivityWindowAndroidForTest(); 127 resetActivityWindowAndroidForTest();
123 } 128 }
124 129
125 private void resetActivityWindowAndroidForTest() { 130 private void resetActivityWindowAndroidForTest() {
126 UiUtils.runOnUiThread(getActivity(), new Runnable() { 131 UiUtils.runOnUiThread(getActivity(), new Runnable() {
127 @Override 132 @Override
128 public void run() { 133 public void run() {
129 mActivityWindowAndroidForTest.lastCallback.onIntentCompleted( 134 mActivityWindowAndroidForTest.lastCallback.onIntentCompleted(
130 mActivityWindowAndroidForTest, Activity.RESULT_CANCELED, null, null); 135 mActivityWindowAndroidForTest, Activity.RESULT_CANCELED, null, null);
131 } 136 }
132 }); 137 });
133 mActivityWindowAndroidForTest.lastCallback = null; 138 mActivityWindowAndroidForTest.lastCallback = null;
134 mActivityWindowAndroidForTest.lastIntent = null; 139 mActivityWindowAndroidForTest.lastIntent = null;
135 } 140 }
136 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698