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

Unified Diff: shell/shell_test_base_android.cc

Issue 815993004: Run shell tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add missing file. 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/shell_test_base_android.cc
diff --git a/shell/shell_test_base_android.cc b/shell/shell_test_base_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3509a06c91cfbfb6a5cfd01fe932b8784a584763
--- /dev/null
+++ b/shell/shell_test_base_android.cc
@@ -0,0 +1,45 @@
+// 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.
+
+#include "shell/shell_test_base.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
+#include "jni/ShellTestBase_jni.h"
+#include "shell/filename_util.h"
+#include "url/gurl.h"
+
+namespace mojo {
+namespace shell {
+namespace test {
+
+namespace {
+JNIEnv* InitEnv() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ static bool inited = false;
+ if (!inited) {
+ RegisterNativesImpl(env);
+ inited = true;
+ }
+ return env;
+}
+}
+
+void ShellTestBase::SetUpTestApplications() {
+ // Extract mojo application, and set the resolve base URL to the directory
ppi 2014/12/22 12:02:25 s/application/applications/
qsr 2014/12/22 12:44:20 Done.
+ // containing those.
+ JNIEnv* env = InitEnv();
+ base::android::ScopedJavaLocalRef<jstring> service_dir(
+ Java_ShellTestBase_extractMojoApplication(
+ env, base::android::GetApplicationContext()));
+ shell_context_.mojo_url_resolver()->SetBaseURL(
+ FilePathToFileURL(base::FilePath(
+ base::android::ConvertJavaStringToUTF8(env, service_dir.obj()))));
+}
+
+} // namespace test
+} // namespace shell
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698