• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.util.Log;
22 import android.util.Size;
23 import android.view.Surface;
24 
25 import org.junit.Test;
26 
27 import static org.junit.Assert.assertTrue;
28 
29 
30 /**
31  * <p>Basic test for CameraManager class.</p>
32  */
33 public class NativeCameraDeviceTest extends Camera2SurfaceViewTestCase {
34     private static final String TAG = "NativeCameraDeviceTest";
35     private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
36 
37     /** Load jni on initialization */
38     static {
39         Log.i("NativeCameraDeviceTest", "before loadlibrary");
40         System.loadLibrary("ctscamera2_jni");
41         Log.i("NativeCameraDeviceTest", "after loadlibrary");
42     }
43 
44     @Test
testCameraDeviceOpenAndClose()45     public void testCameraDeviceOpenAndClose() {
46         assertTrue("testCameraDeviceOpenAndClose fail, see log for details",
47                 testCameraDeviceOpenAndCloseNative());
48     }
49 
50     @Test
testCameraDeviceCreateCaptureRequest()51     public void testCameraDeviceCreateCaptureRequest() {
52         assertTrue("testCameraDeviceCreateCaptureRequest fail, see log for details",
53                 testCameraDeviceCreateCaptureRequestNative());
54     }
55 
56     @Test
testCameraDeviceSessionOpenAndClose()57     public void testCameraDeviceSessionOpenAndClose() {
58         // Init preview surface to a guaranteed working size
59         updatePreviewSurface(new Size(640, 480));
60         assertTrue("testCameraDeviceSessionOpenAndClose fail, see log for details",
61                 testCameraDeviceSessionOpenAndCloseNative(mPreviewSurface));
62     }
63 
64     @Test
testCameraDeviceSimplePreview()65     public void testCameraDeviceSimplePreview() {
66         // Init preview surface to a guaranteed working size
67         updatePreviewSurface(new Size(640, 480));
68         assertTrue("testCameraDeviceSimplePreview fail, see log for details",
69                 testCameraDeviceSimplePreviewNative(mPreviewSurface));
70     }
71 
72     @Test
testCameraDevicePreviewWithSessionParameters()73     public void testCameraDevicePreviewWithSessionParameters() {
74         // Init preview surface to a guaranteed working size
75         updatePreviewSurface(new Size(640, 480));
76         assertTrue("testCameraDevicePreviewWithSessionParameters fail, see log for details",
77                 testCameraDevicePreviewWithSessionParametersNative(mPreviewSurface));
78     }
79 
80     @Test
testCameraDeviceSharedOutputUpdate()81     public void testCameraDeviceSharedOutputUpdate() {
82         // Init preview surface to a guaranteed working size
83         Size previewSize = new Size(640, 480);
84         updatePreviewSurface(previewSize);
85         SurfaceTexture outputTexture = new SurfaceTexture(/* random texture ID*/ 5);
86         outputTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
87         Surface outputSurface = new Surface(outputTexture);
88         assertTrue("testCameraDeviceSharedOutputUpdate fail, see log for details",
89                 testCameraDeviceSharedOutputUpdate(mPreviewSurface, outputSurface));
90     }
91 
92     @Test
testCameraDeviceLogicalPhysicalStreaming()93     public void testCameraDeviceLogicalPhysicalStreaming() {
94         // Init preview surface to a guaranteed working size
95         Size previewSize = new Size(640, 480);
96         updatePreviewSurface(previewSize);
97         SurfaceTexture outputTexture = new SurfaceTexture(/* random texture ID*/ 5);
98         outputTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
99         Surface outputSurface = new Surface(outputTexture);
100         assertTrue("testCameraDeviceLogicalPhysicalStreaming fail, see log for details",
101                 testCameraDeviceLogicalPhysicalStreamingNative(mPreviewSurface));
102     }
103 
104     @Test
testCameraDeviceLogicalPhysicalSettings()105     public void testCameraDeviceLogicalPhysicalSettings() {
106         // Init preview surface to a guaranteed working size
107         Size previewSize = new Size(640, 480);
108         updatePreviewSurface(previewSize);
109         SurfaceTexture outputTexture = new SurfaceTexture(/* random texture ID*/ 5);
110         outputTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
111         Surface outputSurface = new Surface(outputTexture);
112         assertTrue("testCameraDeviceLogicalPhysicalSettings fail, see log for details",
113                 testCameraDeviceLogicalPhysicalSettingsNative(mPreviewSurface));
114     }
115 
116     @Test
testCameraDeviceCaptureFailure()117     public void testCameraDeviceCaptureFailure() {
118         assertTrue("testCameraDeviceCaptureFailure fail, see log for details",
119                 testCameraDeviceCaptureFailureNative());
120     }
121 
testCameraDeviceOpenAndCloseNative()122     private static native boolean testCameraDeviceOpenAndCloseNative();
testCameraDeviceCreateCaptureRequestNative()123     private static native boolean testCameraDeviceCreateCaptureRequestNative();
testCameraDeviceSessionOpenAndCloseNative(Surface preview)124     private static native boolean testCameraDeviceSessionOpenAndCloseNative(Surface preview);
testCameraDeviceSimplePreviewNative(Surface preview)125     private static native boolean testCameraDeviceSimplePreviewNative(Surface preview);
testCameraDevicePreviewWithSessionParametersNative( Surface preview)126     private static native boolean testCameraDevicePreviewWithSessionParametersNative(
127             Surface preview);
testCameraDeviceSharedOutputUpdate(Surface src, Surface dst)128     private static native boolean testCameraDeviceSharedOutputUpdate(Surface src, Surface dst);
testCameraDeviceLogicalPhysicalStreamingNative(Surface preview)129     private static native boolean testCameraDeviceLogicalPhysicalStreamingNative(Surface preview);
testCameraDeviceLogicalPhysicalSettingsNative(Surface preview)130     private static native boolean testCameraDeviceLogicalPhysicalSettingsNative(Surface preview);
testCameraDeviceCaptureFailureNative()131     private static native boolean testCameraDeviceCaptureFailureNative();
132 
133 }
134