This source file includes following definitions.
- getTestFilePath
- getTestFileUrl
- encodeHtmlDataUri
package org.chromium.base.test.util;
import junit.framework.Assert;
import org.chromium.base.PathUtils;
public class UrlUtils {
private static final String DATA_DIR = "/chrome/test/data/";
public static String getTestFilePath(String path) {
return PathUtils.getExternalStorageDirectory() + DATA_DIR + path;
}
public static String getTestFileUrl(String path) {
return "file://" + getTestFilePath(path);
}
public static String encodeHtmlDataUri(String html) {
try {
String encoded =
"data:text/html;utf-8," +
java.net.URLEncoder.encode(html, "UTF-8");
encoded = encoded.replace("+", "%20");
return encoded;
} catch (java.io.UnsupportedEncodingException e) {
Assert.fail("Unsupported encoding: " + e.getMessage());
return null;
}
}
}