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

Unified Diff: base/android/javatests/src/org/chromium/base/test/TestFileUtil.java

Issue 10827380: [Android] Implement WebSettings.{get|set}Allow{Content|File}Access. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/android/content_settings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/javatests/src/org/chromium/base/test/TestFileUtil.java
diff --git a/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java b/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java
index 66ff0853f9a73af8a55fe4f1fef2b68f4a7436a2..36b243674d677781f9e84182df218c5a32ef5264 100644
--- a/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java
+++ b/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java
@@ -7,15 +7,46 @@ package org.chromium.base.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.io.Reader;
+import java.io.Writer;
import java.util.Arrays;
/**
* Utility class for dealing with files for test.
*/
public class TestFileUtil {
+ public static void createNewHtmlFile(String name, String title, String body)
+ throws IOException {
+ File file = new File(name);
+ if (!file.createNewFile()) {
+ throw new IOException("File \"" + name + "\" already exists");
+ }
+
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ writer.write("<html><meta charset=\"UTF-8\" />" +
+ "<head><title>" + title + "</title></head>" +
+ "<body>" +
+ (body != null ? body : "") +
+ "</body>" +
+ "</html>");
+ } finally {
+ if (writer != null) {
+ writer.close();
+ }
+ }
+ }
+
+ public static void deleteFile(String name) {
+ File file = new File(name);
+ file.delete();
+ }
+
/**
* @param fileName the file to read in.
* @param sizeLimit cap on the file size: will throw an exception if exceeded
« no previous file with comments | « no previous file | content/browser/android/content_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698