diff options
author | Igor Murashkin <iam@google.com> | 2013-06-25 20:27:06 +0000 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2013-06-26 13:19:45 -0700 |
commit | 70725500dcf3b666b43d50563d64705aab58d2d3 (patch) | |
tree | ad2d6206c590e11c4b86e871c138f2aabd822956 /media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit | |
parent | e363fbb2647aeb5ef4c87160d84c6b9ae8d45598 (diff) | |
download | frameworks_base-70725500dcf3b666b43d50563d64705aab58d2d3.zip frameworks_base-70725500dcf3b666b43d50563d64705aab58d2d3.tar.gz frameworks_base-70725500dcf3b666b43d50563d64705aab58d2d3.tar.bz2 |
Initial camera device implementation
* Working streaming preview requests only
* Almost everything else returns empty objects that don't do anything
Bug: 9213377
Change-Id: Ie6f02a7c0952b0f5ebc41905425b15cae221f7d3
Diffstat (limited to 'media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit')
-rw-r--r-- | media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java new file mode 100644 index 0000000..3400434 --- /dev/null +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/CameraMetadataTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 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.mediaframeworktest.unit; + +import android.os.Parcel; +import android.test.suitebuilder.annotation.SmallTest; +import android.hardware.photography.CameraMetadata; + +/** + * <pre> + * adb shell am instrument \ + * -e class 'com.android.mediaframeworktest.unit.CameraMetadataTest' \ + * -w com.android.mediaframeworktest/.MediaFrameworkUnitTestRunner + * </pre> + */ +public class CameraMetadataTest extends junit.framework.TestCase { + + CameraMetadata mMetadata; + Parcel mParcel; + + @Override + public void setUp() { + mMetadata = new CameraMetadata(); + mParcel = Parcel.obtain(); + } + + @Override + public void tearDown() throws Exception { + mMetadata.close(); + mMetadata = null; + + mParcel.recycle(); + mParcel = null; + } + + @SmallTest + public void testNew() { + assertEquals(0, mMetadata.getEntryCount()); + assertTrue(mMetadata.isEmpty()); + } + + @SmallTest + public void testClose() throws Exception { + mMetadata.isEmpty(); // no throw + + assertFalse(mMetadata.isClosed()); + + mMetadata.close(); + + assertTrue(mMetadata.isClosed()); + + // OK: second close should not throw + mMetadata.close(); + + assertTrue(mMetadata.isClosed()); + + // All other calls after close should throw IllegalStateException + + try { + mMetadata.isEmpty(); + fail("Unreachable -- isEmpty after close should throw IllegalStateException"); + } catch (IllegalStateException e) { + // good: we expect calling this method after close to fail + } + + try { + mMetadata.getEntryCount(); + fail("Unreachable -- getEntryCount after close should throw IllegalStateException"); + } catch (IllegalStateException e) { + // good: we expect calling this method after close to fail + } + + + try { + mMetadata.swap(mMetadata); + fail("Unreachable -- swap after close should throw IllegalStateException"); + } catch (IllegalStateException e) { + // good: we expect calling this method after close to fail + } + + try { + mMetadata.readFromParcel(mParcel); + fail("Unreachable -- readFromParcel after close should throw IllegalStateException"); + } catch (IllegalStateException e) { + // good: we expect calling this method after close to fail + } + + try { + mMetadata.writeToParcel(mParcel, /*flags*/0); + fail("Unreachable -- writeToParcel after close should throw IllegalStateException"); + } catch (IllegalStateException e) { + // good: we expect calling this method after close to fail + } + } +} |