Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mojo / runner / shell_test_base_android.cc
blobded757bb0c9d0d99391618de62e184ba26ee5ce3
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.
5 #include "mojo/runner/shell_test_base.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h"
11 #include "jni/ShellTestBase_jni.h"
12 #include "mojo/util/filename_util.h"
13 #include "url/gurl.h"
15 namespace mojo {
16 namespace runner {
17 namespace test {
19 namespace {
21 JNIEnv* InitEnv() {
22 JNIEnv* env = base::android::AttachCurrentThread();
23 static bool initialized = false;
24 if (!initialized) {
25 RegisterNativesImpl(env);
26 initialized = true;
28 return env;
31 } // namespace
33 void ShellTestBase::SetUpTestApplications() {
34 // Extract mojo applications, and set the resolve base URL to the directory
35 // containing those.
36 JNIEnv* env = InitEnv();
37 base::android::ScopedJavaLocalRef<jstring> service_dir(
38 Java_ShellTestBase_extractMojoApplications(
39 env, base::android::GetApplicationContext()));
40 shell_context_.url_resolver()->SetMojoBaseURL(
41 mojo::util::FilePathToFileURL(base::FilePath(
42 base::android::ConvertJavaStringToUTF8(env, service_dir.obj()))));
45 } // namespace test
46 } // namespace runner
47 } // namespace mojo