43 auto nameLabel = Label::createWithTTF(
"JNI Test",
"fonts/arial.ttf", 28);
47 auto checkLabel = Label::createWithTTF(
"Please check console output",
"fonts/arial.ttf", 22);
51 const std::string classPath =
"org.cocos2dx.cpp_tests.JNITest";
53 JniHelper::callStaticVoidMethod(classPath,
"voidMethod1");
55 JniHelper::callStaticVoidMethod(classPath,
"voidMethod2",
"JNI is easy");
57 JniHelper::callStaticVoidMethod(classPath,
"voidMethod3",
int(4),
float(2.5),
"JNI is really easy");
59 bool b1 = JniHelper::callStaticBooleanMethod(classPath,
"booleanMethod",
int(5));
60 CC_ASSERT(b1 ==
true);
61 bool b2 = JniHelper::callStaticBooleanMethod(classPath,
"booleanMethod",
int(-3));
62 CC_ASSERT(b2 ==
false);
64 int i = JniHelper::callStaticIntMethod(classPath,
"intMethod",
int(10),
int(10));
67 float f = JniHelper::callStaticFloatMethod(classPath,
"floatMethod",
float(2.35),
float(7.65));
70 double d = JniHelper::callStaticDoubleMethod(classPath,
"doubleMethod",
double(2.5),
int(4));
73 std::string str =
"ABCDEF";
74 std::string s1 = JniHelper::callStaticStringMethod(classPath,
"stringMethod", str,
true);
75 CC_ASSERT(s1 ==
"FEDCBA");
76 std::string s2 = JniHelper::callStaticStringMethod(classPath,
"stringMethod", str,
false);
77 CC_ASSERT(s2 ==
"ABCDEF");
79 const char* cstr =
"XYZ";
80 std::string s3 = JniHelper::callStaticStringMethod(classPath,
"stringMethod", cstr,
true);
81 CC_ASSERT(s3 ==
"ZYX");
84 for (
int i = 0; i < 10000; i++) {
85 JniHelper::callStaticVoidMethod(classPath,
"voidMethod4",
"ABCDEF");
static cocos2d::Vec2 top()
static cocos2d::Vec2 center()