remove usage of dir sqlite_stmt_journals to store temp files in tests.
diff --git a/tests/tests/content/src/android/content/cts/ContentResolverTest.java b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
index c6cb7ac..f28b6f0 100644
--- a/tests/tests/content/src/android/content/cts/ContentResolverTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
@@ -227,7 +227,9 @@
)
})
public void testOpenOutputStream() throws IOException {
- Uri uri = Uri.parse(ContentResolver.SCHEME_FILE + ":///sqlite_stmt_journals/temp.jpg");
+ Uri uri = Uri.parse(ContentResolver.SCHEME_FILE + "://" +
+ getContext().getCacheDir().getAbsolutePath() +
+ "/temp.jpg");
OutputStream os = mContentResolver.openOutputStream(uri);
assertNotNull(os);
os.close();
@@ -303,7 +305,9 @@
args = {android.net.Uri.class, java.lang.String.class}
)
public void testOpenFileDescriptor() throws IOException {
- Uri uri = Uri.parse(ContentResolver.SCHEME_FILE + ":///sqlite_stmt_journals/temp.jpg");
+ Uri uri = Uri.parse(ContentResolver.SCHEME_FILE + "://" +
+ getContext().getCacheDir().getAbsolutePath() +
+ "/temp.jpg");
ParcelFileDescriptor pfd = mContentResolver.openFileDescriptor(uri, "w");
assertNotNull(pfd);
pfd.close();
diff --git a/tests/tests/graphics/src/android/graphics/cts/MovieTest.java b/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
index 56421fd..ab875bb 100644
--- a/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
@@ -24,6 +24,7 @@
import java.io.OutputStream;
import android.app.cts.MockActivity;
+import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Movie;
import android.graphics.Paint;
@@ -85,7 +86,9 @@
@BrokenTest("mMovie is null")
public void testDecodeFile() throws Exception {
mMovie = null;
- File imagefile = new File("/sqlite_stmt_journals", "animated.gif");
+ File dbDir = getInstrumentation().getTargetContext().getDir("tests",
+ Context.MODE_PRIVATE);
+ File imagefile = new File(dbDir, "animated.gif");
if (imagefile.exists()) {
imagefile.delete();
}
diff --git a/tests/tests/util/src/android/util/cts/PrintWriterPrinterTest.java b/tests/tests/util/src/android/util/cts/PrintWriterPrinterTest.java
index ea9d3d2..3c36bf3 100644
--- a/tests/tests/util/src/android/util/cts/PrintWriterPrinterTest.java
+++ b/tests/tests/util/src/android/util/cts/PrintWriterPrinterTest.java
@@ -24,6 +24,7 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
+import android.content.Context;
import android.test.AndroidTestCase;
import android.util.PrintWriterPrinter;
import dalvik.annotation.TestTargets;
@@ -37,7 +38,8 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- mFile = new File("sqlite_stmt_journals","print.log");
+ File dbDir = getContext().getDir("tests", Context.MODE_PRIVATE);
+ mFile = new File(dbDir,"print.log");
if (!mFile.exists())
mFile.createNewFile();
}
diff --git a/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java b/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
index 7357ad3..67aa005 100644
--- a/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
@@ -26,6 +26,7 @@
import org.xmlpull.v1.XmlPullParser;
+import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -131,9 +132,8 @@
ImageView iv1 = new ImageView(getContext());
imageSwitcher.addView(iv1);
- // because I can not write file in /data/data/com.android, it will throw IOException.
- // I just write the image file into database test path.
- File imagefile = new File("/sqlite_stmt_journals", "tempimage.jpg");
+ File dbDir = getContext().getDir("tests", Context.MODE_PRIVATE);
+ File imagefile = new File(dbDir, "tempimage.jpg");
if (imagefile.exists()) {
imagefile.delete();
}
diff --git a/tests/tests/widget/src/android/widget/cts/ImageViewTest.java b/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
index 295ac93..2bf064c 100644
--- a/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
@@ -264,9 +264,9 @@
mImageView.setImageURI(null);
assertNull(mImageView.getDrawable());
- // because I can not write file in /data/data/com.android, it will throw IOException.
- // I just write the image file into database test path.
- File imagefile = new File("/sqlite_stmt_journals", "tempimage.jpg");
+ File dbDir = getInstrumentation().getTargetContext().getDir("tests",
+ Context.MODE_PRIVATE);
+ File imagefile = new File(dbDir, "tempimage.jpg");
if (imagefile.exists()) {
imagefile.delete();
}