Merge "Cannot test properly if a quality is 'unspecified'" into gingerbread
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
old mode 100644
new mode 100755
index 4c6259c..fdffd51
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -174,7 +174,8 @@
android.graphics.BitmapFactory.Options.class}
)
public void testDecodeFileDescriptor1() throws IOException {
- FileDescriptor input = obtainDescriptor(obtainPath());
+ ParcelFileDescriptor pfd = obtainParcelDescriptor(obtainPath());
+ FileDescriptor input = pfd.getFileDescriptor();
Rect r = new Rect(1, 1, 1, 1);
Bitmap b = BitmapFactory.decodeFileDescriptor(input, r, mOpt1);
assertNotNull(b);
@@ -191,7 +192,8 @@
args = {java.io.FileDescriptor.class}
)
public void testDecodeFileDescriptor2() throws IOException {
- FileDescriptor input = obtainDescriptor(obtainPath());
+ ParcelFileDescriptor pfd = obtainParcelDescriptor(obtainPath());
+ FileDescriptor input = pfd.getFileDescriptor();
Bitmap b = BitmapFactory.decodeFileDescriptor(input);
assertNotNull(b);
// Test the bitmap size
@@ -240,10 +242,11 @@
return mRes.openRawResource(R.drawable.start);
}
- private FileDescriptor obtainDescriptor(String path) throws IOException {
- File file = new File(path);
- return(ParcelFileDescriptor.open(file,
- ParcelFileDescriptor.MODE_READ_ONLY).getFileDescriptor());
+ private ParcelFileDescriptor obtainParcelDescriptor(String path)
+ throws IOException {
+ File file = new File(path);
+ return(ParcelFileDescriptor.open(file,
+ ParcelFileDescriptor.MODE_READ_ONLY));
}
private String obtainPath() throws IOException {
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
old mode 100644
new mode 100755
index e1ba12a..5cda2cb
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapRegionDecoderTest.java
@@ -157,7 +157,8 @@
public void testNewInstanceStringAndFileDescriptor() throws IOException {
for (int i = 0; i < RES_IDS.length; ++i) {
String filepath = obtainPath(i);
- FileDescriptor fd = obtainDescriptor(filepath);
+ ParcelFileDescriptor pfd = obtainParcelDescriptor(filepath);
+ FileDescriptor fd = pfd.getFileDescriptor();
try {
BitmapRegionDecoder decoder1 =
BitmapRegionDecoder.newInstance(filepath, false);
@@ -245,9 +246,11 @@
Bitmap wholeImage = BitmapFactory.decodeFile(filepath, opts);
compareRegionByRegion(decoder, opts, wholeImage);
- FileDescriptor fd1 = obtainDescriptor(filepath);
+ ParcelFileDescriptor pfd1 = obtainParcelDescriptor(filepath);
+ FileDescriptor fd1 = pfd1.getFileDescriptor();
decoder = BitmapRegionDecoder.newInstance(fd1, false);
- FileDescriptor fd2 = obtainDescriptor(filepath);
+ ParcelFileDescriptor pfd2 = obtainParcelDescriptor(filepath);
+ FileDescriptor fd2 = pfd2.getFileDescriptor();
compareRegionByRegion(decoder, opts, wholeImage);
wholeImage.recycle();
}
@@ -357,12 +360,14 @@
return (file.getPath());
}
- private FileDescriptor obtainDescriptor(String path) throws IOException {
+ private ParcelFileDescriptor obtainParcelDescriptor(String path)
+ throws IOException {
File file = new File(path);
return(ParcelFileDescriptor.open(file,
- ParcelFileDescriptor.MODE_READ_ONLY).getFileDescriptor());
+ ParcelFileDescriptor.MODE_READ_ONLY));
}
+
// Compare expected to actual to see if their diff is less then mseMargin.
// lessThanMargin is to indicate whether we expect the diff to be
// "less than" or "no less than".