CameraLatency.java revision 3ec4b6040078fc26b09defd55e3f5f9ac84aba28
1/* 2 * Copyright (C) 2009 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.camera.stress; 18 19import com.android.camera.Camera; 20 21import android.app.Instrumentation; 22import android.test.ActivityInstrumentationTestCase2; 23import android.test.suitebuilder.annotation.LargeTest; 24import android.util.Log; 25import android.view.KeyEvent; 26 27/** 28 * Junit / Instrumentation test case for camera test 29 * 30 */ 31 32public class CameraLatency extends ActivityInstrumentationTestCase2 <Camera> { 33 private String TAG = "CameraLatency"; 34 private static final int TOTAL_NUMBER_OF_IMAGECAPTURE = 5; 35 private static final long WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN = 3000; 36 37 public CameraLatency() { 38 super("com.android.camera", Camera.class); 39 } 40 41 @Override 42 protected void setUp() throws Exception { 43 getActivity(); 44 super.setUp(); 45 } 46 47 @Override 48 protected void tearDown() throws Exception { 49 super.tearDown(); 50 } 51 52 @LargeTest 53 public void testImageCapture() { 54 Instrumentation inst = getInstrumentation(); 55 try { 56 for (int i = 0; i < TOTAL_NUMBER_OF_IMAGECAPTURE; i++) { 57 Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN); 58 inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP); 59 inst.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); 60 Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN); 61 } 62 } catch (Exception e) { 63 Log.v(TAG, e.toString()); 64 } 65 assertTrue("testImageCapture", true); 66 } 67} 68 69