Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright 2016 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 
     17 package android.hardware.camera2.cts;
     18 
     19 import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
     20 import android.util.Log;
     21 import android.util.Size;
     22 import android.view.Surface;
     23 
     24 /**
     25  * <p>Basic test for CameraManager class.</p>
     26  */
     27 public class NativeCameraDeviceTest extends Camera2SurfaceViewTestCase {
     28     private static final String TAG = "NativeCameraDeviceTest";
     29     private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
     30 
     31     /** Load jni on initialization */
     32     static {
     33         Log.i("NativeCameraDeviceTest", "before loadlibrary");
     34         System.loadLibrary("ctscamera2_jni");
     35         Log.i("NativeCameraDeviceTest", "after loadlibrary");
     36     }
     37 
     38     public void testCameraDeviceOpenAndClose() {
     39         assertTrue("testCameraDeviceOpenAndClose fail, see log for details",
     40                 testCameraDeviceOpenAndCloseNative());
     41     }
     42 
     43     public void testCameraDeviceCreateCaptureRequest() {
     44         assertTrue("testCameraDeviceCreateCaptureRequest fail, see log for details",
     45                 testCameraDeviceCreateCaptureRequestNative());
     46     }
     47 
     48     public void testCameraDeviceSessionOpenAndClose() {
     49         // Init preview surface to a guaranteed working size
     50         updatePreviewSurface(new Size(640, 480));
     51         assertTrue("testCameraDeviceSessionOpenAndClose fail, see log for details",
     52                 testCameraDeviceSessionOpenAndCloseNative(mPreviewSurface));
     53     }
     54 
     55     public void testCameraDeviceSimplePreview() {
     56         // Init preview surface to a guaranteed working size
     57         updatePreviewSurface(new Size(640, 480));
     58         assertTrue("testCameraDeviceSimplePreview fail, see log for details",
     59                 testCameraDeviceSimplePreviewNative(mPreviewSurface));
     60     }
     61 
     62     private static native boolean testCameraDeviceOpenAndCloseNative();
     63     private static native boolean testCameraDeviceCreateCaptureRequestNative();
     64     private static native boolean testCameraDeviceSessionOpenAndCloseNative(Surface preview);
     65     private static native boolean testCameraDeviceSimplePreviewNative(Surface preview);
     66 }
     67