Chromium Code Reviews| 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.base.test.util; | 5 package org.chromium.base.test.util; |
| 6 | 6 |
| 7 import junit.framework.Assert; | 7 import junit.framework.Assert; |
| 8 | 8 |
| 9 import org.chromium.base.PathUtils; | 9 import org.chromium.base.PathUtils; |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 } | 34 } |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Returns the root of the test data directory. | 37 * Returns the root of the test data directory. |
| 38 */ | 38 */ |
| 39 public static String getIsolatedTestRoot() { | 39 public static String getIsolatedTestRoot() { |
| 40 return PathUtils.getExternalStorageDirectory() + "/chromium_tests_root"; | 40 return PathUtils.getExternalStorageDirectory() + "/chromium_tests_root"; |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Returns the root of the test data output directory. | |
| 45 */ | |
| 46 public static String getTestFileOutputRoot() { | |
| 47 return PathUtils.getExternalStorageDirectory() + "/chromium_tests_output _root"; | |
| 48 } | |
| 49 | |
| 50 /** | |
| 51 * Construct the full path of a test data output file. | |
| 52 * @param path Pathname relative to external/ | |
| 53 */ | |
| 54 public static String getTestFileOutputPath(String path) { | |
| 55 return getTestFileOutputRoot() + "/" + path; | |
|
jbudorick
2017/05/08 17:08:39
Should this check that path doesn't start with "/"
mikecase (-- gone --)
2017/05/08 18:35:31
This is all gone now. So...fixed
| |
| 56 } | |
| 57 | |
| 58 /** | |
| 44 * Construct a suitable URL for loading a test data file. | 59 * Construct a suitable URL for loading a test data file. |
| 45 * @param path Pathname relative to external/chrome/test/data | 60 * @param path Pathname relative to external/chrome/test/data |
| 46 */ | 61 */ |
| 47 public static String getTestFileUrl(String path) { | 62 public static String getTestFileUrl(String path) { |
| 48 return "file://" + getTestFilePath(path); | 63 return "file://" + getTestFilePath(path); |
| 49 } | 64 } |
| 50 | 65 |
| 51 // TODO(jbudorick): Remove this function once everything has been isolated a nd switched back | 66 // TODO(jbudorick): Remove this function once everything has been isolated a nd switched back |
| 52 // to getTestFileUrl. crbug/400499 | 67 // to getTestFileUrl. crbug/400499 |
| 53 /** | 68 /** |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 71 String encoded = | 86 String encoded = |
| 72 "data:text/html;utf-8," + java.net.URLEncoder.encode(html, " UTF-8"); | 87 "data:text/html;utf-8," + java.net.URLEncoder.encode(html, " UTF-8"); |
| 73 encoded = encoded.replace("+", "%20"); | 88 encoded = encoded.replace("+", "%20"); |
| 74 return encoded; | 89 return encoded; |
| 75 } catch (java.io.UnsupportedEncodingException e) { | 90 } catch (java.io.UnsupportedEncodingException e) { |
| 76 Assert.fail("Unsupported encoding: " + e.getMessage()); | 91 Assert.fail("Unsupported encoding: " + e.getMessage()); |
| 77 return null; | 92 return null; |
| 78 } | 93 } |
| 79 } | 94 } |
| 80 } | 95 } |
| OLD | NEW |