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.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
8 import android.util.Pair; | 8 import android.util.Pair; |
9 | 9 |
10 import org.chromium.android_webview.AwContents; | 10 import org.chromium.android_webview.AwContents; |
(...skipping 25 matching lines...) Expand all Loading... |
36 | 36 |
37 private static class ShouldInterceptRequestClient extends TestAwContentsClie
nt { | 37 private static class ShouldInterceptRequestClient extends TestAwContentsClie
nt { |
38 | 38 |
39 public static class ShouldInterceptRequestHelper extends CallbackHelper
{ | 39 public static class ShouldInterceptRequestHelper extends CallbackHelper
{ |
40 private List<String> mShouldInterceptRequestUrls = new ArrayList<Str
ing>(); | 40 private List<String> mShouldInterceptRequestUrls = new ArrayList<Str
ing>(); |
41 private ConcurrentHashMap<String, AwWebResourceResponse> mReturnValu
esByUrls = | 41 private ConcurrentHashMap<String, AwWebResourceResponse> mReturnValu
esByUrls = |
42 new ConcurrentHashMap<String, AwWebResourceResponse>(); | 42 new ConcurrentHashMap<String, AwWebResourceResponse>(); |
43 private ConcurrentHashMap<String, AwWebResourceRequest> mRequestsByU
rls = | 43 private ConcurrentHashMap<String, AwWebResourceRequest> mRequestsByU
rls = |
44 new ConcurrentHashMap<String, AwWebResourceRequest>(); | 44 new ConcurrentHashMap<String, AwWebResourceRequest>(); |
45 // This is read on another thread, so needs to be marked volatile. | 45 // This is read on another thread, so needs to be marked volatile. |
46 private volatile AwWebResourceResponse mShouldInterceptRequestReturn
Value = null; | 46 private volatile AwWebResourceResponse mShouldInterceptRequestReturn
Value; |
47 void setReturnValue(AwWebResourceResponse value) { | 47 void setReturnValue(AwWebResourceResponse value) { |
48 mShouldInterceptRequestReturnValue = value; | 48 mShouldInterceptRequestReturnValue = value; |
49 } | 49 } |
50 void setReturnValueForUrl(String url, AwWebResourceResponse value) { | 50 void setReturnValueForUrl(String url, AwWebResourceResponse value) { |
51 mReturnValuesByUrls.put(url, value); | 51 mReturnValuesByUrls.put(url, value); |
52 } | 52 } |
53 public List<String> getUrls() { | 53 public List<String> getUrls() { |
54 assert getCallCount() > 0; | 54 assert getCallCount() > 0; |
55 return mShouldInterceptRequestUrls; | 55 return mShouldInterceptRequestUrls; |
56 } | 56 } |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 mAwContents = mTestContainerView.getAwContents(); | 869 mAwContents = mTestContainerView.getAwContents(); |
870 loadUrlAsync(mAwContents, "http://www.example.com"); | 870 loadUrlAsync(mAwContents, "http://www.example.com"); |
871 waitForShouldInterceptRequest.await(); | 871 waitForShouldInterceptRequest.await(); |
872 // The following call will try to send an IPC and wait for a reply from
renderer. | 872 // The following call will try to send an IPC and wait for a reply from
renderer. |
873 // We do not check the actual result, because it can be bogus. The impor
tant | 873 // We do not check the actual result, because it can be bogus. The impor
tant |
874 // thing is that the call does not cause a deadlock. | 874 // thing is that the call does not cause a deadlock. |
875 executeJavaScriptAndWaitForResult(mAwContents, client, "1+1"); | 875 executeJavaScriptAndWaitForResult(mAwContents, client, "1+1"); |
876 signalAfterSendingIpc.countDown(); | 876 signalAfterSendingIpc.countDown(); |
877 } | 877 } |
878 } | 878 } |
OLD | NEW |