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

Unified Diff: shell/android/tests/src/org/chromium/mojo/shell/ShellTestBase.java

Issue 815993004: Run shell tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: move shell_test_base_android.cc Created 6 years 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: shell/android/tests/src/org/chromium/mojo/shell/ShellTestBase.java
diff --git a/shell/android/tests/src/org/chromium/mojo/shell/ShellTestBase.java b/shell/android/tests/src/org/chromium/mojo/shell/ShellTestBase.java
new file mode 100644
index 0000000000000000000000000000000000000000..a5d0da4eaeb20296f11126234791014442c67f94
--- /dev/null
+++ b/shell/android/tests/src/org/chromium/mojo/shell/ShellTestBase.java
@@ -0,0 +1,40 @@
+// Copyright 2014 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.mojo.shell;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Helper method for ShellTestBase
+ */
+@JNINamespace("mojo::shell::test")
+public class ShellTestBase {
+ // Directory where applications bundled with the tests will be extracted.
+ private static final String TEST_APP_DIRECTORY = "test_apps";
+
+ /**
+ * Extract the mojo application from the apk assets and returns the directory where they are.
+ */
+ @CalledByNative
+ private static String extractMojoApplication(Context context) throws IOException {
+ final File outputDirectory = context.getDir(TEST_APP_DIRECTORY, Context.MODE_PRIVATE);
+
+ AssetManager manager = context.getResources().getAssets();
+ for (String asset : manager.list("")) {
+ if (asset.endsWith(".mojo")) {
+ FileHelper.extractFromAssets(context, asset, outputDirectory, false);
+ }
+ }
+
+ return outputDirectory.getAbsolutePath();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698