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 17package com.android.mediaframeworktest; 18 19import android.os.Bundle; 20import android.test.InstrumentationTestRunner; 21import android.test.InstrumentationTestSuite; 22import android.util.Log; 23 24import com.android.mediaframeworktest.integration.CameraBinderTest; 25import com.android.mediaframeworktest.integration.CameraDeviceBinderTest; 26 27import junit.framework.TestSuite; 28 29/** 30 * Instrumentation Test Runner for all media framework integration tests. 31 * 32 * Running all tests: 33 * 34 * adb shell am instrument -w com.android.mediaframeworktest/.MediaFrameworkIntegrationTestRunner 35 */ 36 37public class MediaFrameworkIntegrationTestRunner extends InstrumentationTestRunner { 38 39 private static final String TAG = "MediaFrameworkIntegrationTestRunner"; 40 41 public static int mCameraId = 0; 42 43 @Override 44 public TestSuite getAllTests() { 45 TestSuite suite = new InstrumentationTestSuite(this); 46 suite.addTestSuite(CameraBinderTest.class); 47 suite.addTestSuite(CameraDeviceBinderTest.class); 48 return suite; 49 } 50 51 @Override 52 public ClassLoader getLoader() { 53 return MediaFrameworkIntegrationTestRunner.class.getClassLoader(); 54 } 55 56 @Override 57 public void onCreate(Bundle icicle) { 58 super.onCreate(icicle); 59 60 String cameraId = (String) icicle.get("camera_id"); 61 if (cameraId != null) { 62 try { 63 Log.v(TAG, 64 String.format("Reading camera_id from icicle: '%s'", cameraId)); 65 mCameraId = Integer.parseInt(cameraId); 66 } 67 catch (NumberFormatException e) { 68 Log.e(TAG, String.format("Failed to convert camera_id to integer")); 69 } 70 } 71 } 72} 73