| Index: testing/android/appurify_support/java/src/org/chromium/test/support/RobotiumBundleGenerator.java
|
| diff --git a/testing/android/appurify_support/java/src/org/chromium/test/support/RobotiumBundleGenerator.java b/testing/android/appurify_support/java/src/org/chromium/test/support/RobotiumBundleGenerator.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..167e7b92a4f900e23b3ef0c7097d22fee9c9b323
|
| --- /dev/null
|
| +++ b/testing/android/appurify_support/java/src/org/chromium/test/support/RobotiumBundleGenerator.java
|
| @@ -0,0 +1,56 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.test.support;
|
| +
|
| +import android.app.Instrumentation;
|
| +import android.os.Bundle;
|
| +import android.util.Log;
|
| +
|
| +import java.util.Map;
|
| +
|
| +/**
|
| + * Creates a results bundle that emulates the one created by Robotium.
|
| + */
|
| +public class RobotiumBundleGenerator implements ResultsBundleGenerator {
|
| +
|
| + private static final String TAG = "RobotiumBundleGenerator";
|
| +
|
| + public Bundle generate(Map<String, ResultsBundleGenerator.TestResult> rawResults) {
|
| + int testsPassed = 0;
|
| + int testsFailed = 0;
|
| +
|
| + for (Map.Entry<String, ResultsBundleGenerator.TestResult> entry : rawResults.entrySet()) {
|
| + switch (entry.getValue()) {
|
| + case PASSED:
|
| + ++testsPassed;
|
| + break;
|
| + case FAILED:
|
| + // TODO(jbudorick): Remove this log message once AMP execution and
|
| + // results handling has been stabilized.
|
| + Log.d(TAG, "FAILED: " + entry.getKey());
|
| + ++testsFailed;
|
| + break;
|
| + default:
|
| + Log.w(TAG, "Unhandled: " + entry.getKey() + ", "
|
| + + entry.getValue().toString());
|
| + break;
|
| + }
|
| + }
|
| +
|
| + StringBuilder resultBuilder = new StringBuilder();
|
| + if (testsFailed > 0) {
|
| + resultBuilder.append(
|
| + "\nFAILURES!!! Tests run: " + Integer.toString(rawResults.size())
|
| + + ", Failures: " + Integer.toString(testsFailed) + ", Errors: 0");
|
| + } else {
|
| + resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)");
|
| + }
|
| +
|
| + Bundle resultsBundle = new Bundle();
|
| + resultsBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
|
| + resultBuilder.toString());
|
| + return resultsBundle;
|
| + }
|
| +}
|
|
|