Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2015 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 package android.hardware.multiprocess.camera.cts;
     17 
     18 /**
     19  * Constants used throughout the multi-process unit tests.
     20  */
     21 public class TestConstants {
     22 
     23     public static final int EVENT_CAMERA_ERROR = -1;
     24     public static final int EVENT_CAMERA_CONNECT = 1;
     25     public static final int EVENT_CAMERA_EVICTED = 2;
     26     public static final int EVENT_CAMERA_AVAILABLE = 3;
     27     public static final int EVENT_CAMERA_UNAVAILABLE = 4;
     28 
     29     public static final String EVENT_CAMERA_ERROR_STR = "error";
     30     public static final String EVENT_CAMERA_CONNECT_STR = "connect";
     31     public static final String EVENT_CAMERA_EVICTED_STR = "evicted";
     32     public static final String EVENT_CAMERA_AVAILABLE_STR = "available";
     33     public static final String EVENT_CAMERA_UNAVAILABLE_STR = "unavailable";
     34 
     35     public static final String EVENT_CAMERA_UNKNOWN_STR = "unknown";
     36 
     37     /**
     38      * Convert the given error code to a string.
     39      *
     40      * @param err error code from {@link TestConstants}.
     41      * @return string for this error code.
     42      */
     43     public static String errToStr(int err) {
     44         switch(err) {
     45             case EVENT_CAMERA_ERROR:
     46                 return EVENT_CAMERA_ERROR_STR;
     47             case EVENT_CAMERA_CONNECT:
     48                 return EVENT_CAMERA_CONNECT_STR;
     49             case EVENT_CAMERA_EVICTED:
     50                 return EVENT_CAMERA_EVICTED_STR;
     51             case EVENT_CAMERA_AVAILABLE:
     52                 return EVENT_CAMERA_AVAILABLE_STR;
     53             case EVENT_CAMERA_UNAVAILABLE:
     54                 return EVENT_CAMERA_UNAVAILABLE_STR;
     55             default:
     56                 return EVENT_CAMERA_UNKNOWN_STR + " " + err;
     57         }
     58     }
     59 
     60     /**
     61      * Convert the given array of error codes to an array of strings.
     62      *
     63      * @param err array of error codes from {@link TestConstants}.
     64      * @return string array for the given error codes.
     65      */
     66     public static String[] convertToStringArray(int[] err) {
     67         if (err == null) return null;
     68         String[] ret = new String[err.length];
     69         for (int i = 0; i < err.length; i++) {
     70             ret[i] = errToStr(err[i]);
     71         }
     72         return ret;
     73     }
     74 
     75 }
     76