Commit 04c511fd authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Generate test methods for native java unittests

Uses the JNI generator to generate test methods for native java
unittests that simply call java test methods.

Bug: 783819
Change-Id: I2ff4d87a1aa053847077bd3f418123be49174375
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992247
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729913}
parent 978f1f27
......@@ -3305,6 +3305,7 @@ if (is_android) {
"android/java/src/org/chromium/base/UserDataHost.java",
"android/java/src/org/chromium/base/annotations/AccessedByNative.java",
"android/java/src/org/chromium/base/annotations/CalledByNative.java",
"android/java/src/org/chromium/base/annotations/CalledByNativeJavaTest.java",
"android/java/src/org/chromium/base/annotations/CalledByNativeUnchecked.java",
"android/java/src/org/chromium/base/annotations/CheckDiscard.java",
"android/java/src/org/chromium/base/annotations/DoNotInline.java",
......
// Copyright 2020 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.base.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @CalledByNativeJavaTest is used by the JNI generator to create the necessary JNI
* bindings, expose this method to native code, and generate a native test proxy
* method for this Java Test method.
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.CLASS)
public @interface CalledByNativeJavaTest {
/*
* If present, tells which inner class the method belongs to.
*/
public String value() default "";
}
......@@ -214,6 +214,40 @@ For other objects - use smart pointers to store them:
* `JavaParamRef<>` - Use to accept any of the above as a parameter to a
function without creating a redundant registration.
### Native Java Unittests and @CalledByNativeJavaTest
Native Java Unittests are Java unit tests that run on Android (not on the host
machine). Unlike junit and robolectric, these tests can use the native library,
and real Android APIs. Unlike unit tests in ChromePublicTestApk and similar, the
Activity is not restarted between tests, so the tests run much faster (and you
must be careful not to leave state behind). Example tests may be found in
chrome/android/native_java_unittests/.
The @CalledByNativeJavaTest annotation causes the JNI generator to generate
C++ test methods that simply call out to the Java test methods.
For Example:
```java
class FooTest {
@CalledByNative public FooTest() {}
@CalledByNativeJavaTest public void testFoo() { ... }
@CalledByNativeJavaTest public void testOtherFoo() { ... }
}
```
```c++
class FooTest : public ::testing::Test {
FooTest() : j_test_(Java_FooTest_Constructor(AttachCurrentThread())) {}
const ScopedJavaGlobalRef<jobject>& j_test() { return j_test_; }
private:
ScopedJavaGlobalRef<jobject> j_test_;
}
JAVA_TESTS(AndroidPaymentAppFinderUnitTest, j_test())
```
In some cases you may want to run custom C++ code before running the Java test,
in which case, use CalledByNative instead of CalledByNativeJavaTest and call the
test method yourself. eg. Java_FooTest_testFancyFoo(env, j_test());
### Additional Guidelines / Advice
Minimize the surface API between the two sides. Rather than calling multiple
......
......@@ -262,4 +262,7 @@ JNI_GENERATOR_EXPORT jobjectArray Java_J_N_MPpCU1l5(
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_example_jni_generator_SampleForAnnotationProcessor_JNI
......@@ -280,4 +280,7 @@ JNI_GENERATOR_EXPORT jobjectArray
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_example_jni_generator_SampleForAnnotationProcessor_JNI
......@@ -524,4 +524,7 @@ static base::android::ScopedJavaLocalRef<jobject> Java_SampleForTests_getInnerEn
} // namespace android
} // namespace base
// Step 4: Generated test functions (optional).
#endif // org_chromium_example_jni_generator_SampleForTests_JNI
// 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.
// This file is autogenerated by
// base/android/jni_generator/jni_generator.py
// For
// org/chromium/TestJni
#ifndef org_chromium_TestJni_JNI
#define org_chromium_TestJni_JNI
#include <jni.h>
#include "base/android/jni_generator/jni_generator_helper.h"
// Step 1: Forward declarations.
JNI_REGISTRATION_EXPORT extern const char kClassPath_org_chromium_TestJni[];
const char kClassPath_org_chromium_TestJni[] = "org/chromium/TestJni";
JNI_REGISTRATION_EXPORT extern const char kClassPath_org_chromium_TestJni_00024MyInnerClass[];
const char kClassPath_org_chromium_TestJni_00024MyInnerClass[] =
"org/chromium/TestJni$MyInnerClass";
// Leaking this jclass as we cannot use LazyInstance from some threads.
JNI_REGISTRATION_EXPORT std::atomic<jclass> g_org_chromium_TestJni_clazz(nullptr);
#ifndef org_chromium_TestJni_clazz_defined
#define org_chromium_TestJni_clazz_defined
inline jclass org_chromium_TestJni_clazz(JNIEnv* env) {
return base::android::LazyGetClass(env, kClassPath_org_chromium_TestJni,
&g_org_chromium_TestJni_clazz);
}
#endif
// Leaking this jclass as we cannot use LazyInstance from some threads.
JNI_REGISTRATION_EXPORT std::atomic<jclass> g_org_chromium_TestJni_00024MyInnerClass_clazz(nullptr);
#ifndef org_chromium_TestJni_00024MyInnerClass_clazz_defined
#define org_chromium_TestJni_00024MyInnerClass_clazz_defined
inline jclass org_chromium_TestJni_00024MyInnerClass_clazz(JNIEnv* env) {
return base::android::LazyGetClass(env, kClassPath_org_chromium_TestJni_00024MyInnerClass,
&g_org_chromium_TestJni_00024MyInnerClass_clazz);
}
#endif
// Step 2: Constants (optional).
// Step 3: Method stubs.
static std::atomic<jmethodID> g_org_chromium_TestJni_Constructor(nullptr);
static base::android::ScopedJavaLocalRef<jobject> Java_TestJni_Constructor(JNIEnv* env) {
jclass clazz = org_chromium_TestJni_clazz(env);
CHECK_CLAZZ(env, clazz,
org_chromium_TestJni_clazz(env), NULL);
jni_generator::JniJavaCallContextChecked call_context;
call_context.Init<
base::android::MethodID::TYPE_INSTANCE>(
env,
clazz,
"<init>",
"()V",
&g_org_chromium_TestJni_Constructor);
jobject ret =
env->NewObject(clazz,
call_context.base.method_id);
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
}
static std::atomic<jmethodID> g_org_chromium_TestJni_testFoo(nullptr);
static jint Java_TestJni_testFoo(JNIEnv* env, const base::android::JavaRef<jobject>& obj) {
jclass clazz = org_chromium_TestJni_clazz(env);
CHECK_CLAZZ(env, obj.obj(),
org_chromium_TestJni_clazz(env), 0);
jni_generator::JniJavaCallContextChecked call_context;
call_context.Init<
base::android::MethodID::TYPE_INSTANCE>(
env,
clazz,
"testFoo",
"()I",
&g_org_chromium_TestJni_testFoo);
jint ret =
env->CallIntMethod(obj.obj(),
call_context.base.method_id);
return ret;
}
static std::atomic<jmethodID> g_org_chromium_TestJni_testOtherFoo(nullptr);
static void Java_TestJni_testOtherFoo(JNIEnv* env, const base::android::JavaRef<jobject>& obj) {
jclass clazz = org_chromium_TestJni_clazz(env);
CHECK_CLAZZ(env, obj.obj(),
org_chromium_TestJni_clazz(env));
jni_generator::JniJavaCallContextChecked call_context;
call_context.Init<
base::android::MethodID::TYPE_INSTANCE>(
env,
clazz,
"testOtherFoo",
"()V",
&g_org_chromium_TestJni_testOtherFoo);
env->CallVoidMethod(obj.obj(),
call_context.base.method_id);
}
static std::atomic<jmethodID> g_org_chromium_TestJni_00024MyInnerClass_testInnerFoo(nullptr);
static void Java_MyInnerClass_testInnerFoo(JNIEnv* env, const base::android::JavaRef<jobject>& obj)
{
jclass clazz = org_chromium_TestJni_00024MyInnerClass_clazz(env);
CHECK_CLAZZ(env, obj.obj(),
org_chromium_TestJni_00024MyInnerClass_clazz(env));
jni_generator::JniJavaCallContextChecked call_context;
call_context.Init<
base::android::MethodID::TYPE_INSTANCE>(
env,
clazz,
"testInnerFoo",
"()V",
&g_org_chromium_TestJni_00024MyInnerClass_testInnerFoo);
env->CallVoidMethod(obj.obj(),
call_context.base.method_id);
}
// Step 4: Generated test functions (optional).
#define JAVA_TESTS(test_fixture, java_test_object)\
TEST_F(test_fixture, TestFoo) { \
JNIEnv* env = base::android::AttachCurrentThread(); \
Java_TestJni_testFoo(\
env, java_test_object); \
}\
TEST_F(test_fixture, TestOtherFoo) { \
JNIEnv* env = base::android::AttachCurrentThread(); \
Java_TestJni_testOtherFoo(\
env, java_test_object); \
}\
TEST_F(test_fixture, TestInnerFoo) { \
JNIEnv* env = base::android::AttachCurrentThread(); \
Java_MyInnerClass_testInnerFoo(\
env, java_test_object); \
}
#endif // org_chromium_TestJni_JNI
......@@ -475,4 +475,7 @@ static base::android::ScopedJavaLocalRef<jobject> Java_TestJni_getCompressFormat
return base::android::ScopedJavaLocalRef<jobject>(env, ret);
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -2317,4 +2317,7 @@ static void Java_MotionEvent_writeToParcel(JNIEnv* env, const base::android::Jav
} // namespace JNI_MotionEvent
// Step 4: Generated test functions (optional).
#endif // android_view_MotionEvent_JNI
......@@ -273,4 +273,7 @@ static base::android::ScopedJavaLocalRef<jobject> Java_InputStream_Constructor(J
} // namespace JNI_InputStream
// Step 4: Generated test functions (optional).
#endif // java_io_InputStream_JNI
......@@ -84,4 +84,7 @@ static base::android::ScopedJavaLocalRef<jclass> Java_HashSet_getClass(JNIEnv* e
} // namespace JNI_HashSet
// Step 4: Generated test functions (optional).
#endif // java_util_HashSet_JNI
......@@ -57,4 +57,7 @@ JNI_GENERATOR_EXPORT jint Java_org_chromium_TestJni_00024MyInnerClass_nativeInit
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -67,4 +67,7 @@ JNI_GENERATOR_EXPORT jint Java_org_chromium_TestJni_00024MyOtherInnerClass_nativ
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -80,4 +80,7 @@ JNI_GENERATOR_EXPORT jint Java_org_chromium_TestJni_00024MyOtherInnerClass_nativ
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -68,4 +68,7 @@ static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRef<jo
call_context.base.method_id, callback1.obj(), callback2.obj());
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_foo_Foo_JNI
......@@ -226,4 +226,7 @@ static base::android::ScopedJavaLocalRef<jstring>
return base::android::ScopedJavaLocalRef<jstring>(env, ret);
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_example_jni_generator_SampleForTests_JNI
......@@ -213,4 +213,7 @@ JNI_GENERATOR_EXPORT jthrowable Java_org_chromium_TestJni_nativeMessWithJavaExce
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -46,4 +46,7 @@ JNI_GENERATOR_EXPORT void Java_org_chromium_TestJni_nativeDestroy(
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_TestJni_JNI
......@@ -60,4 +60,7 @@ JNI_GENERATOR_EXPORT jstring
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_example_SampleProxyJni_JNI
......@@ -114,4 +114,7 @@ JNI_GENERATOR_EXPORT void Java_org_chromium_base_natives_GEN_1JNI_org_1chromium_
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_foo_Foo_JNI
......@@ -46,4 +46,7 @@ JNI_GENERATOR_EXPORT void Java_foo_bar_nativeSyncSetupEnded(
}
// Step 4: Generated test functions (optional).
#endif // foo_bar_JNI
......@@ -64,4 +64,7 @@ static void Java_Foo_calledByNative(JNIEnv* env, const base::android::JavaRef<jo
call_context.base.method_id, callback.obj());
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_foo_Foo_JNI
......@@ -97,4 +97,7 @@ JNI_GENERATOR_EXPORT void Java_org_chromium_foo_Foo_nativeCallWithQualifiedObjec
}
// Step 4: Generated test functions (optional).
#endif // org_chromium_foo_Foo_JNI
......@@ -103,4 +103,7 @@ static void Java_Foo_callbackFromNative(JNIEnv* env, const base::android::JavaRe
} // namespace chromium_foo
} // namespace org
// Step 4: Generated test functions (optional).
#endif // org_chromium_foo_Foo_JNI
......@@ -173,6 +173,7 @@ class CalledByNative(object):
self.env_call = GetEnvCall(self.is_constructor, self.static,
self.return_type)
self.static_cast = GetStaticCastForReturnType(self.return_type)
self.gen_test_method = kwargs.get('gen_test_method', False)
class ConstantField(object):
......@@ -670,7 +671,8 @@ RE_SCOPED_JNI_TYPES = re.compile('jobject|jclass|jstring|jthrowable|.*Array')
# Regex to match a string like "@CalledByNative public void foo(int bar)".
RE_CALLED_BY_NATIVE = re.compile(
r'@CalledByNative(?P<Unchecked>(?:Unchecked)?)(?:\("(?P<annotation>.*)"\))?'
r'@CalledByNative(?P<Unchecked>(?:Unchecked)?)(?P<JavaTest>(?:JavaTest)?)'
r'(?:\("(?P<annotation>.*)"\))?'
r'(?:\s+@\w+(?:\(.*\))?)*' # Ignore any other annotations.
r'\s+(?P<prefix>('
r'(private|protected|public|static|abstract|final|default|synchronized)'
......@@ -721,7 +723,8 @@ def ExtractCalledByNatives(jni_params, contents, always_mangle):
return_type=return_type,
name=name,
is_constructor=is_constructor,
params=JniParams.Parse(match.group('params')))
params=JniParams.Parse(match.group('params')),
gen_test_method='JavaTest' in match.group('JavaTest'))
]
# Check for any @CalledByNative occurrences that weren't matched.
unmatched_lines = re.sub(RE_CALLED_BY_NATIVE, '', contents).split('\n')
......@@ -1122,6 +1125,9 @@ $CONSTANT_FIELDS\
// Step 3: Method stubs.
$METHOD_STUBS
// Step 4: Generated test functions (optional).
$TEST_METHODS
#endif // ${HEADER_GUARD}
""")
values = {
......@@ -1132,6 +1138,7 @@ $METHOD_STUBS
'METHOD_STUBS': self.GetMethodStubsString(),
'HEADER_GUARD': self.header_guard,
'INCLUDES': self.GetIncludesString(),
'TEST_METHODS': self.GetTestMethodsString(),
}
open_namespace = self.GetOpenNamespaceString()
if open_namespace:
......@@ -1174,6 +1181,17 @@ $METHOD_STUBS
for called_by_native in self.called_by_natives
]
def GetTestMethodsString(self):
strings = []
for called_by_native in self.called_by_natives:
if not called_by_native.gen_test_method:
continue
strings += [self.GetTestMethodString(called_by_native)]
if strings:
strings.insert(0, "#define JAVA_TESTS(test_fixture, java_test_object)\\")
ret = '\n'.join(strings)
return ret[:-1] # Drop trailing '\'.
def GetIncludesString(self):
if not self.options.includes:
return ''
......@@ -1454,6 +1472,20 @@ ${PROFILING_LEAVING_NATIVE}\
values['TRACE_EVENT'] = ''
return RemoveIndentedEmptyLines(template.substitute(values))
def GetTestMethodString(self, called_by_native):
method_template = Template("""\
TEST_F(test_fixture, ${METHOD_ID_VAR_NAME_UPPERCASE}) { \\
JNIEnv* env = base::android::AttachCurrentThread(); \\
Java_${JAVA_CLASS_ONLY}_${METHOD_ID_VAR_NAME}(\\
env, java_test_object); \\
}\\""")
values = self.GetCalledByNativeValues(called_by_native)
method_name = values['METHOD_ID_VAR_NAME']
values['METHOD_ID_VAR_NAME_UPPERCASE'] = method_name[0].upper(
) + method_name[1:]
return RemoveIndentedEmptyLines(method_template.substitute(values))
def GetTraceEventForNameTemplate(self, name_template, values):
name = Template(name_template).substitute(values)
return ' TRACE_EVENT0("jni", "%s");\n' % name
......
......@@ -814,6 +814,85 @@ scooby doo
except jni_generator.ParseError as e:
self.assertEqual(('@CalledByNative', 'scooby doo'), e.context_lines)
def testCalledByNativeJavaTest(self):
test_data = """
class MyOuterClass {
@CalledByNative
public MyOuterClass() {}
@CalledByNativeJavaTest
public int testFoo() {}
@CalledByNativeJavaTest
public void testOtherFoo() {}
class MyInnerClass {
@CalledByNativeJavaTest("MyInnerClass")
public void testInnerFoo() {}
}
}
"""
jni_params = jni_generator.JniParams('org/chromium/Foo')
jni_params.ExtractImportsAndInnerClasses(test_data)
called_by_natives = jni_generator.ExtractCalledByNatives(
jni_params, test_data, always_mangle=False)
golden_called_by_natives = [
CalledByNative(
return_type='MyOuterClass',
system_class=False,
static=False,
name='Constructor',
method_id_var_name='Constructor',
java_class_name='',
params=[],
env_call=('Void', ''),
unchecked=False,
gen_test_method=False,
is_constructor=True,
),
CalledByNative(
return_type='int',
system_class=False,
static=False,
name='testFoo',
method_id_var_name='testFoo',
java_class_name='',
params=[],
env_call=('Void', ''),
unchecked=False,
gen_test_method=True,
),
CalledByNative(
return_type='void',
system_class=False,
static=False,
name='testOtherFoo',
method_id_var_name='testOtherFoo',
java_class_name='',
params=[],
env_call=('Void', ''),
unchecked=False,
gen_test_method=True,
),
CalledByNative(
return_type='void',
system_class=False,
static=False,
name='testInnerFoo',
method_id_var_name='testInnerFoo',
java_class_name='MyInnerClass',
params=[],
env_call=('Void', ''),
unchecked=False,
gen_test_method=True,
)
]
self.AssertListEquals(golden_called_by_natives, called_by_natives)
h = jni_generator.InlHeaderFileGenerator('', 'org/chromium/TestJni', [],
called_by_natives, [], jni_params,
TestOptions())
self.AssertGoldenTextEquals(h.GetContent())
def testFullyQualifiedClassName(self):
contents = """
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
......
......@@ -17,6 +17,7 @@ import org.mockito.MockitoAnnotations;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.CalledByNativeJavaTest;
import org.chromium.blink_public.common.ContextMenuDataMediaType;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
......@@ -50,10 +51,6 @@ public class ChromeContextMenuPopulatorTest {
private ChromeContextMenuPopulator mPopulator;
@CalledByNative
public static ChromeContextMenuPopulatorTest create() {
return new ChromeContextMenuPopulatorTest();
}
private ChromeContextMenuPopulatorTest() {}
@CalledByNative
......@@ -109,7 +106,7 @@ public class ChromeContextMenuPopulatorTest {
}
}
@CalledByNative
@CalledByNativeJavaTest
public void testHttpLink() {
FirstRunStatus.setFirstRunFlowComplete(false);
ContextMenuParams contextMenuParams = new ContextMenuParams(0, PAGE_URL, LINK_URL,
......@@ -146,7 +143,7 @@ public class ChromeContextMenuPopulatorTest {
checkMenuOptions(contextMenuParams, expected4);
}
@CalledByNative
@CalledByNativeJavaTest
public void testMailLink() {
FirstRunStatus.setFirstRunFlowComplete(false);
ContextMenuParams contextMenuParams =
......@@ -182,7 +179,7 @@ public class ChromeContextMenuPopulatorTest {
checkMenuOptions(contextMenuParams, expected4);
}
@CalledByNative
@CalledByNativeJavaTest
public void testTelLink() {
FirstRunStatus.setFirstRunFlowComplete(false);
ContextMenuParams contextMenuParams =
......@@ -219,7 +216,7 @@ public class ChromeContextMenuPopulatorTest {
checkMenuOptions(contextMenuParams, expected4);
}
@CalledByNative
@CalledByNativeJavaTest
public void testVideoLink() {
FirstRunStatus.setFirstRunFlowComplete(false);
String sourceUrl = "http://www.blah.com/";
......@@ -260,7 +257,7 @@ public class ChromeContextMenuPopulatorTest {
checkMenuOptions(contextMenuParams, expected4Tab1, expected4Tab2);
}
@CalledByNative
@CalledByNativeJavaTest
public void testImageHiFi() {
FirstRunStatus.setFirstRunFlowComplete(false);
ContextMenuParams contextMenuParams = new ContextMenuParams(ContextMenuDataMediaType.IMAGE,
......@@ -294,7 +291,7 @@ public class ChromeContextMenuPopulatorTest {
checkMenuOptions(contextMenuParams, expected4);
}
@CalledByNative
@CalledByNativeJavaTest
public void testHttpLinkWithImageHiFi() {
FirstRunStatus.setFirstRunFlowComplete(false);
ContextMenuParams contextMenuParams = new ContextMenuParams(ContextMenuDataMediaType.IMAGE,
......
......@@ -10,14 +10,12 @@ using base::android::AttachCurrentThread;
class ChromeContextMenuPopulatorTest : public ::testing::Test {
public:
ChromeContextMenuPopulatorTest() {
JNIEnv* env = AttachCurrentThread();
j_test_.Reset(Java_ChromeContextMenuPopulatorTest_create(env));
}
ChromeContextMenuPopulatorTest()
: j_test_(Java_ChromeContextMenuPopulatorTest_Constructor(
AttachCurrentThread())) {}
void SetUp() override {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_setUp(env, j_test_);
Java_ChromeContextMenuPopulatorTest_setUp(AttachCurrentThread(), j_test_);
}
const base::android::ScopedJavaGlobalRef<jobject>& j_test() {
......@@ -28,32 +26,4 @@ class ChromeContextMenuPopulatorTest : public ::testing::Test {
base::android::ScopedJavaGlobalRef<jobject> j_test_;
};
TEST_F(ChromeContextMenuPopulatorTest, TestHttpLink) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testHttpLink(env, j_test());
}
TEST_F(ChromeContextMenuPopulatorTest, TestMailLink) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testMailLink(env, j_test());
}
TEST_F(ChromeContextMenuPopulatorTest, TestTelLink) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testTelLink(env, j_test());
}
TEST_F(ChromeContextMenuPopulatorTest, TestVideoLink) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testVideoLink(env, j_test());
}
TEST_F(ChromeContextMenuPopulatorTest, TestImageHiFi) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testImageHiFi(env, j_test());
}
TEST_F(ChromeContextMenuPopulatorTest, TestHttpLinkWithImageHiFi) {
JNIEnv* env = AttachCurrentThread();
Java_ChromeContextMenuPopulatorTest_testHttpLinkWithImageHiFi(env, j_test());
}
JAVA_TESTS(ChromeContextMenuPopulatorTest, j_test())
......@@ -10,14 +10,12 @@ using base::android::AttachCurrentThread;
class InstalledAppProviderTest : public ::testing::Test {
public:
InstalledAppProviderTest() {
JNIEnv* env = AttachCurrentThread();
j_test_.Reset(Java_InstalledAppProviderTest_create(env));
}
InstalledAppProviderTest()
: j_test_(
Java_InstalledAppProviderTest_Constructor(AttachCurrentThread())) {}
void SetUp() override {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_setUp(env, j_test_);
Java_InstalledAppProviderTest_setUp(AttachCurrentThread(), j_test_);
}
const base::android::ScopedJavaGlobalRef<jobject>& j_test() {
......@@ -28,169 +26,4 @@ class InstalledAppProviderTest : public ::testing::Test {
base::android::ScopedJavaGlobalRef<jobject> j_test_;
};
TEST_F(InstalledAppProviderTest, TestOriginMissingParts) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOriginMissingParts(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestIncognitoWithOneInstalledRelatedApp) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testIncognitoWithOneInstalledRelatedApp(
env, j_test());
}
TEST_F(InstalledAppProviderTest, TestNoRelatedApps) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testNoRelatedApps(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneRelatedAppNoId) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppNoId(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneRelatedNonAndroidApp) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedNonAndroidApp(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneRelatedAppNotInstalled) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppNotInstalled(env, j_test());
}
TEST_F(InstalledAppProviderTest,
TestOneRelatedAppBrokenAssetStatementsResource) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppBrokenAssetStatementsResource(
env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneRelatedAppNoAssetStatements) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppNoAssetStatements(env,
j_test());
}
TEST_F(InstalledAppProviderTest,
TestOneRelatedAppNoAssetStatementsNullMetadata) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppNoAssetStatementsNullMetadata(
env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneRelatedAppRelatedToDifferentOrigins) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneRelatedAppRelatedToDifferentOrigins(
env, j_test());
}
TEST_F(InstalledAppProviderTest, TestOneInstalledRelatedApp) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testOneInstalledRelatedApp(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestDynamicallyChangingUrl) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testDynamicallyChangingUrl(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestInstalledRelatedAppWithUrl) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testInstalledRelatedAppWithUrl(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestMultipleAssetStatements) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testMultipleAssetStatements(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementSyntaxError) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementSyntaxError(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNotArray) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNotArray(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementArrayNoObjects) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementArrayNoObjects(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNoRelation) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNoRelation(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNonStandardRelation) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNonStandardRelation(env,
j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNoTarget) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNoTarget(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNoNamespace) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNoNamespace(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestNonWebAssetStatement) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testNonWebAssetStatement(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementNoSite) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementNoSite(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementSiteSyntaxError) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementSiteSyntaxError(env,
j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementSiteMissingParts) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementSiteMissingParts(env,
j_test());
}
TEST_F(InstalledAppProviderTest, TestAssetStatementSiteHasPath) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testAssetStatementSiteHasPath(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestExtraInstalledApp) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testExtraInstalledApp(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestMultipleInstalledRelatedApps) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testMultipleInstalledRelatedApps(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestArtificialDelay) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testArtificialDelay(env, j_test());
}
TEST_F(InstalledAppProviderTest, TestMultipleAppsIncludingInstantApps) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testMultipleAppsIncludingInstantApps(env,
j_test());
}
TEST_F(InstalledAppProviderTest, TestRelatedAppsOverAllowedThreshold) {
JNIEnv* env = AttachCurrentThread();
Java_InstalledAppProviderTest_testRelatedAppsOverAllowedThreshold(env,
j_test());
}
JAVA_TESTS(InstalledAppProviderTest, j_test())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment