Cocos2d-x SDK Integration Guide
-
Upload
trinhtuyen -
Category
Documents
-
view
237 -
download
4
Transcript of Cocos2d-x SDK Integration Guide
Cocos2d-x SDK Integration Guide This guide explains the TestBird UI automated testing Cocos2d-X SDK (aka SDK) integration
process. Cocos2d-x SDK is an essential part of TestBird UI automated testing platform. Its main
function is UI object recognition on the Cocos2d-x platform. In addition, it is also capable of user
behaviour recoding, local playback and cloud playback.
The current SDK version only supports objects that can be recognised by the screen. The
customized data information in the internal storage is not included. TestBird may obtain more
information in the future to meet customers’ needs.
I. SDK Integration Procedure Windows + Eclipse + NDK + Cygwin (environment)
Precondition: Users have already installed NDK, Cocos2d-x, Cygwin and Eclipse environment.
1、Install libzyc Files
Step one: Copy LibZyc.a and paste to the game App (assuming TestCpp) jni directory.
One way of copying is to import. Drag LibZyc.a to jni directory or copy LibZyc.a from Files
Explorer. Right click jni and select paste.
After copy is completed, the UI will look like this:
Step 2: double click jni/Andriod.mk file and add an extra line
LOCAL_LDLIBS += $(LOCAL_PATH)/libzyc.a
See the following image
Step 3: In order to ensure the SDK gets linked each time, an extra line in Build_native.sh file is
needed. For the Link to operate smoothly all the time, it is necessary to delete Libcocos2d.a file.
(Without such action, even when liyzyc.a has been updated, the link will not reload)
2、Import TestBird SDK Package
Step one: Configure the project. Select ‘build path’, then choose ‘Configure Build
Path...’
Step two: Click ‘Java Build Path’ and configure ‘Libraries’. Click ‘Add External Jars’ to
import ‘testbirdsdk.jar’.
Step three: Select‘Order and Export’, choose ‘testbirdsdk.jar’. Click ‘up’ bottom to
locate ‘testbirdsdk.jar’ above source code and gen code.
Step four: Initialise testbirdSdk. Invoke SdkManager.getInstance().init function and enter
the correct forms of appid and channelid. The first argument is appid, channelid second.
i
Step five: Configure permission in AndroidManifest.xml
Below are needed permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
For now, SDK integration is completed. The SDK can be used in Apps.
Note: SDK integration is a one-time operation.
II. SDK Application
1、Initialize SDK (only once needed)
Open JNI entrance (main.cpp), declare to invoke ‘bool InitUiTestSupport()’ when session
begins.
Identify CCScene
1) All UI objects start with CCScene. Therefore, a clear division must be drawn between
different objects. If users adopt CCScene as the universal measurement to identify a
certain scene, the SDK will not be able to distinguish objects from different scenes.
2) CCScene identifier is a character string. As long as different CCScene is guaranteed, the
identifiers can be different. From a testing angle, it is suggested to design the
identifiers as easy to understand as possible. In other words, their functions can be
extracted based on the names.
3) API
bool SetSceneTag(CCNode * pScene, char * pName)
pScene
(3) Set up (API)
Add function prototype in program’s public header:
bool SetSceneTag(CCNode * pScene, char * pName)
pScene CCScene indicator to be set
pName Scene Title
Return value: true and false. The reasons for false are: invalid pScene CCScene object, empty
pNmae or the length of the name is 0.
When creating a Scene object, only one time API invocation is needed. (only invoke on Scene
object, do not need to operate on each UI object)
III. Others The users need to provide the version number of the Cocos2d-x. TestBird will offer SDK
accordingly.
When a user edits the Cocos2d-x platform, as long as the edition does not involve header file, the
user only needs to provide the version number of the Cocos2d-x. If the user edited the content of
the head file, then the edited header file needs to be provided.