List of usage examples for android.webkit WebSettings LOAD_NO_CACHE
int LOAD_NO_CACHE
To view the source code for android.webkit WebSettings LOAD_NO_CACHE.
Click Source Link
From source file:org.chromium.android_webview.test.AwSettingsTest.java
@SmallTest @Feature({ "AndroidWebView", "Preferences" }) // As our implementation of network loads blocking uses the same net::URLRequest settings, make // sure that setting cache mode doesn't accidentally enable network loads. The reference // behaviour is that when network loads are blocked, setting cache mode has no effect. public void testCacheModeWithBlockedNetworkLoads() throws Throwable { final TestAwContentsClient contentClient = new TestAwContentsClient(); final AwTestContainerView testContainer = createAwTestContainerViewOnMainSync(contentClient); final AwContents awContents = testContainer.getAwContents(); final AwSettings awSettings = getAwSettingsOnUiThread(testContainer.getAwContents()); clearCacheOnUiThread(awContents, true); assertEquals(WebSettings.LOAD_DEFAULT, awSettings.getCacheMode()); awSettings.setBlockNetworkLoads(true); TestWebServer webServer = null;/* w w w. ja v a 2 s .c om*/ try { webServer = new TestWebServer(false); final String htmlPath = "/testCacheModeWithBlockedNetworkLoads.html"; final String url = webServer.setResponse(htmlPath, "response", null); loadUrlSyncAndExpectError(awContents, contentClient.getOnPageFinishedHelper(), contentClient.getOnReceivedErrorHelper(), url); assertEquals(0, webServer.getRequestCount(htmlPath)); awSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); loadUrlSyncAndExpectError(awContents, contentClient.getOnPageFinishedHelper(), contentClient.getOnReceivedErrorHelper(), url); assertEquals(0, webServer.getRequestCount(htmlPath)); awSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); loadUrlSyncAndExpectError(awContents, contentClient.getOnPageFinishedHelper(), contentClient.getOnReceivedErrorHelper(), url); assertEquals(0, webServer.getRequestCount(htmlPath)); awSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY); loadUrlSyncAndExpectError(awContents, contentClient.getOnPageFinishedHelper(), contentClient.getOnReceivedErrorHelper(), url); assertEquals(0, webServer.getRequestCount(htmlPath)); } finally { if (webServer != null) webServer.shutdown(); } }