1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.mediaframeworktest.unit;
18
19import android.hardware.Camera;
20import android.test.suitebuilder.annotation.SmallTest;
21import android.util.Log;
22
23/**
24 * <pre>
25 * adb shell am instrument \
26 *      -e class 'com.android.mediaframeworktest.unit.CameraOpenTest' \
27 *      -w com.android.mediaframeworktest/.MediaFrameworkUnitTestRunner
28 * </pre>
29 */
30public class CameraOpenTest extends junit.framework.TestCase {
31    private static String TAG = "CameraOpenTest";
32
33    private Camera mCamera;
34
35    /**
36     * Test @hide android.hardware.Camera#openLegacy API that cannot be tested in CTS.
37     */
38    @SmallTest
39    public void testOpenLegacy() {
40        int nCameras = Camera.getNumberOfCameras();
41        for (int id = 0; id < nCameras; id++) {
42            try {
43                mCamera.openLegacy(id, Camera.CAMERA_HAL_API_VERSION_1_0);
44            } catch (RuntimeException e) {
45                Log.i(TAG, "Unable to open camera as HAL1 legacy camera device " + e);
46            } finally {
47                if (mCamera != null) {
48                    mCamera.release();
49                }
50            }
51        }
52    }
53}
54