From dcd762a819f195fdbd441334ca5b97a07f1aa8dd Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Thu, 19 Aug 2010 16:38:21 -0700 Subject: Close the video file descriptor earlier. The file descriptor will be closed in finalize() eventually. But it is better to close it as soon when we are done with it. bug:2912676 Change-Id: I04e1abfdc946c2f218cca30d9140627444bce706 --- .../com/android/camera/functional/CameraTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/src/com/android/camera/functional/CameraTest.java (limited to 'tests/src/com/android/camera') diff --git a/tests/src/com/android/camera/functional/CameraTest.java b/tests/src/com/android/camera/functional/CameraTest.java new file mode 100644 index 0000000..9eca03e --- /dev/null +++ b/tests/src/com/android/camera/functional/CameraTest.java @@ -0,0 +1,31 @@ +package com.android.camera.functional; + +import android.content.Intent; +import android.net.Uri; +import android.os.Environment; +import android.os.Process; +import android.provider.MediaStore; +import android.test.InstrumentationTestCase; +import android.test.suitebuilder.annotation.LargeTest; + +import java.io.File; + +public class CameraTest extends InstrumentationTestCase { + private static final String CAMERA_PACKAGE = "com.google.android.camera"; + private static final String CAMCORDER_ACTIVITY = "com.android.camera.VideoCamera"; + + @LargeTest + public void testVideoCaptureIntentFdLeak() throws Exception { + Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); + intent.setClassName(CAMERA_PACKAGE, CAMCORDER_ACTIVITY); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse("file://" + + Environment.getExternalStorageDirectory().toString() + + "test_fd_leak.3gp")); + getInstrumentation().startActivitySync(intent).finish(); + // Test if the fd is closed. + for (File f: new File("/proc/" + Process.myPid() + "/fd").listFiles()) { + assertEquals(-1, f.getCanonicalPath().indexOf("test_fd_leak.3gp")); + } + } +} -- cgit v1.1