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

Unified Diff: testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java

Issue 2710343003: Update Robolectric to 3.2.2 (Closed)
Patch Set: Small fix to StripLayoutHelperTest Created 3 years, 9 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/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
diff --git a/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..09cec0738be785a7a2b99acff2375c88d4751f90
--- /dev/null
+++ b/testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java
@@ -0,0 +1,40 @@
+// Copyright 2017 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.testing.local;
+
+import org.robolectric.annotation.Config;
+import org.robolectric.internal.ManifestFactory;
+import org.robolectric.internal.ManifestIdentifier;
+import org.robolectric.manifest.AndroidManifest;
+
+// TODO(mikecase): Add support for specifying the AndroidManifest for
+// Robolectric tests.
+
+/**
+ * Class that manages passing Android manifest information to Robolectric.
+ */
+public class GNManifestFactory implements ManifestFactory {
+ private static final String DEFAULT_PACKAGE_NAME = "org.robolectric.default";
+
+ @Override
+ public ManifestIdentifier identify(Config config) {
+ if (!config.manifest().equals(Config.NONE)) {
+ throw new RuntimeException("Specifying custom manifest not currently supported. "
+ + "Please use annotation @Config(manifest = Config.NONE) on Robolectric tests "
+ + "for the time being.");
+ }
+ return new ManifestIdentifier(null, null, null, config.packageName(), null);
+ }
+
+ @Override
+ public AndroidManifest create(ManifestIdentifier manifestIdentifier) {
+ String packageName = manifestIdentifier.getPackageName();
+ if (packageName == null || packageName.equals("")) {
+ packageName = DEFAULT_PACKAGE_NAME;
+ }
+
+ return new AndroidManifest(null, null, null, packageName);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698