CameraActivityTest.java revision 19c0b7882d14679bc0fe5d25c4e1ea34350d0b8d
1/*
2 * Copyright (C) 2012 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.camera.activity;
18
19import com.android.camera.Camera;
20import com.android.camera.CameraDevice;
21import com.android.camera.CameraHolder;
22import com.android.camera.IntentExtras;
23
24import android.app.Instrumentation;
25import android.hardware.Camera.CameraInfo;
26import android.test.ActivityInstrumentationTestCase2;
27import android.test.suitebuilder.annotation.LargeTest;
28
29public class CameraActivityTest extends ActivityInstrumentationTestCase2 <Camera> {
30    private static final String TAG = "CameraActivityTest";
31    private CameraInfo mCameraInfo[];
32
33    public CameraActivityTest() {
34        super(Camera.class);
35    }
36
37    @Override
38    protected void setUp() throws Exception {
39        super.setUp();
40        mCameraInfo = new CameraInfo[2];
41        mCameraInfo[0] = new CameraInfo();
42        mCameraInfo[0].facing = CameraInfo.CAMERA_FACING_BACK;
43        mCameraInfo[1] = new CameraInfo();
44        mCameraInfo[1].facing = CameraInfo.CAMERA_FACING_FRONT;
45    }
46
47    @Override
48    protected void tearDown() throws Exception {
49        CameraHolder.injectMockCamera(null,  null);
50    }
51
52    @LargeTest
53    public void testFailToConnect() throws Exception {
54        CameraHolder.injectMockCamera(mCameraInfo, null);
55
56        getActivity();
57        Instrumentation inst = getInstrumentation();
58        inst.waitForIdleSync();
59    }
60}
61