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.graphics.SurfaceTexture; 20 import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase; 21 import android.platform.test.annotations.AppModeFull; 22 import android.util.Log; 23 import android.util.Size; 24 import android.view.Surface; 25 26 /** 27 * <p>Basic test for CameraManager class.</p> 28 */ 29 @AppModeFull 30 public class NativeCameraDeviceTest extends Camera2SurfaceViewTestCase { 31 private static final String TAG = "NativeCameraDeviceTest"; 32 private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE); 33 34 /** Load jni on initialization */ 35 static { 36 Log.i("NativeCameraDeviceTest", "before loadlibrary"); 37 System.loadLibrary("ctscamera2_jni"); 38 Log.i("NativeCameraDeviceTest", "after loadlibrary"); 39 } 40 testCameraDeviceOpenAndClose()41 public void testCameraDeviceOpenAndClose() { 42 assertTrue("testCameraDeviceOpenAndClose fail, see log for details", 43 testCameraDeviceOpenAndCloseNative()); 44 } 45 testCameraDeviceCreateCaptureRequest()46 public void testCameraDeviceCreateCaptureRequest() { 47 assertTrue("testCameraDeviceCreateCaptureRequest fail, see log for details", 48 testCameraDeviceCreateCaptureRequestNative()); 49 } 50 testCameraDeviceSessionOpenAndClose()51 public void testCameraDeviceSessionOpenAndClose() { 52 // Init preview surface to a guaranteed working size 53 updatePreviewSurface(new Size(640, 480)); 54 assertTrue("testCameraDeviceSessionOpenAndClose fail, see log for details", 55 testCameraDeviceSessionOpenAndCloseNative(mPreviewSurface)); 56 } 57 testCameraDeviceSimplePreview()58 public void testCameraDeviceSimplePreview() { 59 // Init preview surface to a guaranteed working size 60 updatePreviewSurface(new Size(640, 480)); 61 assertTrue("testCameraDeviceSimplePreview fail, see log for details", 62 testCameraDeviceSimplePreviewNative(mPreviewSurface)); 63 } 64 testCameraDevicePreviewWithSessionParameters()65 public void testCameraDevicePreviewWithSessionParameters() { 66 // Init preview surface to a guaranteed working size 67 updatePreviewSurface(new Size(640, 480)); 68 assertTrue("testCameraDevicePreviewWithSessionParametersNative fail, see log for details", 69 testCameraDevicePreviewWithSessionParametersNative(mPreviewSurface)); 70 } 71 testCameraDeviceSharedOutputUpdate()72 public void testCameraDeviceSharedOutputUpdate() { 73 // Init preview surface to a guaranteed working size 74 Size previewSize = new Size(640, 480); 75 updatePreviewSurface(previewSize); 76 SurfaceTexture outputTexture = new SurfaceTexture(/* random texture ID*/ 5); 77 outputTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight()); 78 Surface outputSurface = new Surface(outputTexture); 79 assertTrue("testCameraDeviceSharedWindowAddRemove fail, see log for details", 80 testCameraDeviceSharedOutputUpdate(mPreviewSurface, outputSurface)); 81 } 82 testCameraDeviceOpenAndCloseNative()83 private static native boolean testCameraDeviceOpenAndCloseNative(); testCameraDeviceCreateCaptureRequestNative()84 private static native boolean testCameraDeviceCreateCaptureRequestNative(); testCameraDeviceSessionOpenAndCloseNative(Surface preview)85 private static native boolean testCameraDeviceSessionOpenAndCloseNative(Surface preview); testCameraDeviceSimplePreviewNative(Surface preview)86 private static native boolean testCameraDeviceSimplePreviewNative(Surface preview); testCameraDevicePreviewWithSessionParametersNative( Surface preview)87 private static native boolean testCameraDevicePreviewWithSessionParametersNative( 88 Surface preview); testCameraDeviceSharedOutputUpdate(Surface src, Surface dst)89 private static native boolean testCameraDeviceSharedOutputUpdate(Surface src, Surface dst); 90 } 91