OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 8 |
7 import android.os.Message; | 9 import android.os.Message; |
8 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
9 | 11 |
10 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 12 import org.apache.http.util.EncodingUtils; |
11 | 13 |
12 import org.apache.http.util.EncodingUtils; | |
13 import org.chromium.android_webview.AwContents; | 14 import org.chromium.android_webview.AwContents; |
14 import org.chromium.base.test.util.Feature; | 15 import org.chromium.base.test.util.Feature; |
15 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 16 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
16 import org.chromium.net.test.util.TestWebServer; | 17 import org.chromium.net.test.util.TestWebServer; |
17 | 18 |
18 import java.util.concurrent.TimeUnit; | 19 import java.util.concurrent.TimeUnit; |
19 import java.util.concurrent.TimeoutException; | 20 import java.util.concurrent.TimeoutException; |
20 | 21 |
21 /** | 22 /** |
22 * Tests if resubmission of post data is handled properly. | 23 * Tests if resubmission of post data is handled properly. |
23 */ | 24 */ |
24 public class AwContentsClientOnFormResubmissionTest extends AwTestBase { | 25 public class AwContentsClientOnFormResubmissionTest extends AwTestBase { |
25 | 26 |
26 private static class TestAwContentsClient | 27 private static class TestAwContentsClient |
27 extends org.chromium.android_webview.test.TestAwContentsClient { | 28 extends org.chromium.android_webview.test.TestAwContentsClient { |
28 | 29 |
29 // Number of times onFormResubmit is called. | 30 // Number of times onFormResubmit is called. |
30 private int mResubmissions = 0; | 31 private int mResubmissions; |
31 // Whether to resubmit Post data on reload. | 32 // Whether to resubmit Post data on reload. |
32 private boolean mResubmit = false; | 33 private boolean mResubmit; |
33 | 34 |
34 public int getResubmissions() { | 35 public int getResubmissions() { |
35 return mResubmissions; | 36 return mResubmissions; |
36 } | 37 } |
37 public void setResubmit(boolean resubmit) { | 38 public void setResubmit(boolean resubmit) { |
38 mResubmit = resubmit; | 39 mResubmit = resubmit; |
39 } | 40 } |
40 @Override | 41 @Override |
41 public void onFormResubmission(Message dontResend, Message resend) { | 42 public void onFormResubmission(Message dontResend, Message resend) { |
42 mResubmissions++; | 43 mResubmissions++; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 }); | 119 }); |
119 try { | 120 try { |
120 // Wait for page finished callback, or a timeout. A timeout is neces
sary | 121 // Wait for page finished callback, or a timeout. A timeout is neces
sary |
121 // to detect a dontResend response. | 122 // to detect a dontResend response. |
122 onPageFinishedHelper.waitForCallback(callCount, 1, TIMEOUT, TimeUnit
.SECONDS); | 123 onPageFinishedHelper.waitForCallback(callCount, 1, TIMEOUT, TimeUnit
.SECONDS); |
123 } catch (TimeoutException e) { | 124 } catch (TimeoutException e) { |
124 // Exception expected from testDontResend case. | 125 // Exception expected from testDontResend case. |
125 } | 126 } |
126 } | 127 } |
127 } | 128 } |
OLD | NEW |