OSDN Git Service

camera2: Update api to be async
authorIgor Murashkin <iam@google.com>
Fri, 20 Sep 2013 00:32:24 +0000 (17:32 -0700)
committerIgor Murashkin <iam@google.com>
Fri, 20 Sep 2013 00:32:24 +0000 (17:32 -0700)
Bug: 10360518
Change-Id: I66b0dc54135a85822a218e1259dd171e7ddf0c87

camera/docs/CameraPropertiesTest.mako

index c730b87..129b90a 100644 (file)
@@ -29,6 +29,7 @@ import android.content.Context;
 import android.hardware.camera2.CameraDevice;
 import android.hardware.camera2.CameraManager;
 import android.hardware.camera2.CameraProperties;
+import android.os.Handler;
 import android.test.AndroidTestCase;
 
 /**
@@ -37,6 +38,9 @@ import android.test.AndroidTestCase;
 public class CameraPropertiesTest extends AndroidTestCase {
     private CameraManager mCameraManager;
 
+    private CameraTestThread mLooperThread;
+    private Handler mHandler;
+
     @Override
     public void setContext(Context context) {
         super.setContext(context);
@@ -47,10 +51,16 @@ public class CameraPropertiesTest extends AndroidTestCase {
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+
+        mLooperThread = new CameraTestThread();
+        mHandler = mLooperThread.start();
     }
 
     @Override
     protected void tearDown() throws Exception {
+        mLooperThread.close();
+        mHandler = null;
+
         super.tearDown();
     }
     % for sec in find_all_sections(metadata):
@@ -60,7 +70,7 @@ public class CameraPropertiesTest extends AndroidTestCase {
     public void testCameraProperties${pascal_case(entry.name)}() throws Exception {
         String[] ids = mCameraManager.getCameraIdList();
         for (int i = 0; i < ids.length; i++) {
-            CameraDevice camera = mCameraManager.openCamera(ids[i]);
+            CameraDevice camera = CameraTestUtils.openCamera(mCameraManager, ids[i], mHandler);
             assertNotNull("Failed to open camera", camera);
             CameraProperties props;
             try {