1 /* 2 * Copyright (C) 2013 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 com.android.cts.verifier.camera.fov; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 22 import java.util.List; 23 24 class CtsTestHelper { 25 26 private static final String REPORTED_FOV_EXTRA = "lightcycle.reported_fov"; 27 private static final String MEASURED_FOV_EXTRA = "lightcycle.measured_fov"; 28 storeCtsTestResult(Activity activity, float reportedFOV, float measuredFOV)29 public static void storeCtsTestResult(Activity activity, float reportedFOV, float measuredFOV) { 30 Intent it = new Intent(); 31 it.putExtra(REPORTED_FOV_EXTRA, reportedFOV); 32 it.putExtra(MEASURED_FOV_EXTRA, measuredFOV); 33 activity.setResult(Activity.RESULT_OK, it); 34 } 35 getMeasuredFOV(Intent intent)36 public static float getMeasuredFOV(Intent intent) { 37 return intent.getFloatExtra(MEASURED_FOV_EXTRA, -1f); 38 } 39 getReportedFOV(Intent intent)40 public static float getReportedFOV(Intent intent) { 41 return intent.getFloatExtra(REPORTED_FOV_EXTRA, -1f); 42 } 43 isResultPassed(float reportedFOV, float measuredFOV)44 public static boolean isResultPassed(float reportedFOV, float measuredFOV) { 45 if (Math.abs(reportedFOV - measuredFOV) < 2f) return true; 46 return false; 47 } 48 getTestDetails(List<SelectableResolution> resolutions)49 public static String getTestDetails(List<SelectableResolution> resolutions) { 50 String details = "PhotoSphere FOV test result:\n"; 51 for (int i = 0; i < resolutions.size(); i++) { 52 SelectableResolution res = resolutions.get(i); 53 details += "Camera:" + res.cameraId + ", Resolution:" + res.width + 'x' + res.height 54 + ", Measured FOV = " + res.measuredFOV + '\n'; 55 56 } 57 58 return details; 59 } 60 } 61