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..e8d602d53f6e6f5130b803c5d0b1c54e7e33d70e 100644 |
--- a/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java |
+++ b/base/android/javatests/src/org/chromium/base/test/TestFileUtil.java |
@@ -7,6 +7,7 @@ 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.Reader; |
@@ -16,6 +17,32 @@ 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"); |
+ } |
+ |
+ FileOutputStream out = null; |
+ try { |
+ out = new FileOutputStream(file); |
+ out.write(("<html><head><title>" + title + |
+ "</title><head><body>" + |
+ (body != null ? body : "") + |
+ "</body></html>").getBytes()); |
Satish
2012/08/20 10:16:57
this is going to get the encoded string in the pla
mnaganov (inactive)
2012/08/20 13:32:55
So far, tests were using Latin-1, but I see your p
|
+ } finally { |
+ if (out != null) { |
+ out.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 |