diff options
author | Sascha Haeberling <haeberling@google.com> | 2013-08-12 19:18:54 -0700 |
---|---|---|
committer | Sascha Haeberling <haeberling@google.com> | 2013-08-12 19:18:54 -0700 |
commit | de42a04ad09b70d550f85bc4339876ea50a53e75 (patch) | |
tree | 3587b04d55d98c6440df76a0a3a5814f314b2c0c /tests/src/com/android/gallery3d/functional | |
parent | 10fe36347b1059151d1a4e0c5faf98fd903fce3c (diff) | |
download | android_packages_apps_Snap-de42a04ad09b70d550f85bc4339876ea50a53e75.tar.gz android_packages_apps_Snap-de42a04ad09b70d550f85bc4339876ea50a53e75.tar.bz2 android_packages_apps_Snap-de42a04ad09b70d550f85bc4339876ea50a53e75.zip |
Remove all tests from Camera2 until we have them sorted out.
Change-Id: I15107eac9acc37b09094585902fc24fe96ef8953
Diffstat (limited to 'tests/src/com/android/gallery3d/functional')
3 files changed, 0 insertions, 487 deletions
diff --git a/tests/src/com/android/gallery3d/functional/CameraTest.java b/tests/src/com/android/gallery3d/functional/CameraTest.java deleted file mode 100644 index c293c0d4a..000000000 --- a/tests/src/com/android/gallery3d/functional/CameraTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.gallery3d.functional; - -import com.android.camera.CameraActivity; - -import android.app.Activity; -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; -import java.lang.ref.WeakReference; -import java.util.ArrayList; - -public class CameraTest extends InstrumentationTestCase { - @LargeTest - public void testVideoCaptureIntentFdLeak() throws Exception { - Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); - intent.setClass(getInstrumentation().getTargetContext(), CameraActivity.class); - 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")); - } - } - - @LargeTest - public void testActivityLeak() throws Exception { - checkActivityLeak(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); - checkActivityLeak(MediaStore.INTENT_ACTION_VIDEO_CAMERA); - } - - private void checkActivityLeak(String action) throws Exception { - final int TEST_COUNT = 5; - Intent intent = new Intent(action); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.setClass(getInstrumentation().getTargetContext(), - CameraActivity.class); - ArrayList<WeakReference<Activity>> refs = - new ArrayList<WeakReference<Activity>>(); - for (int i = 0; i < TEST_COUNT; i++) { - Activity activity = getInstrumentation().startActivitySync(intent); - refs.add(new WeakReference<Activity>(activity)); - activity.finish(); - getInstrumentation().waitForIdleSync(); - activity = null; - } - Runtime.getRuntime().gc(); - Runtime.getRuntime().runFinalization(); - Runtime.getRuntime().gc(); - int refCount = 0; - for (WeakReference<Activity> c: refs) { - if (c.get() != null) refCount++; - } - // If applications are leaking activity, every reference is reachable. - assertTrue(refCount != TEST_COUNT); - } -} diff --git a/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java b/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java deleted file mode 100644 index 9ea912864..000000000 --- a/tests/src/com/android/gallery3d/functional/ImageCaptureIntentTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.gallery3d.functional; - -import com.android.camera.CameraActivity; -import com.android.camera2.R; - -import android.app.Activity; -import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.net.Uri; -import android.os.Environment; -import android.provider.MediaStore; -import android.test.ActivityInstrumentationTestCase2; -import android.test.suitebuilder.annotation.LargeTest; -import android.view.KeyEvent; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; - -public class ImageCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> { - private Intent mIntent; - - public ImageCaptureIntentTest() { - super(CameraActivity.class); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - } - - @LargeTest - public void testNoExtraOutput() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - takePicture(); - pressDone(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_OK, getActivity().getResultCode()); - Intent resultData = getActivity().getResultData(); - Bitmap bitmap = (Bitmap) resultData.getParcelableExtra("data"); - assertNotNull(bitmap); - assertTrue(bitmap.getWidth() > 0); - assertTrue(bitmap.getHeight() > 0); - } - - @LargeTest - public void testExtraOutput() throws Exception { - File file = new File(Environment.getExternalStorageDirectory(), - "test.jpg"); - BufferedInputStream stream = null; - byte[] jpegData; - - try { - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); - setActivityIntent(mIntent); - getActivity(); - - takePicture(); - pressDone(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_OK, getActivity().getResultCode()); - - // Verify the jpeg file - int fileLength = (int) file.length(); - assertTrue(fileLength > 0); - jpegData = new byte[fileLength]; - stream = new BufferedInputStream(new FileInputStream(file)); - stream.read(jpegData); - } finally { - if (stream != null) stream.close(); - file.delete(); - } - - Bitmap b = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length); - assertTrue(b.getWidth() > 0); - assertTrue(b.getHeight() > 0); - } - - @LargeTest - public void testCancel() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - pressCancel(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode()); - } - - @LargeTest - public void testSnapshotCancel() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - takePicture(); - pressCancel(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode()); - } - - private void takePicture() throws Exception { - getInstrumentation().sendKeySync( - new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS)); - getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA); - Thread.sleep(4000); - } - - private void pressDone() { - getInstrumentation().runOnMainSync(new Runnable() { - @Override - public void run() { - getActivity().findViewById(R.id.btn_done).performClick(); - } - }); - } - - private void pressCancel() { - getInstrumentation().runOnMainSync(new Runnable() { - @Override - public void run() { - getActivity().findViewById(R.id.btn_cancel).performClick(); - } - }); - } -} diff --git a/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java b/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java deleted file mode 100644 index 349398949..000000000 --- a/tests/src/com/android/gallery3d/functional/VideoCaptureIntentTest.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.gallery3d.functional; - -import com.android.camera.CameraActivity; -import com.android.camera2.R; - -import android.app.Activity; -import android.content.ContentResolver; -import android.content.Intent; -import android.database.Cursor; -import android.media.MediaMetadataRetriever; -import android.net.Uri; -import android.os.Environment; -import android.provider.MediaStore; -import android.provider.MediaStore.Video.VideoColumns; -import android.test.ActivityInstrumentationTestCase2; -import android.test.suitebuilder.annotation.LargeTest; -import android.util.Log; -import android.view.KeyEvent; - -import java.io.File; - -public class VideoCaptureIntentTest extends ActivityInstrumentationTestCase2 <CameraActivity> { - private static final String TAG = "VideoCaptureIntentTest"; - private Intent mIntent; - private Uri mVideoUri; - private File mFile, mFile2; - - public VideoCaptureIntentTest() { - super(CameraActivity.class); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); - } - - @Override - protected void tearDown() throws Exception { - if (mVideoUri != null) { - ContentResolver resolver = getActivity().getContentResolver(); - Uri query = mVideoUri.buildUpon().build(); - String[] projection = new String[] {VideoColumns.DATA}; - - Cursor cursor = null; - try { - cursor = resolver.query(query, projection, null, null, null); - if (cursor != null && cursor.moveToFirst()) { - new File(cursor.getString(0)).delete(); - } - } finally { - if (cursor != null) cursor.close(); - } - - resolver.delete(mVideoUri, null, null); - } - if (mFile != null) mFile.delete(); - if (mFile2 != null) mFile2.delete(); - super.tearDown(); - } - - @LargeTest - public void testNoExtraOutput() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - recordVideo(); - pressDone(); - - Intent resultData = getActivity().getResultData(); - mVideoUri = resultData.getData(); - assertNotNull(mVideoUri); - verify(getActivity(), mVideoUri); - } - - @LargeTest - public void testExtraOutput() throws Exception { - mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp"); - - Uri uri = Uri.fromFile(mFile); - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - setActivityIntent(mIntent); - getActivity(); - - recordVideo(); - pressDone(); - - verify(getActivity(), uri); - } - - @LargeTest - public void testCancel() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - pressCancel(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode()); - } - - @LargeTest - public void testRecordCancel() throws Exception { - setActivityIntent(mIntent); - getActivity(); - - recordVideo(); - pressCancel(); - - assertTrue(getActivity().isFinishing()); - assertEquals(Activity.RESULT_CANCELED, getActivity().getResultCode()); - } - - @LargeTest - public void testExtraSizeLimit() throws Exception { - mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp"); - final long sizeLimit = 500000; // bytes - - Uri uri = Uri.fromFile(mFile); - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - mIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit); - mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // use low quality to speed up - setActivityIntent(mIntent); - getActivity(); - - recordVideo(5000); - pressDone(); - - verify(getActivity(), uri); - long length = mFile.length(); - Log.v(TAG, "Video size is " + length + " bytes."); - assertTrue(length > 0); - assertTrue("Actual size=" + length, length <= sizeLimit); - } - - @LargeTest - public void testExtraDurationLimit() throws Exception { - mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp"); - final int durationLimit = 2; // seconds - - Uri uri = Uri.fromFile(mFile); - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - mIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit); - setActivityIntent(mIntent); - getActivity(); - - recordVideo(5000); - pressDone(); - - int duration = verify(getActivity(), uri); - // The duraion should be close to to the limit. The last video duration - // also has duration, so the total duration may exceeds the limit a - // little bit. - Log.v(TAG, "Video length is " + duration + " ms."); - assertTrue(duration < (durationLimit + 1) * 1000); - } - - @LargeTest - public void testExtraVideoQuality() throws Exception { - mFile = new File(Environment.getExternalStorageDirectory(), "video.tmp"); - mFile2 = new File(Environment.getExternalStorageDirectory(), "video2.tmp"); - - Uri uri = Uri.fromFile(mFile); - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); // low quality - setActivityIntent(mIntent); - getActivity(); - - recordVideo(); - pressDone(); - - verify(getActivity(), uri); - setActivity(null); - - uri = Uri.fromFile(mFile2); - mIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // high quality - setActivityIntent(mIntent); - getActivity(); - - recordVideo(); - pressDone(); - - verify(getActivity(), uri); - assertTrue(mFile.length() <= mFile2.length()); - } - - // Verify result code, result data, and the duration. - private int verify(CameraActivity activity, Uri uri) throws Exception { - assertTrue(activity.isFinishing()); - assertEquals(Activity.RESULT_OK, activity.getResultCode()); - - // Verify the video file - MediaMetadataRetriever retriever = new MediaMetadataRetriever(); - retriever.setDataSource(activity, uri); - String duration = retriever.extractMetadata( - MediaMetadataRetriever.METADATA_KEY_DURATION); - assertNotNull(duration); - int durationValue = Integer.parseInt(duration); - Log.v(TAG, "Video duration is " + durationValue); - assertTrue(durationValue > 0); - return durationValue; - } - - private void recordVideo(int ms) throws Exception { - getInstrumentation().sendCharacterSync(KeyEvent.KEYCODE_CAMERA); - Thread.sleep(ms); - getInstrumentation().runOnMainSync(new Runnable() { - @Override - public void run() { - // If recording is in progress, stop it. Run these atomically in - // UI thread. - CameraActivity activity = getActivity(); - if (activity.isRecording()) { - activity.findViewById(R.id.shutter_button).performClick(); - } - } - }); - } - - private void recordVideo() throws Exception { - recordVideo(2000); - } - - private void pressDone() { - getInstrumentation().runOnMainSync(new Runnable() { - @Override - public void run() { - getActivity().findViewById(R.id.btn_done).performClick(); - } - }); - } - - private void pressCancel() { - getInstrumentation().runOnMainSync(new Runnable() { - @Override - public void run() { - getActivity().findViewById(R.id.btn_cancel).performClick(); - } - }); - } -} |