/** * send a status for the start of a each test, so long tests can be seen * as "running" */ @Override public void startTest(Test test) { String testClass = test.getClass().getName(); String testName = ((TestCase) test).getName(); mTestResult = new Bundle(mResultTemplate); mTestResult.putString(REPORT_KEY_NAME_CLASS, testClass); mTestResult.putString(REPORT_KEY_NAME_TEST, testName); mTestResult.putInt(REPORT_KEY_NUM_CURRENT, ++mTestNum); // pretty printing if (testClass != null && !testClass.equals(mTestClass)) { mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, String.format("\n%s:", testClass)); mTestClass = testClass; } else { mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, ""); } Method testMethod = null; try { testMethod = test.getClass().getMethod(testName); // Report total number of iterations, if test is repetitive if (testMethod.isAnnotationPresent(RepetitiveTest.class)) { int numIterations = testMethod.getAnnotation(RepetitiveTest.class).numIterations(); mTestResult.putInt(REPORT_KEY_NUM_ITERATIONS, numIterations); } } catch (NoSuchMethodException e) { // ignore- the test with given name does not exist. Will be // handled during test // execution } mAutomationSupport.sendStatus(REPORT_VALUE_RESULT_START, mTestResult); mTestResultCode = 0; mPrinter.startTest(test); }
@RepetitiveTest(numIterations=NUM_ITERATIONS) public void testLauncherRotationStress() throws Exception { Launcher launcher = getActivity(); getInstrumentation().waitForIdleSync(); SystemClock.sleep(WAIT_TIME_MS); launcher.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); getInstrumentation().waitForIdleSync(); SystemClock.sleep(WAIT_TIME_MS); launcher.setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }