PuzzleSDK
JNITest类 参考

#include <JNITest.h>

+ 类 JNITest 继承关系图:
+ JNITest 的协作图:

Public 成员函数

 CREATE_FUNC (JNITest)
 
 JNITest ()
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 JNITest.h35 行定义.

构造及析构函数说明

◆ JNITest()

JNITest::JNITest ( )

在文件 JNITest.cpp41 行定义.

42{
43 auto nameLabel = Label::createWithTTF("JNI Test", "fonts/arial.ttf", 28);
44 nameLabel->setPosition(VisibleRect::center().x, VisibleRect::top().y - 50);
45 addChild(nameLabel);
46
47 auto checkLabel = Label::createWithTTF("Please check console output", "fonts/arial.ttf", 22);
48 checkLabel->setPosition(VisibleRect::center());
49 addChild(checkLabel);
50
51 const std::string classPath = "org.cocos2dx.cpp_tests.JNITest";
52
53 JniHelper::callStaticVoidMethod(classPath, "voidMethod1");
54
55 JniHelper::callStaticVoidMethod(classPath, "voidMethod2", "JNI is easy");
56
57 JniHelper::callStaticVoidMethod(classPath, "voidMethod3", int(4), float(2.5), "JNI is really easy");
58
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);
63
64 int i = JniHelper::callStaticIntMethod(classPath, "intMethod", int(10), int(10));
65 CC_ASSERT(i == 20);
66
67 float f = JniHelper::callStaticFloatMethod(classPath, "floatMethod", float(2.35), float(7.65));
68 CC_ASSERT(f == 10.0);
69
70 double d = JniHelper::callStaticDoubleMethod(classPath, "doubleMethod", double(2.5), int(4));
71 CC_ASSERT(d == 10.0);
72
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");
78
79 const char* cstr = "XYZ";
80 std::string s3 = JniHelper::callStaticStringMethod(classPath, "stringMethod", cstr, true);
81 CC_ASSERT(s3 == "ZYX");
82
83 // should not crash
84 for (int i = 0; i < 10000; i++) {
85 JniHelper::callStaticVoidMethod(classPath, "voidMethod4", "ABCDEF");
86 }
87
88 // should not compile
89 // JniHelper::callStaticVoidMethod(classPath, "voidMethod4", std::vector<int>());
90}
static cocos2d::Vec2 top()
Definition: VisibleRect.cpp:57
static cocos2d::Vec2 center()
Definition: VisibleRect.cpp:69

引用了 VisibleRect::center() , 以及 VisibleRect::top().

+ 函数调用图:

成员函数说明

◆ CREATE_FUNC()

JNITest::CREATE_FUNC ( JNITest  )

该类的文档由以下文件生成: