OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.mojo.shell; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.content.res.AssetManager; |
| 9 |
| 10 import org.chromium.base.CalledByNative; |
| 11 import org.chromium.base.JNINamespace; |
| 12 |
| 13 import java.io.File; |
| 14 import java.io.IOException; |
| 15 |
| 16 /** |
| 17 * Helper method for ShellTestBase. |
| 18 */ |
| 19 @JNINamespace("mojo::shell::test") |
| 20 public class ShellTestBase { |
| 21 // Directory where applications bundled with the tests will be extracted. |
| 22 private static final String TEST_APP_DIRECTORY = "test_apps"; |
| 23 |
| 24 /** |
| 25 * Extracts the mojo applications from the apk assets and returns the direct
ory where they are. |
| 26 */ |
| 27 @CalledByNative |
| 28 private static String extractMojoApplications(Context context) throws IOExce
ption { |
| 29 final File outputDirectory = context.getDir(TEST_APP_DIRECTORY, Context.
MODE_PRIVATE); |
| 30 |
| 31 AssetManager manager = context.getResources().getAssets(); |
| 32 for (String asset : manager.list("")) { |
| 33 if (asset.endsWith(".mojo")) { |
| 34 FileHelper.extractFromAssets(context, asset, outputDirectory, fa
lse); |
| 35 } |
| 36 } |
| 37 |
| 38 return outputDirectory.getAbsolutePath(); |
| 39 } |
| 40 } |
OLD | NEW |