Home | History | Annotate | Download | only in docs
      1 ## -*- coding: utf-8 -*-
      2 /*
      3  * Copyright (C) 2013 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  */
     17 
     18 /**
     19  * ! Do not edit this file directly !
     20  *
     21  * Generated automatically from system/media/camera/docs/CameraCharacteristicsTest.mako.
     22  * This file contains only the auto-generated CameraCharacteristics CTS tests; it does
     23  * not contain any additional manual tests, which would be in a separate file.
     24  */
     25 
     26 package android.hardware.camera2.cts;
     27 
     28 import android.content.Context;
     29 import android.hardware.camera2.CameraCharacteristics;
     30 import android.hardware.camera2.CameraManager;
     31 import android.hardware.camera2.CameraMetadata.Key;
     32 import android.test.AndroidTestCase;
     33 import android.util.Log;
     34 
     35 import java.util.List;
     36 
     37 /**
     38  * Auto-generated CTS test for CameraCharacteristics fields.
     39  */
     40 public class CameraCharacteristicsTest extends AndroidTestCase {
     41     private CameraManager mCameraManager;
     42     private static final String TAG = "CameraCharacteristicsTest";
     43 
     44     @Override
     45     public void setContext(Context context) {
     46         super.setContext(context);
     47         mCameraManager = (CameraManager)context.getSystemService(Context.CAMERA_SERVICE);
     48         assertNotNull("Can't connect to camera manager", mCameraManager);
     49     }
     50 
     51     @Override
     52     protected void setUp() throws Exception {
     53         super.setUp();
     54     }
     55 
     56     @Override
     57     protected void tearDown() throws Exception {
     58         super.tearDown();
     59     }
     60     % for sec in find_all_sections(metadata):
     61       % for entry in find_unique_entries(sec):
     62         % if entry.kind == 'static' and entry.visibility == "public":
     63 
     64     public void testCameraCharacteristics${pascal_case(entry.name)}() throws Exception {
     65         String[] ids = mCameraManager.getCameraIdList();
     66         for (int i = 0; i < ids.length; i++) {
     67             CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
     68             assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
     69                                         props);
     70 
     71           % if entry.applied_optional:
     72             Integer hwLevel = props.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
     73             assertNotNull("No hardware level reported! android.info.supportedHardwareLevel",
     74                     hwLevel);
     75             if (hwLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)
     76           % endif
     77             {
     78 
     79                 assertNotNull("Invalid property: ${entry.name}",
     80                         props.get(CameraCharacteristics.${jkey_identifier(entry.name)}));
     81 
     82                 List<Key<?>> allKeys = props.getKeys();
     83                 assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
     84                         ids[i], props));
     85                 assertTrue("Key not in keys list: ${entry.name}", allKeys.contains(
     86                         CameraCharacteristics.${jkey_identifier(entry.name)}));
     87 
     88             }
     89 
     90         }
     91     }
     92         % endif
     93       % endfor
     94     % endfor
     95 }
     96 
     97