Search in sources :

Example 1 with TestSuiteBuilder

use of android.test.suitebuilder.TestSuiteBuilder in project android_frameworks_base by ParanoidAndroid.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Example 2 with TestSuiteBuilder

use of android.test.suitebuilder.TestSuiteBuilder in project android_frameworks_base by DirtyUnicorns.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Example 3 with TestSuiteBuilder

use of android.test.suitebuilder.TestSuiteBuilder in project android_frameworks_base by ResurrectionRemix.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Example 4 with TestSuiteBuilder

use of android.test.suitebuilder.TestSuiteBuilder in project android_frameworks_base by crdroidandroid.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Example 5 with TestSuiteBuilder

use of android.test.suitebuilder.TestSuiteBuilder in project platform_frameworks_base by android.

the class InstrumentationTestRunner method onCreate.

@Override
public void onCreate(Bundle arguments) {
    super.onCreate(arguments);
    mArguments = arguments;
    // Apk paths used to search for test classes when using TestSuiteBuilders.
    String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
    ClassPathPackageInfoSource.setApkPaths(apkPaths);
    Predicate<TestMethod> testSizePredicate = null;
    Predicate<TestMethod> testAnnotationPredicate = null;
    Predicate<TestMethod> testNotAnnotationPredicate = null;
    String testClassesArg = null;
    boolean logOnly = false;
    if (arguments != null) {
        // Test class name passed as an argument should override any meta-data declaration.
        testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
        mDebug = getBooleanArgument(arguments, "debug");
        mJustCount = getBooleanArgument(arguments, "count");
        mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
        mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
        testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
        testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
        testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
        logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
        mCoverage = getBooleanArgument(arguments, "coverage");
        mCoverageFilePath = arguments.getString("coverageFile");
        try {
            // Accept either string or int
            Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
            if (delay != null)
                mDelayMsec = Integer.parseInt(delay.toString());
        } catch (NumberFormatException e) {
            Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
        }
    }
    TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
    if (testSizePredicate != null) {
        testSuiteBuilder.addRequirements(testSizePredicate);
    }
    if (testAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testAnnotationPredicate);
    }
    if (testNotAnnotationPredicate != null) {
        testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
    }
    if (testClassesArg == null) {
        if (mPackageOfTests != null) {
            testSuiteBuilder.includePackages(mPackageOfTests);
        } else {
            TestSuite testSuite = getTestSuite();
            if (testSuite != null) {
                testSuiteBuilder.addTestSuite(testSuite);
            } else {
                // no package or class bundle arguments were supplied, and no test suite
                // provided so add all tests in application
                testSuiteBuilder.includePackages("");
            }
        }
    } else {
        parseTestClasses(testClassesArg, testSuiteBuilder);
    }
    testSuiteBuilder.addRequirements(getBuilderRequirements());
    mTestRunner = getAndroidTestRunner();
    mTestRunner.setContext(getTargetContext());
    mTestRunner.setInstrumentation(this);
    mTestRunner.setSkipExecution(logOnly);
    mTestRunner.setTest(testSuiteBuilder.build());
    mTestCount = mTestRunner.getTestCases().size();
    if (mSuiteAssignmentMode) {
        mTestRunner.addTestListener(new SuiteAssignmentPrinter());
    } else {
        WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
        mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
        mTestRunner.addTestListener(resultPrinter);
        mTestRunner.setPerformanceResultsWriter(resultPrinter);
    }
    start();
}
Also used : TestSuiteBuilder(android.test.suitebuilder.TestSuiteBuilder) TestSuite(junit.framework.TestSuite) TestMethod(android.test.suitebuilder.TestMethod)

Aggregations

TestMethod (android.test.suitebuilder.TestMethod)5 TestSuiteBuilder (android.test.suitebuilder.TestSuiteBuilder)5 TestSuite (junit.framework.TestSuite)5