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

Unified Diff: base/android/jni_generator/jni_generator_tests.py

Issue 15715006: Android: allow JNI generator to be used with jarjar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change gyp variable to a pathname. Created 7 years, 7 months 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
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | build/jni_generator.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_generator/jni_generator_tests.py
diff --git a/base/android/jni_generator/jni_generator_tests.py b/base/android/jni_generator/jni_generator_tests.py
index f6dd3c97dae634f26b79edde01729b6731ce0f3f..f008f394cec95c87d4c6ab5df9ecd036f09504ab 100755
--- a/base/android/jni_generator/jni_generator_tests.py
+++ b/base/android/jni_generator/jni_generator_tests.py
@@ -1937,6 +1937,85 @@ static bool RegisterNativesImpl(JNIEnv* env) {
self.assertTrue(len(line) > 80,
('Expected #ifndef line to be > 80 chars: ', line))
+ def testJarJarRemapping(self):
+ test_data = """
+ package org.chromium.example.jni_generator;
+
+ import org.chromium.example2.Test;
+
+ class Example {
+ private static native void nativeTest(Test t);
+ }
+ """
+ jni_generator.JniParams.SetJarJarMappings(
+ """rule org.chromium.example.** com.test.@1
+ rule org.chromium.example2.** org.test2.@0""")
+ jni_from_java = jni_generator.JNIFromJavaSource(
+ test_data, 'org/chromium/example/jni_generator/Example')
+ jni_generator.JniParams.SetJarJarMappings('')
+ golden_content = """\
+// Copyright (c) 2012 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.
+
+// This file is autogenerated by
+// base/android/jni_generator/jni_generator_tests.py
+// For
+// org/chromium/example/jni_generator/Example
+
+#ifndef org_chromium_example_jni_generator_Example_JNI
+#define org_chromium_example_jni_generator_Example_JNI
+
+#include <jni.h>
+
+#include "base/android/jni_android.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/basictypes.h"
+#include "base/logging.h"
+
+using base::android::ScopedJavaLocalRef;
+
+// Step 1: forward declarations.
+namespace {
+const char kExampleClassPath[] = "com/test/jni_generator/Example";
+// Leaking this jclass as we cannot use LazyInstance from some threads.
+jclass g_Example_clazz = NULL;
+} // namespace
+
+static void Test(JNIEnv* env, jclass clazz,
+ jobject t);
+
+// Step 2: method stubs.
+
+// Step 3: RegisterNatives.
+
+static bool RegisterNativesImpl(JNIEnv* env) {
+
+ g_Example_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
+ base::android::GetClass(env, kExampleClassPath).obj()));
+ static const JNINativeMethod kMethodsExample[] = {
+ { "nativeTest",
+"("
+"Lorg/test2/org/chromium/example2/Test;"
+")"
+"V", reinterpret_cast<void*>(Test) },
+ };
+ const int kMethodsExampleSize = arraysize(kMethodsExample);
+
+ if (env->RegisterNatives(g_Example_clazz,
+ kMethodsExample,
+ kMethodsExampleSize) < 0) {
+ LOG(ERROR) << "RegisterNatives failed in " << __FILE__;
+ return false;
+ }
+
+ return true;
+}
+
+#endif // org_chromium_example_jni_generator_Example_JNI
+"""
+ self.assertTextEquals(golden_content, jni_from_java.GetContent())
+
def testImports(self):
import_header = """
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
« no previous file with comments | « base/android/jni_generator/jni_generator.py ('k') | build/jni_generator.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698