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.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Point; | 8 import android.graphics.Point; |
9 import android.net.http.SslError; | 9 import android.net.http.SslError; |
10 import android.os.Build; | 10 import android.os.Build; |
(...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 } | 1931 } |
1932 | 1932 |
1933 @SmallTest | 1933 @SmallTest |
1934 @Feature({"AndroidWebView", "Preferences"}) | 1934 @Feature({"AndroidWebView", "Preferences"}) |
1935 public void testBlockNetworkLoadsWithAudio() throws Throwable { | 1935 public void testBlockNetworkLoadsWithAudio() throws Throwable { |
1936 final TestAwContentsClient contentClient = new TestAwContentsClient(); | 1936 final TestAwContentsClient contentClient = new TestAwContentsClient(); |
1937 final AwTestContainerView testContainer = | 1937 final AwTestContainerView testContainer = |
1938 createAwTestContainerViewOnMainSync(contentClient); | 1938 createAwTestContainerViewOnMainSync(contentClient); |
1939 final AwContents awContents = testContainer.getAwContents(); | 1939 final AwContents awContents = testContainer.getAwContents(); |
1940 final AwSettings awSettings = getAwSettingsOnUiThread(awContents); | 1940 final AwSettings awSettings = getAwSettingsOnUiThread(awContents); |
1941 CallbackHelper callback = new CallbackHelper(); | 1941 final CallbackHelper callback = new CallbackHelper(); |
1942 awSettings.setJavaScriptEnabled(true); | 1942 awSettings.setJavaScriptEnabled(true); |
1943 | 1943 |
1944 TestWebServer webServer = null; | 1944 TestWebServer webServer = null; |
1945 try { | 1945 try { |
1946 webServer = new TestWebServer(false); | 1946 webServer = new TestWebServer(false); |
1947 final String httpPath = "/audio.mp3"; | 1947 final String httpPath = "/audio.mp3"; |
1948 // Don't care about the response is correct or not, just want | 1948 // Don't care about the response is correct or not, just want |
1949 // to know whether Url is accessed. | 1949 // to know whether Url is accessed. |
1950 final String audioUrl = webServer.setResponse(httpPath, "1", null); | 1950 final String audioUrl = webServer.setResponse(httpPath, "1", null); |
1951 | 1951 |
1952 String pageHtml = "<html><body><audio controls src='" + audioUrl + "
' " + | 1952 String pageHtml = "<html><body><audio controls src='" + audioUrl + "
' " + |
1953 "oncanplay=\"AudioEvent.onCanPlay();\" " + | 1953 "oncanplay=\"AudioEvent.onCanPlay();\" " + |
1954 "onerror=\"AudioEvent.onError();\" /> </body></html>"; | 1954 "onerror=\"AudioEvent.onError();\" /> </body></html>"; |
1955 // Actual test. Blocking should trigger onerror handler. | 1955 // Actual test. Blocking should trigger onerror handler. |
1956 awSettings.setBlockNetworkLoads(true); | 1956 awSettings.setBlockNetworkLoads(true); |
1957 awContents.addPossiblyUnsafeJavascriptInterface( | 1957 runTestOnUiThread(new Runnable() { |
1958 new AudioEvent(callback), "AudioEvent", null); | 1958 @Override |
| 1959 public void run() { |
| 1960 awContents.addPossiblyUnsafeJavascriptInterface( |
| 1961 new AudioEvent(callback), "AudioEvent", null); |
| 1962 } |
| 1963 }); |
1959 int count = callback.getCallCount(); | 1964 int count = callback.getCallCount(); |
1960 loadDataSync(awContents, contentClient.getOnPageFinishedHelper(), pa
geHtml, | 1965 loadDataSync(awContents, contentClient.getOnPageFinishedHelper(), pa
geHtml, |
1961 "text/html", false); | 1966 "text/html", false); |
1962 callback.waitForCallback(count, 1); | 1967 callback.waitForCallback(count, 1); |
1963 assertEquals(0, webServer.getRequestCount(httpPath)); | 1968 assertEquals(0, webServer.getRequestCount(httpPath)); |
1964 | 1969 |
1965 // The below test failed in Nexus Galaxy. | 1970 // The below test failed in Nexus Galaxy. |
1966 // See https://code.google.com/p/chromium/issues/detail?id=313463 | 1971 // See https://code.google.com/p/chromium/issues/detail?id=313463 |
1967 // Unblock should load normally. | 1972 // Unblock should load normally. |
1968 /* | 1973 /* |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 final AwContents awContents = webView.getAwContents(); | 2800 final AwContents awContents = webView.getAwContents(); |
2796 runTestOnUiThread(new Runnable() { | 2801 runTestOnUiThread(new Runnable() { |
2797 @Override | 2802 @Override |
2798 public void run() { | 2803 public void run() { |
2799 awContents.getContentViewCore().sendDoubleTapForTest( | 2804 awContents.getContentViewCore().sendDoubleTapForTest( |
2800 SystemClock.uptimeMillis(), x, y); | 2805 SystemClock.uptimeMillis(), x, y); |
2801 } | 2806 } |
2802 }); | 2807 }); |
2803 } | 2808 } |
2804 } | 2809 } |
OLD | NEW |