FileDocCategorySizeDatePackage
CameraPairwiseTest.javaAPI DocAndroid 5.1 API18006Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest.functional.camera

CameraPairwiseTest

public class CameraPairwiseTest extends android.test.ActivityInstrumentationTestCase2
Junit / Instrumentation test case for camera API pairwise testing Settings tested against: flash mode, exposure compensation, white balance, scene mode, picture size, and geotagging adb shell am instrument - e class com.android.mediaframeworktest.stress.CameraPairwiseTest - w com.android.mediaframeworktest/.CameraStressTestRunner

Fields Summary
private com.android.mediaframeworktest.CameraTestHelper
mCameraTestHelper
private android.os.Handler
mHandler
private Thread
mLooperThread
private String
TAG
private static final long
WAIT_TIMEOUT
private static final double
MOCK_LATITUDE
private static final double
MOCK_LONGITUDE
Constructors Summary
public CameraPairwiseTest()


    // camera setting enums
           
           
             
             
           
          

      
        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
    
Methods Summary
private voidgenericPairwiseTestCase(com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$Flash flash, com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$Exposure exposure, com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$WhiteBalance whitebalance, com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$SceneMode scenemode, com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$PictureSize picturesize, com.android.mediaframeworktest.functional.camera.CameraPairwiseTest$Geotagging geotagging)
Generic pairwise test method

        try {
            SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
            Camera.Parameters params = mCameraTestHelper.getCameraParameters();

            runOnLooper(new Runnable() {
                @Override
                public void run() {
                    mCameraTestHelper.setupCameraTest();
                }
            });

            // Configure flash setting
            switch (flash) {
                case ON:
                    params.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
                    break;
                case OFF:
                    params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                    break;
                case AUTO:
                    params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
                    break;
            }

            // Configure exposure setting
            switch (exposure) {
                case MIN:
                    params.setExposureCompensation(params.getMinExposureCompensation());
                    break;
                case MAX:
                    params.setExposureCompensation(params.getMaxExposureCompensation());
                    break;
                case NONE:
                    params.setExposureCompensation(0);
                    break;
            }

            // Configure white balance setting
            switch (whitebalance) {
                case DAYLIGHT:
                    params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_DAYLIGHT);
                    break;
                case FLUORESCENT:
                    params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_FLUORESCENT);
                    break;
                case INCANDESCENT:
                    params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_INCANDESCENT);
                    break;
                case CLOUDY:
                    params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
                    break;
                case AUTO:
                    params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO);
                    break;
            }

            // Configure scene mode setting
            switch (scenemode) {
                case SUNSET:
                    params.setSceneMode(Camera.Parameters.SCENE_MODE_SUNSET);
                    break;
                case ACTION:
                    params.setSceneMode(Camera.Parameters.SCENE_MODE_ACTION);
                    break;
                case PARTY:
                    params.setSceneMode(Camera.Parameters.SCENE_MODE_PARTY);
                    break;
                case NIGHT:
                    params.setSceneMode(Camera.Parameters.SCENE_MODE_NIGHT);
                    break;
                case AUTO:
                    params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
                    break;
            }

            // Configure picture size setting
            List<Camera.Size> supportedPictureSizes = params.getSupportedPictureSizes();
            int mid = (int) Math.floor(supportedPictureSizes.size() / 2);
            int low = supportedPictureSizes.size() - 1;
            switch (picturesize) {
                case SMALL:
                    params.setPictureSize(supportedPictureSizes.get(low).width,
                            supportedPictureSizes.get(low).height);
                    break;
                case MEDIUM:
                    params.setPictureSize(supportedPictureSizes.get(mid).width,
                            supportedPictureSizes.get(mid).height);
                    break;
                case LARGE:
                    params.setPictureSize(supportedPictureSizes.get(0).width,
                            supportedPictureSizes.get(mid).height);
                    break;
            }

            // Configure geotagging setting
            switch (geotagging) {
                case ON:
                    params.setGpsLatitude(MOCK_LATITUDE);
                    params.setGpsLongitude(MOCK_LONGITUDE);
                    break;
                case OFF:
                    break;
            }

            mCameraTestHelper.setParameters(params);
            mCameraTestHelper.startCameraPreview(surfaceHolder);
            mCameraTestHelper.capturePhoto();
            mCameraTestHelper.cleanupTestImages();
        } catch (Exception e) {
            Log.e(TAG, e.toString());
            fail("Test case failed");
        }
    
private voidrunOnLooper(java.lang.Runnable command)

        final Semaphore sem = new Semaphore(0);
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                try {
                    command.run();
                } finally {
                    sem.release();
                }
            }
        });
        if (!sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
            fail("Failed to run the command on the looper.");
        }
    
protected voidsetUp()

        final Semaphore sem = new Semaphore(0);
        mLooperThread = new Thread() {
            @Override
            public void run() {
                Log.v(TAG, "starting looper");
                Looper.prepare();
                mHandler = new Handler();
                sem.release();
                Looper.loop();
                Log.v(TAG, "quit looper");
            }
        };
        mLooperThread.start();
        if (!sem.tryAcquire(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) {
            fail("Failed to start the looper.");
        }
        getActivity();
        super.setUp();

        mCameraTestHelper = new CameraTestHelper();
    
protected voidtearDown()

        if (mHandler != null) {
            mHandler.getLooper().quit();
            mHandler = null;
        }
        if (mLooperThread != null) {
            mLooperThread.join(WAIT_TIMEOUT);
            if (mLooperThread.isAlive()) {
                fail("Failed to stop the looper.");
            }
            mLooperThread = null;
        }
        super.tearDown();
    
public voidtestCameraPairwiseScenario01()
Flash: Auto / Exposure: None / WB: Daylight Scene: Sunset / Pic: Medium / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.NONE, WhiteBalance.DAYLIGHT, SceneMode.SUNSET,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario02()
Flash: On / Exposure: Min / WB: Fluorescent Scene: Auto / Pic: Large / Geo: on

        genericPairwiseTestCase(Flash.ON, Exposure.MIN, WhiteBalance.FLUORESCENT, SceneMode.AUTO,
                PictureSize.LARGE, Geotagging.ON);
    
public voidtestCameraPairwiseScenario03()
Flash: Off / Exposure: Max / WB: Auto Scene: Night / Pic: Small / Geo: on

        genericPairwiseTestCase(Flash.OFF, Exposure.MAX, WhiteBalance.AUTO, SceneMode.NIGHT,
                PictureSize.SMALL, Geotagging.ON);
    
public voidtestCameraPairwiseScenario04()
Flash: Off / Exposure: Max / WB: Cloudy Scene: Auto / Pic: Med / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.MAX, WhiteBalance.CLOUDY, SceneMode.AUTO,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario05()
Flash: Auto / Exposure: Max / WB: Incandescent Scene: Auto / Pic: Large / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.MAX, WhiteBalance.INCANDESCENT,
                SceneMode.AUTO, PictureSize.LARGE, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario06()
Flash: On / Exposure: None / WB: Cloudy Scene: Auto / Pic: Small / Geo: on

        genericPairwiseTestCase(Flash.ON, Exposure.NONE, WhiteBalance.CLOUDY, SceneMode.AUTO,
                PictureSize.SMALL, Geotagging.ON);
    
public voidtestCameraPairwiseScenario07()
Flash: Auto / Exposure: Min / WB: Auto Scene: Action / Pic: Small / Geo: on

        genericPairwiseTestCase(Flash.AUTO, Exposure.MIN, WhiteBalance.AUTO, SceneMode.ACTION,
                PictureSize.SMALL, Geotagging.ON);
    
public voidtestCameraPairwiseScenario08()
Flash: On / Exposure: Min / WB: Auto Scene: Action / Pic: Medium / Geo: off

        genericPairwiseTestCase(Flash.ON, Exposure.MIN, WhiteBalance.AUTO, SceneMode.ACTION,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario09()
Flash: Off / Exposure: Min / WB: Auto Scene: Night / Pic: Large / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.MIN, WhiteBalance.AUTO, SceneMode.NIGHT,
                PictureSize.LARGE, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario10()
Flash: Off / Exposure: Min / WB: Daylight Scene: Sunset / Pic: Small / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.MIN, WhiteBalance.DAYLIGHT, SceneMode.SUNSET,
                PictureSize.SMALL, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario11()
Flash: On / Exposure: Max / WB: Daylight Scene: Sunset / Pic: Large / Geo: on

        genericPairwiseTestCase(Flash.ON, Exposure.MAX, WhiteBalance.DAYLIGHT, SceneMode.SUNSET,
                PictureSize.LARGE, Geotagging.ON);
    
public voidtestCameraPairwiseScenario12()
Flash: Auto / Exposure: Min / WB: Cloudy Scene: Auto / Pic: Large / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.MIN, WhiteBalance.CLOUDY, SceneMode.AUTO,
                PictureSize.LARGE, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario13()
Flash: Off / Exposure: None / WB: Auto Scene: Party / Pic: Medium / Geo: on

        genericPairwiseTestCase(Flash.OFF, Exposure.NONE, WhiteBalance.AUTO, SceneMode.PARTY,
                PictureSize.MEDIUM, Geotagging.ON);
    
public voidtestCameraPairwiseScenario14()
Flash: Auto / Exposure: None / WB: Auto Scene: Night / Pic: Small / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.NONE, WhiteBalance.AUTO, SceneMode.NIGHT,
                PictureSize.SMALL, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario15()
Flash: On / Exposure: None / WB: Incandescent Scene: Auto / Pic: Medium / Geo: on

        genericPairwiseTestCase(Flash.ON, Exposure.NONE, WhiteBalance.INCANDESCENT, SceneMode.AUTO,
                PictureSize.MEDIUM, Geotagging.ON);
    
public voidtestCameraPairwiseScenario16()
Flash: Auto / Exposure: Min / WB: Auto Scene: Party / Pic: Small / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.MIN, WhiteBalance.AUTO, SceneMode.PARTY,
                PictureSize.SMALL, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario17()
Flash: Off / Exposure: Min / WB: Incandescent Scene: Auto / Pic: Small / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.MIN, WhiteBalance.INCANDESCENT, SceneMode.AUTO,
                PictureSize.SMALL, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario18()
Flash: On / Exposure: None / WB: Auto Scene: Party / Pic: Large / Geo: off

        genericPairwiseTestCase(Flash.ON, Exposure.NONE, WhiteBalance.AUTO, SceneMode.PARTY,
                PictureSize.LARGE, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario19()
Flash Off / Exposure: None / WB: Auto Scene: Action / Pic: Large / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.NONE, WhiteBalance.AUTO, SceneMode.ACTION,
                PictureSize.LARGE, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario20()
Flash: Off / Exposure: Max / WB: Fluorescent Scene: Auto / Pic: Medium / Geo: Off

        genericPairwiseTestCase(Flash.OFF, Exposure.MAX, WhiteBalance.FLUORESCENT, SceneMode.AUTO,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario21()
Flash: Off / Exposure: Min / WB: Auto Scene: Auto / Pic: Medium / Geo: off

        genericPairwiseTestCase(Flash.OFF, Exposure.MIN, WhiteBalance.AUTO, SceneMode.AUTO,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario22()
Flash: On / Exposure: Max / WB: Auto Scene: Action / Pic: Small / Geo: off

        genericPairwiseTestCase(Flash.ON, Exposure.MAX, WhiteBalance.AUTO, SceneMode.ACTION,
                PictureSize.SMALL, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario23()
Flash: On / Exposure: Max / WB: Auto Scene: Night / Pic: Medium / Geo: on

        genericPairwiseTestCase(Flash.ON, Exposure.MAX, WhiteBalance.AUTO, SceneMode.NIGHT,
                PictureSize.MEDIUM, Geotagging.ON);
    
public voidtestCameraPairwiseScenario24()
Flash: Auto / Exposure: None / WB: Fluorescent Scene: Auto / Pic: Small / Geo: on

        genericPairwiseTestCase(Flash.AUTO, Exposure.NONE, WhiteBalance.FLUORESCENT,
                SceneMode.AUTO, PictureSize.SMALL, Geotagging.ON);
    
public voidtestCameraPairwiseScenario25()
Flash: Auto / Exposure: Max / WB: Daylight Scene: Auto / Pic: Medium / Geo: off

        genericPairwiseTestCase(Flash.AUTO, Exposure.MAX, WhiteBalance.DAYLIGHT, SceneMode.AUTO,
                PictureSize.MEDIUM, Geotagging.OFF);
    
public voidtestCameraPairwiseScenario26()
Flash: Auto / Exposure: Max / WB: Auto Scene: Party / Pic: Medium / Geo: on

        genericPairwiseTestCase(Flash.AUTO, Exposure.MAX, WhiteBalance.AUTO, SceneMode.PARTY,
                PictureSize.MEDIUM, Geotagging.ON);