diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-08-19 16:38:21 -0700 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-08-20 16:10:01 -0700 |
commit | dcd762a819f195fdbd441334ca5b97a07f1aa8dd (patch) | |
tree | 8f55a8d17635beb282b0b5f9b0dc26d38feacfe7 /tests | |
parent | 0eda94c5e2302a9e26d6c572ece84fe5428815e2 (diff) | |
download | LegacyCamera-dcd762a819f195fdbd441334ca5b97a07f1aa8dd.zip LegacyCamera-dcd762a819f195fdbd441334ca5b97a07f1aa8dd.tar.gz LegacyCamera-dcd762a819f195fdbd441334ca5b97a07f1aa8dd.tar.bz2 |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/camera/functional/CameraTest.java | 31 |
1 files changed, 31 insertions, 0 deletions
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")); + } + } +} |