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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/AndroidWebViewTestBase.java

Issue 11187032: Handle resubmission of HTTP Posts. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: final nits Created 8 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.app.Instrumentation; 7 import android.app.Instrumentation;
8 import android.content.Context; 8 import android.content.Context;
9 import android.test.ActivityInstrumentationTestCase2; 9 import android.test.ActivityInstrumentationTestCase2;
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 final String url) throws Throwable { 117 final String url) throws Throwable {
118 runTestOnUiThread(new Runnable() { 118 runTestOnUiThread(new Runnable() {
119 @Override 119 @Override
120 public void run() { 120 public void run() {
121 awContents.loadUrl(new LoadUrlParams(url)); 121 awContents.loadUrl(new LoadUrlParams(url));
122 } 122 }
123 }); 123 });
124 } 124 }
125 125
126 /** 126 /**
127 * Posts url on the UI thread and blocks until onPageFinished is called.
128 */
129 protected void postUrlSync(final AwContents awContents,
130 CallbackHelper onPageFinishedHelper, final String url,
131 byte[] postData) throws Throwable {
132 int currentCallCount = onPageFinishedHelper.getCallCount();
133 postUrlAsync(awContents, url, postData);
134 onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_S ECONDS,
135 TimeUnit.SECONDS);
136 }
137
138 /**
139 * Loads url on the UI thread but does not block.
140 */
141 protected void postUrlAsync(final AwContents awContents,
142 final String url, byte[] postData) throws Throwable {
143 class PostUrl implements Runnable {
144 byte[] mPostData;
145 public PostUrl(byte[] postData) {
146 mPostData = postData;
147 }
148 @Override
149 public void run() {
150 awContents.loadUrl(LoadUrlParams.createLoadHttpPostParams(url,
151 mPostData));
152 }
153 }
154 runTestOnUiThread(new PostUrl(postData));
155 }
156
157 /**
127 * Loads data on the UI thread and blocks until onPageFinished is called. 158 * Loads data on the UI thread and blocks until onPageFinished is called.
128 */ 159 */
129 protected void loadDataSync(final AwContents awContents, 160 protected void loadDataSync(final AwContents awContents,
130 CallbackHelper onPageFinishedHelper, 161 CallbackHelper onPageFinishedHelper,
131 final String data, final String mimeType, 162 final String data, final String mimeType,
132 final boolean isBase64Encoded) throws Throwable { 163 final boolean isBase64Encoded) throws Throwable {
133 int currentCallCount = onPageFinishedHelper.getCallCount(); 164 int currentCallCount = onPageFinishedHelper.getCallCount();
134 loadDataAsync(awContents, data, mimeType, isBase64Encoded); 165 loadDataAsync(awContents, data, mimeType, isBase64Encoded);
135 onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_S ECONDS, 166 onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_S ECONDS,
136 TimeUnit.SECONDS); 167 TimeUnit.SECONDS);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * Executes the given snippet of JavaScript code within the given ContentVie w. Returns the 264 * Executes the given snippet of JavaScript code within the given ContentVie w. Returns the
234 * result of its execution in JSON format. 265 * result of its execution in JSON format.
235 */ 266 */
236 protected String executeJavaScriptAndWaitForResult(final AwContents awConten ts, 267 protected String executeJavaScriptAndWaitForResult(final AwContents awConten ts,
237 TestAwContentsClient viewClient, final String code) throws Throwable { 268 TestAwContentsClient viewClient, final String code) throws Throwable {
238 return JSUtils.executeJavaScriptAndWaitForResult(this, awContents, 269 return JSUtils.executeJavaScriptAndWaitForResult(this, awContents,
239 viewClient.getOnEvaluateJavaScriptResultHelper(), 270 viewClient.getOnEvaluateJavaScriptResultHelper(),
240 code); 271 code);
241 } 272 }
242 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698