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.net; | 5 package org.chromium.net; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.AssetManager; | 8 import android.content.res.AssetManager; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
11 import org.chromium.base.FileUtils; | 11 import org.chromium.base.FileUtils; |
12 import org.chromium.base.PathUtils; | 12 import org.chromium.base.PathUtils; |
13 import org.chromium.base.annotations.SuppressFBWarnings; | 13 import org.chromium.base.annotations.SuppressFBWarnings; |
14 | 14 |
15 import java.io.File; | 15 import java.io.File; |
16 import java.io.IOException; | 16 import java.io.IOException; |
17 | 17 |
18 /** | 18 /** |
19 * Helper class to install test files. | 19 * Helper class to install test files. |
20 */ | 20 */ |
21 public final class TestFilesInstaller { | 21 public final class TestFilesInstaller { |
22 private static final String TAG = "TestFilesInstaller"; | 22 private static final String TAG = TestFilesInstaller.class.getSimpleName(); |
23 // Name of the asset directory in which test files are stored. | 23 // Name of the asset directory in which test files are stored. |
24 private static final String TEST_FILE_ASSET_PATH = "test"; | 24 private static final String TEST_FILE_ASSET_PATH = "test"; |
25 | 25 |
26 /** | 26 /** |
27 * Installs test files if files have not been installed. | 27 * Installs test files if files have not been installed. |
28 */ | 28 */ |
29 public static void installIfNeeded(Context context) { | 29 public static void installIfNeeded(Context context) { |
30 if (areFilesInstalled(context)) { | 30 if (areFilesInstalled(context)) { |
31 return; | 31 return; |
32 } | 32 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 File destFile = new File(destFilePath); | 97 File destFile = new File(destFilePath); |
98 if (destFile.exists()) { | 98 if (destFile.exists()) { |
99 throw new IllegalStateException(srcFilePath + " already exists."); | 99 throw new IllegalStateException(srcFilePath + " already exists."); |
100 } | 100 } |
101 | 101 |
102 if (!FileUtils.extractAsset(context, srcFilePath, destFile)) { | 102 if (!FileUtils.extractAsset(context, srcFilePath, destFile)) { |
103 throw new IOException("Could not extract asset " + srcFilePath + "."
); | 103 throw new IOException("Could not extract asset " + srcFilePath + "."
); |
104 } | 104 } |
105 } | 105 } |
106 } | 106 } |
OLD | NEW |