Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/TestFilesInstaller.java

Issue 2318493003: Clean up PathUtils unused parameters. (Closed)
Patch Set: Fix more. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/CronetTestFramework.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 24 matching lines...) Expand all
35 } catch (IOException e) { 35 } catch (IOException e) {
36 // Make the test app crash and fail early. 36 // Make the test app crash and fail early.
37 throw new RuntimeException(e); 37 throw new RuntimeException(e);
38 } 38 }
39 } 39 }
40 40
41 /** 41 /**
42 * Returns the installed path of the test files. 42 * Returns the installed path of the test files.
43 */ 43 */
44 public static String getInstalledPath(Context context) { 44 public static String getInstalledPath(Context context) {
45 return PathUtils.getDataDirectory(context) + "/" + TEST_FILE_ASSET_PATH; 45 return PathUtils.getDataDirectory() + "/" + TEST_FILE_ASSET_PATH;
46 } 46 }
47 47
48 /** 48 /**
49 * Returns whether test files are installed. 49 * Returns whether test files are installed.
50 */ 50 */
51 private static boolean areFilesInstalled(Context context) { 51 private static boolean areFilesInstalled(Context context) {
52 // Checking for file directory is fine even when new files are added, 52 // Checking for file directory is fine even when new files are added,
53 // because the app will be re-installed and app data will be cleared. 53 // because the app will be re-installed and app data will be cleared.
54 File directory = new File(getInstalledPath(context)); 54 File directory = new File(getInstalledPath(context));
55 return directory.exists(); 55 return directory.exists();
56 } 56 }
57 57
58 /** 58 /**
59 * Installs test files that are included in {@code path}. 59 * Installs test files that are included in {@code path}.
60 * @params context Application context 60 * @params context Application context
61 * @params path 61 * @params path
62 */ 62 */
63 private static void install(Context context, String path) throws IOException { 63 private static void install(Context context, String path) throws IOException {
64 AssetManager assetManager = context.getAssets(); 64 AssetManager assetManager = context.getAssets();
65 String files[] = assetManager.list(path); 65 String files[] = assetManager.list(path);
66 Log.i(TAG, "Loading " + path + " ..."); 66 Log.i(TAG, "Loading " + path + " ...");
67 String root = PathUtils.getDataDirectory(context); 67 String root = PathUtils.getDataDirectory();
68 if (files.length == 0) { 68 if (files.length == 0) {
69 // The path is a file, so copy the file now. 69 // The path is a file, so copy the file now.
70 copyTestFile(context, path, root + "/" + path); 70 copyTestFile(context, path, root + "/" + path);
71 } else { 71 } else {
72 // The path is a directory, so recursively handle its files, since 72 // The path is a directory, so recursively handle its files, since
73 // the directory can contain subdirectories. 73 // the directory can contain subdirectories.
74 String fullPath = root + "/" + path; 74 String fullPath = root + "/" + path;
75 File dir = new File(fullPath); 75 File dir = new File(fullPath);
76 if (!dir.exists()) { 76 if (!dir.exists()) {
77 Log.i(TAG, "Creating directory " + fullPath + " ..."); 77 Log.i(TAG, "Creating directory " + fullPath + " ...");
(...skipping 19 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « components/cronet/android/test/src/org/chromium/net/CronetTestFramework.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698