OLD | NEW |
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.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
8 import android.util.Log; | 8 import android.util.Log; |
9 import android.util.Pair; | 9 import android.util.Pair; |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 final TestAwContentsClient contentsClient = new TestAwContentsClient(); | 161 final TestAwContentsClient contentsClient = new TestAwContentsClient(); |
162 final AwTestContainerView testContainerView = | 162 final AwTestContainerView testContainerView = |
163 createAwTestContainerViewOnMainSync(contentsClient); | 163 createAwTestContainerViewOnMainSync(contentsClient); |
164 final AwContents awContents = testContainerView.getAwContents(); | 164 final AwContents awContents = testContainerView.getAwContents(); |
165 final TestAwContentsClient.OnLoadResourceHelper onLoadResourceHelper = | 165 final TestAwContentsClient.OnLoadResourceHelper onLoadResourceHelper = |
166 contentsClient.getOnLoadResourceHelper(); | 166 contentsClient.getOnLoadResourceHelper(); |
167 | 167 |
168 final String aboutPageUrl = addAboutPageToTestServer(mWebServer); | 168 final String aboutPageUrl = addAboutPageToTestServer(mWebServer); |
169 | 169 |
170 int callCount = onLoadResourceHelper.getCallCount(); | 170 int callCount = onLoadResourceHelper.getCallCount(); |
171 int onPageFinishedCallCount = contentsClient.getOnPageFinishedHelper().g
etCallCount(); | |
172 | 171 |
173 loadUrlAsync(awContents, aboutPageUrl); | 172 loadUrlAsync(awContents, aboutPageUrl); |
174 | 173 |
175 onLoadResourceHelper.waitForCallback(callCount); | 174 onLoadResourceHelper.waitForCallback(callCount); |
176 assertEquals(aboutPageUrl, onLoadResourceHelper.getUrl()); | 175 assertEquals(aboutPageUrl, onLoadResourceHelper.getUrl()); |
177 } | 176 } |
178 | 177 |
179 @SmallTest | 178 @SmallTest |
180 @Feature({"Android-WebView"}) | 179 @Feature({"Android-WebView"}) |
181 public void testDoesNotCrashOnInvalidData() throws Throwable { | 180 public void testDoesNotCrashOnInvalidData() throws Throwable { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 @Feature({"Android-WebView"}) | 261 @Feature({"Android-WebView"}) |
263 public void testCalledForImage() throws Throwable { | 262 public void testCalledForImage() throws Throwable { |
264 final TestAwContentsClient contentsClient = new TestAwContentsClient(); | 263 final TestAwContentsClient contentsClient = new TestAwContentsClient(); |
265 final AwTestContainerView testContainerView = | 264 final AwTestContainerView testContainerView = |
266 createAwTestContainerViewOnMainSync(contentsClient); | 265 createAwTestContainerViewOnMainSync(contentsClient); |
267 final AwContents awContents = testContainerView.getAwContents(); | 266 final AwContents awContents = testContainerView.getAwContents(); |
268 final TestAwContentsClient.ShouldInterceptRequestHelper shouldInterceptR
equestHelper = | 267 final TestAwContentsClient.ShouldInterceptRequestHelper shouldInterceptR
equestHelper = |
269 contentsClient.getShouldInterceptRequestHelper(); | 268 contentsClient.getShouldInterceptRequestHelper(); |
270 | 269 |
271 final String imagePath = "/" + CommonResources.FAVICON_FILENAME; | 270 final String imagePath = "/" + CommonResources.FAVICON_FILENAME; |
272 final String imageUrl = mWebServer.setResponseBase64(imagePath, | 271 mWebServer.setResponseBase64(imagePath, |
273 CommonResources.FAVICON_DATA_BASE64, CommonResources.getImagePng
Headers(true)); | 272 CommonResources.FAVICON_DATA_BASE64, CommonResources.getImagePng
Headers(true)); |
274 final String pageWithImage = | 273 final String pageWithImage = |
275 addPageToTestServer(mWebServer, "/page_with_image.html", | 274 addPageToTestServer(mWebServer, "/page_with_image.html", |
276 CommonResources.getOnImageLoadedHtml(CommonResources.FAVICON
_FILENAME)); | 275 CommonResources.getOnImageLoadedHtml(CommonResources.FAVICON
_FILENAME)); |
277 | 276 |
278 int callCount = shouldInterceptRequestHelper.getCallCount(); | 277 int callCount = shouldInterceptRequestHelper.getCallCount(); |
279 loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWi
thImage); | 278 loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWi
thImage); |
280 shouldInterceptRequestHelper.waitForCallback(callCount, 2); | 279 shouldInterceptRequestHelper.waitForCallback(callCount, 2); |
281 | 280 |
282 assertEquals(2, shouldInterceptRequestHelper.getUrls().size()); | 281 assertEquals(2, shouldInterceptRequestHelper.getUrls().size()); |
(...skipping 16 matching lines...) Expand all Loading... |
299 CommonResources.makeHtmlPageFrom("", | 298 CommonResources.makeHtmlPageFrom("", |
300 "<iframe src=\"" + aboutPageUrl + "\"/>")); | 299 "<iframe src=\"" + aboutPageUrl + "\"/>")); |
301 | 300 |
302 int callCount = shouldInterceptRequestHelper.getCallCount(); | 301 int callCount = shouldInterceptRequestHelper.getCallCount(); |
303 loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWi
thIframe); | 302 loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWi
thIframe); |
304 shouldInterceptRequestHelper.waitForCallback(callCount, 2); | 303 shouldInterceptRequestHelper.waitForCallback(callCount, 2); |
305 assertEquals(2, shouldInterceptRequestHelper.getUrls().size()); | 304 assertEquals(2, shouldInterceptRequestHelper.getUrls().size()); |
306 assertEquals(aboutPageUrl, shouldInterceptRequestHelper.getUrls().get(1)
); | 305 assertEquals(aboutPageUrl, shouldInterceptRequestHelper.getUrls().get(1)
); |
307 } | 306 } |
308 } | 307 } |
OLD | NEW |