Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a178d672 authored by Xia Wang's avatar Xia Wang
Browse files

Fix image processing test to include all benchmark tests

-- each test case can be excuted separately
-- add a test case to run all benchmarks.

DO NOT MERGE

Change-Id: I3c61dfe50267a6db11bc1895a4f37ed618a9103b
parent 0dae634b
Loading
Loading
Loading
Loading
+86 −85
Original line number Original line Diff line number Diff line
@@ -21,14 +21,7 @@ import android.os.Bundle;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.renderscript.ScriptC;
import android.renderscript.RenderScript;
import android.renderscript.Type;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.Script;
import android.view.SurfaceView;
import android.view.SurfaceView;
import android.view.SurfaceHolder;
import android.widget.AdapterView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ImageView;
@@ -37,13 +30,8 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TextView;
import android.view.View;
import android.view.View;
import android.util.Log;
import android.util.Log;
import java.lang.Math;


import android.os.Environment;
import android.os.Environment;
import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import java.io.BufferedWriter;
import java.io.BufferedWriter;
import java.io.File;
import java.io.File;
import java.io.FileWriter;
import java.io.FileWriter;
@@ -52,12 +40,57 @@ import java.io.IOException;
public class ImageProcessingActivity extends Activity
public class ImageProcessingActivity extends Activity
                                       implements SeekBar.OnSeekBarChangeListener {
                                       implements SeekBar.OnSeekBarChangeListener {
    private final String TAG = "Img";
    private final String TAG = "Img";
    private final String RESULT_FILE = "image_processing_result.csv";
    public final String RESULT_FILE = "image_processing_result.csv";

    /**
     * Define enum type for test names
     */
    public enum TestName {
        LEVELS_VEC3_RELAXED ("Levels Vec3 Relaxed"),
        LEVELS_VEC4_RELAXED ("Levels Vec4 Relaxed"),
        LEVELS_VEC3_FULL ("Levels Vec3 Full"),
        LEVELS_VEC4_FULL ("Levels Vec4 Full"),
        BLUR_RADIUS_25 ("Blur radius 25"),
        INTRINSIC_BLUE_RADIUS_25 ("Intrinsic Blur radius 25"),
        GREYSCALE ("Greyscale"),
        GRAIN ("Grain"),
        FISHEYE_FULL ("Fisheye Full"),
        FISHEYE_RELAXED ("Fisheye Relaxed"),
        FISHEYE_APPROXIMATE_FULL ("Fisheye Approximate Full"),
        FISHEYE_APPROXIMATE_RELAXED ("Fisheye Approximate Relaxed"),
        VIGNETTE_FULL ("Vignette Full"),
        VIGNETTE_RELAXED ("Vignette Relaxed"),
        VIGNETTE_APPROXIMATE_FULL ("Vignette Approximate Full"),
        VIGNETTE_APPROXIMATE_RELAXED ("Vignette Approximate Relaxed"),
        GROUP_TEST_EMULATED ("Group Test (emulated)"),
        GROUP_TEST_NATIVE ("Group Test (native)"),
        CONVOLVE_3X3 ("Convolve 3x3"),
        INTRINSICS_CONVOLVE_3X3 ("Intrinsics Convolve 3x3"),
        COLOR_MATRIX ("ColorMatrix"),
        INTRINSICS_COLOR_MATRIX ("Intrinsics ColorMatrix"),
        INTRINSICS_COLOR_MATRIX_GREY ("Intrinsics ColorMatrix Grey"),
        COPY ("Copy"),
        CROSS_PROCESS_USING_LUT ("CrossProcess (using LUT)"),
        CONVOLVE_5X5 ("Convolve 5x5"),
        INTRINSICS_CONVOLVE_5X5 ("Intrinsics Convolve 5x5"),
        MANDELBROT ("Mandelbrot"),
        INTRINSICS_BLEND ("Intrinsics Blend");

        private final String name;

        private TestName(String s) {
            name = s;
        }

        // return quoted string as displayed test name
        public String toString() {
            return name;
        }
    }


    Bitmap mBitmapIn;
    Bitmap mBitmapIn;
    Bitmap mBitmapIn2;
    Bitmap mBitmapIn2;
    Bitmap mBitmapOut;
    Bitmap mBitmapOut;
    String mTestNames[];


    private Spinner mSpinner;
    private Spinner mSpinner;
    private SeekBar mBar1;
    private SeekBar mBar1;
@@ -140,96 +173,96 @@ public class ImageProcessingActivity extends Activity
    }
    }




    void changeTest(int testID) {
    void changeTest(TestName testName) {
        if (mTest != null) {
        if (mTest != null) {
            mTest.destroy();
            mTest.destroy();
        }
        }
        switch(testID) {
        switch(testName) {
        case 0:
        case LEVELS_VEC3_RELAXED:
            mTest = new LevelsV4(false, false);
            mTest = new LevelsV4(false, false);
            break;
            break;
        case 1:
        case LEVELS_VEC4_RELAXED:
            mTest = new LevelsV4(false, true);
            mTest = new LevelsV4(false, true);
            break;
            break;
        case 2:
        case LEVELS_VEC3_FULL:
            mTest = new LevelsV4(true, false);
            mTest = new LevelsV4(true, false);
            break;
            break;
        case 3:
        case LEVELS_VEC4_FULL:
            mTest = new LevelsV4(true, true);
            mTest = new LevelsV4(true, true);
            break;
            break;
        case 4:
        case BLUR_RADIUS_25:
            mTest = new Blur25(false);
            mTest = new Blur25(false);
            break;
            break;
        case 5:
        case INTRINSIC_BLUE_RADIUS_25:
            mTest = new Blur25(true);
            mTest = new Blur25(true);
            break;
            break;
        case 6:
        case GREYSCALE:
            mTest = new Greyscale();
            mTest = new Greyscale();
            break;
            break;
        case 7:
        case GRAIN:
            mTest = new Grain();
            mTest = new Grain();
            break;
            break;
        case 8:
        case FISHEYE_FULL:
            mTest = new Fisheye(false, false);
            mTest = new Fisheye(false, false);
            break;
            break;
        case 9:
        case FISHEYE_RELAXED:
            mTest = new Fisheye(false, true);
            mTest = new Fisheye(false, true);
            break;
            break;
        case 10:
        case FISHEYE_APPROXIMATE_FULL:
            mTest = new Fisheye(true, false);
            mTest = new Fisheye(true, false);
            break;
            break;
        case 11:
        case FISHEYE_APPROXIMATE_RELAXED:
            mTest = new Fisheye(true, true);
            mTest = new Fisheye(true, true);
            break;
            break;
        case 12:
        case VIGNETTE_FULL:
            mTest = new Vignette(false, false);
            mTest = new Vignette(false, false);
            break;
            break;
        case 13:
        case VIGNETTE_RELAXED:
            mTest = new Vignette(false, true);
            mTest = new Vignette(false, true);
            break;
            break;
        case 14:
        case VIGNETTE_APPROXIMATE_FULL:
            mTest = new Vignette(true, false);
            mTest = new Vignette(true, false);
            break;
            break;
        case 15:
        case VIGNETTE_APPROXIMATE_RELAXED:
            mTest = new Vignette(true, true);
            mTest = new Vignette(true, true);
            break;
            break;
        case 16:
        case GROUP_TEST_EMULATED:
            mTest = new GroupTest(false);
            mTest = new GroupTest(false);
            break;
            break;
        case 17:
        case GROUP_TEST_NATIVE:
            mTest = new GroupTest(true);
            mTest = new GroupTest(true);
            break;
            break;
        case 18:
        case CONVOLVE_3X3:
            mTest = new Convolve3x3(false);
            mTest = new Convolve3x3(false);
            break;
            break;
        case 19:
        case INTRINSICS_CONVOLVE_3X3:
            mTest = new Convolve3x3(true);
            mTest = new Convolve3x3(true);
            break;
            break;
        case 20:
        case COLOR_MATRIX:
            mTest = new ColorMatrix(false, false);
            mTest = new ColorMatrix(false, false);
            break;
            break;
        case 21:
        case INTRINSICS_COLOR_MATRIX:
            mTest = new ColorMatrix(true, false);
            mTest = new ColorMatrix(true, false);
            break;
            break;
        case 22:
        case INTRINSICS_COLOR_MATRIX_GREY:
            mTest = new ColorMatrix(true, true);
            mTest = new ColorMatrix(true, true);
            break;
            break;
        case 23:
        case COPY:
            mTest = new Copy();
            mTest = new Copy();
            break;
            break;
        case 24:
        case CROSS_PROCESS_USING_LUT:
            mTest = new CrossProcess();
            mTest = new CrossProcess();
            break;
            break;
        case 25:
        case CONVOLVE_5X5:
            mTest = new Convolve5x5(false);
            mTest = new Convolve5x5(false);
            break;
            break;
        case 26:
        case INTRINSICS_CONVOLVE_5X5:
            mTest = new Convolve5x5(true);
            mTest = new Convolve5x5(true);
            break;
            break;
        case 27:
        case MANDELBROT:
            mTest = new Mandelbrot();
            mTest = new Mandelbrot();
            break;
            break;
        case 28:
        case INTRINSICS_BLEND:
            mTest = new Blend();
            mTest = new Blend();
            break;
            break;
        }
        }
@@ -243,45 +276,14 @@ public class ImageProcessingActivity extends Activity
    }
    }


    void setupTests() {
    void setupTests() {
        mTestNames = new String[29];
        mTestSpinner.setAdapter(new ArrayAdapter<TestName>(
        mTestNames[0] = "Levels Vec3 Relaxed";
            this, R.layout.spinner_layout, TestName.values()));
        mTestNames[1] = "Levels Vec4 Relaxed";
        mTestNames[2] = "Levels Vec3 Full";
        mTestNames[3] = "Levels Vec4 Full";
        mTestNames[4] = "Blur radius 25";
        mTestNames[5] = "Intrinsic Blur radius 25";
        mTestNames[6] = "Greyscale";
        mTestNames[7] = "Grain";
        mTestNames[8] = "Fisheye Full";
        mTestNames[9] = "Fisheye Relaxed";
        mTestNames[10] = "Fisheye Approximate Full";
        mTestNames[11] = "Fisheye Approximate Relaxed";
        mTestNames[12] = "Vignette Full";
        mTestNames[13] = "Vignette Relaxed";
        mTestNames[14] = "Vignette Approximate Full";
        mTestNames[15] = "Vignette Approximate Relaxed";
        mTestNames[16] = "Group Test (emulated)";
        mTestNames[17] = "Group Test (native)";
        mTestNames[18] = "Convolve 3x3";
        mTestNames[19] = "Intrinsics Convolve 3x3";
        mTestNames[20] = "ColorMatrix";
        mTestNames[21] = "Intrinsics ColorMatrix";
        mTestNames[22] = "Intrinsics ColorMatrix Grey";
        mTestNames[23] = "Copy";
        mTestNames[24] = "CrossProcess (using LUT)";
        mTestNames[25] = "Convolve 5x5";
        mTestNames[26] = "Intrinsics Convolve 5x5";
        mTestNames[27] = "Mandelbrot";
        mTestNames[28] = "Intrinsics Blend";

        mTestSpinner.setAdapter(new ArrayAdapter<String>(
            this, R.layout.spinner_layout, mTestNames));
    }
    }


    private AdapterView.OnItemSelectedListener mTestSpinnerListener =
    private AdapterView.OnItemSelectedListener mTestSpinnerListener =
            new AdapterView.OnItemSelectedListener() {
            new AdapterView.OnItemSelectedListener() {
                public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                    changeTest(pos);
                    changeTest(TestName.values()[pos]);
                }
                }


                public void onNothingSelected(AdapterView parent) {
                public void onNothingSelected(AdapterView parent) {
@@ -330,7 +332,7 @@ public class ImageProcessingActivity extends Activity
        mBenchmarkResult.setText("Result: not run");
        mBenchmarkResult.setText("Result: not run");


        setupTests();
        setupTests();
        changeTest(0);
        changeTest(TestName.LEVELS_VEC3_RELAXED);
    }
    }




@@ -369,10 +371,10 @@ public class ImageProcessingActivity extends Activity
        try {
        try {
            BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
            BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
            Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
            Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
            for (int i = 0; i < mTestNames.length; i++ ) {
            for (TestName tn: TestName.values()) {
                changeTest(i);
                changeTest(tn);
                float t = getBenchmark();
                float t = getBenchmark();
                String s = new String("" + mTestNames[i] + ", " + t);
                String s = new String("" + tn.toString() + ", " + t);
                rsWriter.write(s + "\n");
                rsWriter.write(s + "\n");
                Log.v(TAG, "Test " + s + "ms\n");
                Log.v(TAG, "Test " + s + "ms\n");
            }
            }
@@ -380,7 +382,7 @@ public class ImageProcessingActivity extends Activity
        } catch (IOException e) {
        } catch (IOException e) {
            Log.v(TAG, "Unable to write result file " + e.getMessage());
            Log.v(TAG, "Unable to write result file " + e.getMessage());
        }
        }
        changeTest(0);
        changeTest(TestName.LEVELS_VEC3_RELAXED);
    }
    }


    // For benchmark test
    // For benchmark test
@@ -397,7 +399,6 @@ public class ImageProcessingActivity extends Activity
            mTest.finish();
            mTest.finish();
        } while (t > java.lang.System.currentTimeMillis());
        } while (t > java.lang.System.currentTimeMillis());



        //Log.v(TAG, "Benchmarking");
        //Log.v(TAG, "Benchmarking");
        int ct = 0;
        int ct = 0;
        t = java.lang.System.currentTimeMillis();
        t = java.lang.System.currentTimeMillis();
+265 −43
Original line number Original line Diff line number Diff line
@@ -16,33 +16,30 @@


package com.android.rs.image;
package com.android.rs.image;


import com.android.rs.image.ImageProcessingTestRunner;

import android.os.Bundle;
import android.os.Bundle;
import android.os.Environment;
import com.android.rs.image.ImageProcessingActivity.TestName;
import android.app.Instrumentation;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
import android.util.Log;


import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
/**
 * ImageProcessing benchmark test.
 * ImageProcessing benchmark test.
 * To run the test, please use command
 * To run the test, please use command
 *
 *
 * adb shell am instrument -w com.android.rs.image/.ImageProcessingTestRunner
 * adb shell am instrument -e iteration <n> -w com.android.rs.image/.ImageProcessingTestRunner
 *
 *
 */
 */
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageProcessingActivity> {
    private final String TAG = "ImageProcessingTest";
    private final String TAG = "ImageProcessingTest";
    private final String RESULT_FILE = "image_processing_result.txt";
    private final String TEST_NAME = "Testname";
    private int ITERATION = 5;
    private final String ITERATIONS = "Iterations";
    private ImageProcessingActivity mAct;
    private final String BENCHMARK = "Benchmark";
    private static int INSTRUMENTATION_IN_PROGRESS = 2;
    private int mIteration;
    private ImageProcessingActivity mActivity;


    public ImageProcessingTest() {
    public ImageProcessingTest() {
        super(ImageProcessingActivity.class);
        super(ImageProcessingActivity.class);
@@ -51,7 +48,11 @@ public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageP
    @Override
    @Override
    public void setUp() throws Exception {
    public void setUp() throws Exception {
        super.setUp();
        super.setUp();
        mAct = getActivity();
        setActivityInitialTouchMode(false);
        mActivity = getActivity();
        ImageProcessingTestRunner mRunner = (ImageProcessingTestRunner) getInstrumentation();
        mIteration = mRunner.mIteration;
        assertTrue("please enter a valid iteration value", mIteration > 0);
   }
   }


    @Override
    @Override
@@ -59,36 +60,257 @@ public class ImageProcessingTest extends ActivityInstrumentationTestCase2<ImageP
        super.tearDown();
        super.tearDown();
    }
    }


    /**
    class TestAction implements Runnable {
     * ImageProcessing benchmark test
        TestName mTestName;
     */
        float mResult;
    @LargeTest
        public TestAction(TestName testName) {
    public void testImageProcessingBench() {
            mTestName = testName;
        long t = 0;
        }
        long sum = 0;
        public void run() {
        // write result into a file
            mActivity.changeTest(mTestName);
        File externalStorage = Environment.getExternalStorageDirectory();
            mResult = mActivity.getBenchmark();
        if (!externalStorage.canWrite()) {
            Log.v(TAG, "Benchmark for test \"" + mTestName.toString() + "\" is: " + mResult);
            Log.v(TAG, "sdcard is not writable");
            synchronized(this) {
            return;
                this.notify();
        }
            }
        File resultFile = new File(externalStorage, RESULT_FILE);
        }
        resultFile.setWritable(true, false);
        public float getBenchmark() {
            return mResult;
        }
    }

    // Set the benchmark thread to run on ui thread
    // Synchronized the thread such that the test will wait for the benchmark thread to finish
    public void runOnUiThread(Runnable action) {
        synchronized(action) {
            mActivity.runOnUiThread(action);
            try {
            try {
            BufferedWriter rsWriter = new BufferedWriter(new FileWriter(resultFile));
                action.wait();
            Log.v(TAG, "Saved results in: " + resultFile.getAbsolutePath());
            } catch (InterruptedException e) {
            for (int i = 0; i < ITERATION; i++ ) {
                Log.v(TAG, "waiting for action running on UI thread is interrupted: " +
                t = (long)mAct.getBenchmark();
                        e.toString());
                sum += t;
            }
                rsWriter.write("Renderscript frame time core: " + t + " ms\n");
        }
                Log.v(TAG, "RenderScript framew time core: " + t + " ms");
    }
            }

            long avgValue = sum/ITERATION;
    public void runTest(TestAction ta, String testName) {
            rsWriter.write("Average frame time: " + avgValue + " ms\n");
        float sum = 0;
            Log.v(TAG, "Average frame time: " + avgValue + " ms");
        for (int i = 0; i < mIteration; i++) {
            rsWriter.close();
            runOnUiThread(ta);
        } catch (IOException e) {
            float bmValue = ta.getBenchmark();
            Log.v(TAG, "Unable to write result file " + e.getMessage());
            Log.v(TAG, "results for iteration " + i + " is " + bmValue);
            sum += bmValue;
        }
        float avgResult = sum/mIteration;

        // post result to INSTRUMENTATION_STATUS
        Bundle results = new Bundle();
        results.putString(TEST_NAME, testName);
        results.putInt(ITERATIONS, mIteration);
        results.putFloat(BENCHMARK, avgResult);
        getInstrumentation().sendStatus(INSTRUMENTATION_IN_PROGRESS, results);
    }

    // Test case 0: Levels Vec3 Relaxed
    @LargeTest
    public void testLevelsVec3Relaxed() {
        TestAction ta = new TestAction(TestName.LEVELS_VEC3_RELAXED);
        runTest(ta, TestName.LEVELS_VEC3_RELAXED.name());
    }

    // Test case 1: Levels Vec4 Relaxed
    @LargeTest
    public void testLevelsVec4Relaxed() {
        TestAction ta = new TestAction(TestName.LEVELS_VEC4_RELAXED);
        runTest(ta, TestName.LEVELS_VEC4_RELAXED.name());
    }

    // Test case 2: Levels Vec3 Full
    @LargeTest
    public void testLevelsVec3Full() {
        TestAction ta = new TestAction(TestName.LEVELS_VEC3_FULL);
        runTest(ta, TestName.LEVELS_VEC3_FULL.name());
    }

    // Test case 3: Levels Vec4 Full
    @LargeTest
    public void testLevelsVec4Full() {
        TestAction ta = new TestAction(TestName.LEVELS_VEC4_FULL);
        runTest(ta, TestName.LEVELS_VEC4_FULL.name());
    }

    // Test case 4: Blur Radius 25
    @LargeTest
    public void testBlurRadius25() {
        TestAction ta = new TestAction(TestName.BLUR_RADIUS_25);
        runTest(ta, TestName.BLUR_RADIUS_25.name());
    }

    // Test case 5: Intrinsic Blur Radius 25
    @LargeTest
    public void testIntrinsicBlurRadius25() {
        TestAction ta = new TestAction(TestName.INTRINSIC_BLUE_RADIUS_25);
        runTest(ta, TestName.INTRINSIC_BLUE_RADIUS_25.name());
    }

    // Test case 6: Greyscale
    @LargeTest
    public void testGreyscale() {
        TestAction ta = new TestAction(TestName.GREYSCALE);
        runTest(ta, TestName.GREYSCALE.name());
    }

    // Test case 7: Grain
    @LargeTest
    public void testGrain() {
        TestAction ta = new TestAction(TestName.GRAIN);
        runTest(ta, TestName.GRAIN.name());
    }

    // Test case 8: Fisheye Full
    @LargeTest
    public void testFisheyeFull() {
        TestAction ta = new TestAction(TestName.FISHEYE_FULL);
        runTest(ta, TestName.FISHEYE_FULL.name());
    }

    // Test case 9: Fisheye Relaxed
    @LargeTest
    public void testFishEyeRelaxed() {
        TestAction ta = new TestAction(TestName.FISHEYE_RELAXED);
        runTest(ta, TestName.FISHEYE_RELAXED.name());
    }

    // Test case 10: Fisheye Approximate Full
    @LargeTest
    public void testFisheyeApproximateFull() {
        TestAction ta = new TestAction(TestName.FISHEYE_APPROXIMATE_FULL);
        runTest(ta, TestName.FISHEYE_APPROXIMATE_FULL.name());
    }

    // Test case 11: Fisheye Approximate Relaxed
    @LargeTest
    public void testFisheyeApproximateRelaxed() {
        TestAction ta = new TestAction(TestName.FISHEYE_APPROXIMATE_RELAXED);
        runTest(ta, TestName.FISHEYE_APPROXIMATE_RELAXED.name());
    }

    // Test case 12: Vignette Full
    @LargeTest
    public void testVignetteFull() {
        TestAction ta = new TestAction(TestName.VIGNETTE_FULL);
        runTest(ta, TestName.VIGNETTE_FULL.name());
    }

    // Test case 13: Vignette Relaxed
    @LargeTest
    public void testVignetteRelaxed() {
        TestAction ta = new TestAction(TestName.VIGNETTE_RELAXED);
        runTest(ta, TestName.VIGNETTE_RELAXED.name());
    }

    // Test case 14: Vignette Approximate Full
    @LargeTest
    public void testVignetteApproximateFull() {
        TestAction ta = new TestAction(TestName.VIGNETTE_APPROXIMATE_FULL);
        runTest(ta, TestName.VIGNETTE_APPROXIMATE_FULL.name());
    }

    // Test case 15: Vignette Approximate Relaxed
    @LargeTest
    public void testVignetteApproximateRelaxed() {
        TestAction ta = new TestAction(TestName.VIGNETTE_APPROXIMATE_RELAXED);
        runTest(ta, TestName.VIGNETTE_APPROXIMATE_RELAXED.name());
    }

    // Test case 16: Group Test (emulated)
    @LargeTest
    public void testGroupTestEmulated() {
        TestAction ta = new TestAction(TestName.GROUP_TEST_EMULATED);
        runTest(ta, TestName.GROUP_TEST_EMULATED.name());
    }

    // Test case 17: Group Test (native)
    @LargeTest
    public void testGroupTestNative() {
        TestAction ta = new TestAction(TestName.GROUP_TEST_NATIVE);
        runTest(ta, TestName.GROUP_TEST_NATIVE.name());
    }

    // Test case 18: Convolve 3x3
    @LargeTest
    public void testConvolve3x3() {
        TestAction ta = new TestAction(TestName.CONVOLVE_3X3);
        runTest(ta, TestName.CONVOLVE_3X3.name());
    }

    // Test case 19: Intrinsics Convolve 3x3
    @LargeTest
    public void testIntrinsicsConvolve3x3() {
        TestAction ta = new TestAction(TestName.INTRINSICS_CONVOLVE_3X3);
        runTest(ta, TestName.INTRINSICS_CONVOLVE_3X3.name());
    }
    }

    // Test case 20: ColorMatrix
    @LargeTest
    public void testColorMatrix() {
        TestAction ta = new TestAction(TestName.COLOR_MATRIX);
        runTest(ta, TestName.COLOR_MATRIX.name());
    }

    // Test case 21: Intrinsics ColorMatrix
    @LargeTest
    public void testIntrinsicsColorMatrix() {
        TestAction ta = new TestAction(TestName.INTRINSICS_COLOR_MATRIX);
        runTest(ta, TestName.INTRINSICS_COLOR_MATRIX.name());
    }

    // Test case 22: Intrinsics ColorMatrix Grey
    @LargeTest
    public void testIntrinsicsColorMatrixGrey() {
        TestAction ta = new TestAction(TestName.INTRINSICS_COLOR_MATRIX_GREY);
        runTest(ta, TestName.INTRINSICS_COLOR_MATRIX_GREY.name());
    }

    // Test case 23: Copy
    @LargeTest
    public void testCopy() {
        TestAction ta = new TestAction(TestName.COPY);
        runTest(ta, TestName.COPY.name());
    }

    // Test case 24: CrossProcess (using LUT)
    @LargeTest
    public void testCrossProcessUsingLUT() {
        TestAction ta = new TestAction(TestName.CROSS_PROCESS_USING_LUT);
        runTest(ta, TestName.CROSS_PROCESS_USING_LUT.name());
    }

    // Test case 25: Convolve 5x5
    @LargeTest
    public void testConvolve5x5() {
        TestAction ta = new TestAction(TestName.CONVOLVE_5X5);
        runTest(ta, TestName.CONVOLVE_5X5.name());
    }

    // Test case 26: Intrinsics Convolve 5x5
    @LargeTest
    public void testIntrinsicsConvolve5x5() {
        TestAction ta = new TestAction(TestName.INTRINSICS_CONVOLVE_5X5);
        runTest(ta, TestName.INTRINSICS_CONVOLVE_5X5.name());
    }

    // Test case 27: Mandelbrot
    @LargeTest
    public void testMandelbrot() {
        TestAction ta = new TestAction(TestName.MANDELBROT);
        runTest(ta, TestName.MANDELBROT.name());
    }

    // Test case 28
    @LargeTest
    public void testIntrinsicsBlend() {
        TestAction ta = new TestAction(TestName.INTRINSICS_BLEND);
        runTest(ta, TestName.INTRINSICS_BLEND.name());
    }
    }
}
}
+12 −1
Original line number Original line Diff line number Diff line
@@ -24,14 +24,25 @@ import junit.framework.TestSuite;


/**
/**
 * Run the ImageProcessing benchmark test
 * Run the ImageProcessing benchmark test
 * adb shell am instrument -w com.android.rs.image/.ImageProcessingTestRunner
 * adb shell am instrument -e iteration <n> -w com.android.rs.image/.ImageProcessingTestRunner
 *
 *
 */
 */
public class ImageProcessingTestRunner extends InstrumentationTestRunner {
public class ImageProcessingTestRunner extends InstrumentationTestRunner {
    public int mIteration = 5;

    @Override
    @Override
    public TestSuite getAllTests() {
    public TestSuite getAllTests() {
        TestSuite suite = new InstrumentationTestSuite(this);
        TestSuite suite = new InstrumentationTestSuite(this);
        suite.addTestSuite(ImageProcessingTest.class);
        suite.addTestSuite(ImageProcessingTest.class);
        return suite;
        return suite;
    }
    }

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        String strIteration = (String) icicle.get("iteration");
        if (strIteration != null) {
            mIteration = Integer.parseInt(strIteration);
        }
    }
}
}