OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
9 | 9 |
10 import org.chromium.android_webview.AwBrowserProcess; | 10 import org.chromium.android_webview.AwBrowserProcess; |
11 import org.chromium.android_webview.AwContents; | 11 import org.chromium.android_webview.AwContents; |
12 import org.chromium.android_webview.AwContentsStatics; | 12 import org.chromium.android_webview.AwContentsStatics; |
13 import org.chromium.base.ContextUtils; | |
14 import org.chromium.base.PathUtils; | 13 import org.chromium.base.PathUtils; |
15 import org.chromium.base.test.util.Feature; | 14 import org.chromium.base.test.util.Feature; |
16 import org.chromium.net.test.util.TestWebServer; | 15 import org.chromium.net.test.util.TestWebServer; |
17 | 16 |
18 import java.io.File; | 17 import java.io.File; |
19 | 18 |
20 /** | 19 /** |
21 * Test suite for the HTTP cache. | 20 * Test suite for the HTTP cache. |
22 */ | 21 */ |
23 public class HttpCacheTest extends AwTestBase { | 22 public class HttpCacheTest extends AwTestBase { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 File webViewLegacyCacheDir = new File( | 75 File webViewLegacyCacheDir = new File( |
77 PathUtils.getDataDirectory(targetContext), "Cache"); | 76 PathUtils.getDataDirectory(targetContext), "Cache"); |
78 if (!webViewLegacyCacheDir.isDirectory()) { | 77 if (!webViewLegacyCacheDir.isDirectory()) { |
79 assertTrue(webViewLegacyCacheDir.mkdir()); | 78 assertTrue(webViewLegacyCacheDir.mkdir()); |
80 assertTrue(webViewLegacyCacheDir.isDirectory()); | 79 assertTrue(webViewLegacyCacheDir.isDirectory()); |
81 } | 80 } |
82 File dummyCacheFile = File.createTempFile("test", null, webViewLegacyCac
heDir); | 81 File dummyCacheFile = File.createTempFile("test", null, webViewLegacyCac
heDir); |
83 assertTrue(dummyCacheFile.exists()); | 82 assertTrue(dummyCacheFile.exists()); |
84 | 83 |
85 // Set up JNI bindings. | 84 // Set up JNI bindings. |
86 ContextUtils.initApplicationContext(targetContext.getApplicationContext(
)); | |
87 AwBrowserProcess.loadLibrary(targetContext); | 85 AwBrowserProcess.loadLibrary(targetContext); |
88 // No delay before removing the legacy cache files. | 86 // No delay before removing the legacy cache files. |
89 AwContentsStatics.setLegacyCacheRemovalDelayForTest(0); | 87 AwContentsStatics.setLegacyCacheRemovalDelayForTest(0); |
90 | 88 |
91 startBrowserProcess(); | 89 startBrowserProcess(); |
92 final TestAwContentsClient contentClient = new TestAwContentsClient(); | 90 final TestAwContentsClient contentClient = new TestAwContentsClient(); |
93 final AwTestContainerView testContainerView = | 91 final AwTestContainerView testContainerView = |
94 createAwTestContainerViewOnMainSync(contentClient); | 92 createAwTestContainerViewOnMainSync(contentClient); |
95 final AwContents awContents = testContainerView.getAwContents(); | 93 final AwContents awContents = testContainerView.getAwContents(); |
96 | 94 |
(...skipping 10 matching lines...) Expand all Loading... |
107 } finally { | 105 } finally { |
108 if (httpServer != null) { | 106 if (httpServer != null) { |
109 httpServer.shutdown(); | 107 httpServer.shutdown(); |
110 } | 108 } |
111 } | 109 } |
112 | 110 |
113 assertFalse(webViewLegacyCacheDir.exists()); | 111 assertFalse(webViewLegacyCacheDir.exists()); |
114 assertFalse(dummyCacheFile.exists()); | 112 assertFalse(dummyCacheFile.exists()); |
115 } | 113 } |
116 } | 114 } |
OLD | NEW |