Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: testing/android/appurify_support/java/src/org/chromium/test/support/RobotiumBundleGenerator.java

Issue 1034053002: [Android] Add an out-of-app instrumentation driver APK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cjhopman comment Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698