Chromium Code Reviews| 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 |
|
ppi
2014/12/22 12:02:25
nit: add period at the end.
qsr
2014/12/22 12:44:20
Done.
|
| + */ |
| +@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. |
|
ppi
2014/12/22 12:02:25
s/application/applications
ppi
2014/12/22 12:02:25
s/Extract/Extracts/
qsr
2014/12/22 12:44:20
Done.
qsr
2014/12/22 12:44:20
Done.
|
| + */ |
| + @CalledByNative |
| + private static String extractMojoApplication(Context context) throws IOException { |
|
ppi
2014/12/22 12:02:25
s/extractMojoApplication/extractMojoApplications/
qsr
2014/12/22 12:44:20
Done.
|
| + 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(); |
| + } |
| +} |