Chromium Code Reviews| 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 android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 | 8 |
| 9 import org.chromium.android_webview.AwContents; | 9 import org.chromium.android_webview.AwContents; |
| 10 import org.chromium.android_webview.test.util.CommonResources; | 10 import org.chromium.android_webview.test.util.CommonResources; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 1 /* numberOfCallsToWaitFor */, | 65 1 /* numberOfCallsToWaitFor */, |
| 66 WAIT_TIMEOUT_MS, | 66 WAIT_TIMEOUT_MS, |
| 67 TimeUnit.MILLISECONDS); | 67 TimeUnit.MILLISECONDS); |
| 68 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount, | 68 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount, |
| 69 1 /* numberOfCallsToWaitFor */, | 69 1 /* numberOfCallsToWaitFor */, |
| 70 WAIT_TIMEOUT_MS, | 70 WAIT_TIMEOUT_MS, |
| 71 TimeUnit.MILLISECONDS); | 71 TimeUnit.MILLISECONDS); |
| 72 assertEquals(1, onReceivedErrorHelper.getCallCount()); | 72 assertEquals(1, onReceivedErrorHelper.getCallCount()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /** | |
| 76 * If url1 is redirected url2, and url2 load is overridden, onPageFinished s hould still be | |
| 77 * called for url2. | |
| 78 * Steps: | |
| 79 * 1. load url1. url1 onPageStarted | |
| 80 * 2. server redirects url1 to url2. url2 onPageStarted | |
| 81 * 3. shouldOverridedUrlLoading called for url2 and returns true | |
| 82 * 4. url2 onPageFinishedCalled | |
| 83 */ | |
| 84 @MediumTest | |
| 85 @Feature({"AndroidWebView"}) | |
| 86 public void testOnPageFinishedCalledAfterRedirectedUrlIsOverridden() throws Throwable { | |
| 87 TestWebServer webServer = null; | |
| 88 | |
|
sgurun-gerrit only
2014/02/11 22:48:44
drop the empty line.
hush (inactive)
2014/02/11 23:13:30
Done.
| |
| 89 try { | |
| 90 webServer = new TestWebServer(false); | |
| 91 final String redirectTargetPath = "/redirect_target.html"; | |
| 92 // If you visit redirectUrl, you will be redirected to redirectTarge tUrl | |
| 93 final String redirectTargetUrl = webServer.setResponse(redirectTarge tPath, | |
| 94 "<html><body>hello world</body></html>", null); | |
| 95 final String redirectUrl = webServer.setRedirect("/302.html", redire ctTargetUrl); | |
| 96 | |
| 97 mContentsClient = new TestAwContentsClient() { | |
| 98 @Override | |
| 99 public boolean shouldOverrideUrlLoading(String url) { | |
| 100 if (url.equals(redirectTargetUrl)) { | |
| 101 return true; | |
| 102 } | |
| 103 return false; | |
| 104 } | |
| 105 }; | |
| 106 final AwTestContainerView testContainerView = | |
| 107 createAwTestContainerViewOnMainSync(mContentsClient); | |
| 108 mAwContents = testContainerView.getAwContents(); | |
| 109 | |
| 110 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelpe r = | |
| 111 mContentsClient.getOnPageFinishedHelper(); | |
| 112 | |
| 113 loadUrlSync(mAwContents, onPageFinishedHelper, redirectUrl); | |
| 114 | |
| 115 // onPageFinished needs to be called for redirectTargetUrl, but not for redirectUrl | |
| 116 assertEquals(1, onPageFinishedHelper.getCallCount()); | |
| 117 assertEquals(redirectTargetUrl, onPageFinishedHelper.getUrl()); | |
| 118 } finally { | |
| 119 if (webServer != null) webServer.shutdown(); | |
| 120 } | |
| 121 | |
|
sgurun-gerrit only
2014/02/11 22:48:44
drop the empty line
hush (inactive)
2014/02/11 23:13:30
Done.
| |
| 122 } | |
| 123 | |
| 75 @MediumTest | 124 @MediumTest |
| 76 @Feature({"AndroidWebView"}) | 125 @Feature({"AndroidWebView"}) |
| 77 public void testOnPageFinishedNotCalledForValidSubresources() throws Throwab le { | 126 public void testOnPageFinishedNotCalledForValidSubresources() throws Throwab le { |
| 78 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = | 127 TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = |
| 79 mContentsClient.getOnPageFinishedHelper(); | 128 mContentsClient.getOnPageFinishedHelper(); |
| 80 | 129 |
| 81 TestWebServer webServer = null; | 130 TestWebServer webServer = null; |
| 82 try { | 131 try { |
| 83 webServer = new TestWebServer(false); | 132 webServer = new TestWebServer(false); |
| 84 | 133 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, | 255 executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, |
| 207 "window.history.go(-1)"); | 256 "window.history.go(-1)"); |
| 208 | 257 |
| 209 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount); | 258 onPageFinishedHelper.waitForCallback(onPageFinishedCallCount); |
| 210 assertEquals(onPageStartedCallCount, onPageStartedHelper.getCallCoun t()); | 259 assertEquals(onPageStartedCallCount, onPageStartedHelper.getCallCoun t()); |
| 211 } finally { | 260 } finally { |
| 212 if (webServer != null) webServer.shutdown(); | 261 if (webServer != null) webServer.shutdown(); |
| 213 } | 262 } |
| 214 } | 263 } |
| 215 } | 264 } |
| OLD | NEW |