Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into cocos-console-test

This commit is contained in:
shujunqiao 2014-03-21 17:51:06 +08:00
commit e521632b55
22 changed files with 320 additions and 174 deletions

View File

@ -780,6 +780,12 @@ Developers:
huangml
Fixed a bug that Node::removeAllChildrenWithCleanup() does not remove PhysicsBody.
newnon
Adds getCurrentLanguageCode() which returns iso 639-1 language code
youknowone
Adds iOS-like elastic bounceback support for cocos2d::extension::ScrollView
Retired Core Developers:
WenSheng Yang

View File

@ -1 +1 @@
a0b9515cdcf5051f65f3a3efe3a0c35ab0769c69
e1d0a713b9c239ae437f21ab7c256413cebf3241

View File

@ -100,6 +100,14 @@ public:
*/
virtual LanguageType getCurrentLanguage() = 0;
/**
@brief Get current language iso 639-1 code
@return Current language iso 639-1 code
* @js NA
* @lua NA
*/
virtual const char * getCurrentLanguageCode() = 0;
/**
@brief Get target platform
* @js NA

View File

@ -86,6 +86,14 @@ Application* Application::sharedApplication()
return Application::getInstance();
}
const char * Application::getCurrentLanguageCode()
{
static char code[3]={0};
strncpy(code,getCurrentLanguageJNI().c_str(),2);
code[2]='\0';
return code;
}
LanguageType Application::getCurrentLanguage()
{
std::string languageName = getCurrentLanguageJNI();

View File

@ -73,6 +73,12 @@ public:
*/
virtual LanguageType getCurrentLanguage();
/**
@brief Get current language iso 639-1 code
@return Current language iso 639-1 code
*/
virtual const char * getCurrentLanguageCode();
/**
@brief Get target platform
*/

View File

@ -75,6 +75,12 @@ public:
*/
virtual LanguageType getCurrentLanguage();
/**
@brief Get current language iso 639-1 code
@return Current language iso 639-1 code
*/
virtual const char * getCurrentLanguageCode();
/**
@brief Get target platform
*/

View File

@ -78,6 +78,21 @@ Application* Application::sharedApplication()
return Application::getInstance();
}
const char * Application::getCurrentLanguageCode()
{
static char code[3]={0};
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
// get the current language code.(such as English is "en", Chinese is "zh" and so on)
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
[languageCode getCString:code maxLength:2 encoding:NSASCIIStringEncoding];
code[2]='\0';
return code;
}
LanguageType Application::getCurrentLanguage()
{
// get the current language and country config

View File

@ -151,6 +151,20 @@ Application* Application::sharedApplication()
return Application::getInstance();
}
const char * Application::getCurrentLanguageCode()
{
static char code[3]={0};
char *pLanguageName = getenv("LANG");
if (!pLanguageName)
return "en";
strtok(pLanguageName, "_");
if (!pLanguageName)
return "en";
strncpy(code,pLanguageName,2);
code[2]='\0';
return code;
}
LanguageType Application::getCurrentLanguage()
{
char *pLanguageName = getenv("LANG");

View File

@ -72,6 +72,13 @@ public:
/* override functions */
virtual LanguageType getCurrentLanguage();
/**
@brief Get current language iso 639-1 code
@return Current language iso 639-1 code
*/
virtual const char * getCurrentLanguageCode();
/**
* Sets the Resource root path.
* @deprecated Please use FileUtils::getInstance()->setSearchPaths() instead.

View File

@ -80,6 +80,12 @@ public:
*/
virtual LanguageType getCurrentLanguage();
/**
@brief Get current language iso 639-1 code
@return Current language iso 639-1 code
*/
virtual const char * getCurrentLanguageCode();
/**
@brief Get target platform
*/

View File

@ -134,6 +134,21 @@ Application* Application::sharedApplication()
return Application::getInstance();
}
const char * Application::getCurrentLanguageCode()
{
static char code[3]={0};
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
// get the current language code.(such as English is "en", Chinese is "zh" and so on)
NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage];
NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode];
[languageCode getCString:code maxLength:2 encoding:NSASCIIStringEncoding];
code[2]='\0';
return code;
}
LanguageType Application::getCurrentLanguage()
{
// get the current language and country config

View File

@ -190,6 +190,16 @@ LanguageType Application::getCurrentLanguage()
return ret;
}
const char * Application::getCurrentLanguageCode()
{
LANGID lid = GetUserDefaultUILanguage();
const LCID locale_id = MAKELCID(lid, SORT_DEFAULT);
static char code[3] = { 0 };
GetLocaleInfoA(locale_id, LOCALE_SISO639LANGNAME, code, sizeof(code));
code[2] = '\0';
return code;
}
Application::Platform Application::getTargetPlatform()
{
return Platform::OS_WINDOWS;

View File

@ -67,6 +67,8 @@ public:
/* override functions */
virtual void setAnimationInterval(double interval);
virtual LanguageType getCurrentLanguage();
virtual const char * getCurrentLanguageCode();
/**
@brief Get target platform

View File

@ -354,7 +354,6 @@ void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Point& point1,
}
}
void PhysicsWorld::queryRect(PhysicsQueryRectCallbackFunc func, const Rect& rect, void* data)
{
CCASSERT(func != nullptr, "func shouldn't be nullptr");
@ -418,134 +417,6 @@ PhysicsShape* PhysicsWorld::getShape(const Point& point) const
return shape == nullptr ? nullptr : PhysicsShapeInfo::getMap().find(shape)->second->getShape();
}
void PhysicsDebugDraw::drawShape(PhysicsShape& shape)
{
for (auto it = shape._info->getShapes().begin(); it != shape._info->getShapes().end(); ++it)
{
cpShape *subShape = *it;
switch ((*it)->klass_private->type)
{
case CP_CIRCLE_SHAPE:
{
float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(subShape));
Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape)))
+ PhysicsHelper::cpv2point(cpCircleShapeGetOffset(subShape));
static const int CIRCLE_SEG_NUM = 12;
Point seg[CIRCLE_SEG_NUM] = {};
for (int i = 0; i < CIRCLE_SEG_NUM; ++i)
{
float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f;
Point d(radius * cosf(angle), radius * sinf(angle));
seg[i] = centre + d;
}
_drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1, Color4F(1, 0, 0, 1));
break;
}
case CP_SEGMENT_SHAPE:
{
cpSegmentShape *seg = (cpSegmentShape *)subShape;
_drawNode->drawSegment(PhysicsHelper::cpv2point(seg->ta),
PhysicsHelper::cpv2point(seg->tb),
PhysicsHelper::cpfloat2float(seg->r==0 ? 1 : seg->r), Color4F(1, 0, 0, 1));
break;
}
case CP_POLY_SHAPE:
{
cpPolyShape* poly = (cpPolyShape*)subShape;
int num = poly->numVerts;
Point* seg = new Point[num];
PhysicsHelper::cpvs2points(poly->tVerts, seg, num);
_drawNode->drawPolygon(seg, num, Color4F(1.0f, 0.0f, 0.0f, 0.3f), 1.0f, Color4F(1.0f, 0.0f, 0.0f, 1.0f));
delete[] seg;
break;
}
default:
break;
}
}
}
void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint)
{
for (auto it = joint._info->getJoints().begin(); it != joint._info->getJoints().end(); ++it)
{
cpConstraint *constraint = *it;
cpBody *body_a = constraint->a;
cpBody *body_b = constraint->b;
const cpConstraintClass *klass = constraint->klass_private;
if(klass == cpPinJointGetClass())
{
cpPinJoint *subJoint = (cpPinJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
}
else if(klass == cpSlideJointGetClass())
{
cpSlideJoint *subJoint = (cpSlideJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
}
else if(klass == cpPivotJointGetClass())
{
cpPivotJoint *subJoint = (cpPivotJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
}
else if(klass == cpGrooveJointGetClass())
{
cpGrooveJoint *subJoint = (cpGrooveJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->grv_a, body_a->rot));
cpVect b = cpvadd(body_a->p, cpvrotate(subJoint->grv_b, body_a->rot));
cpVect c = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(c), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
}
else if(klass == cpDampedSpringGetClass())
{
cpDampedSpring *subJoint = (cpDampedSpring *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, Color4F(0.0f, 0.0f, 1.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, Color4F(0.0f, 1.0f, 0.0f, 1.0f));
}
}
}
void PhysicsDebugDraw::drawContact()
{
}
PhysicsWorld* PhysicsWorld::construct(Scene& scene)
{
PhysicsWorld * world = new PhysicsWorld();
@ -1062,34 +933,19 @@ PhysicsDebugDraw::PhysicsDebugDraw(PhysicsWorld& world)
: _drawNode(nullptr)
, _world(world)
{
_drawNode = DrawNode::create();
_world.getScene().addChild(_drawNode);
}
PhysicsDebugDraw::~PhysicsDebugDraw()
{
if (_drawNode != nullptr)
{
_drawNode->removeFromParent();
_drawNode = nullptr;
}
_drawNode->removeFromParent();
_drawNode = nullptr;
}
bool PhysicsDebugDraw::begin()
{
if (_drawNode != nullptr)
{
_drawNode->removeFromParent();
_drawNode = nullptr;
}
_drawNode = DrawNode::create();
if (_drawNode == nullptr)
{
return false;
}
_world.getScene().addChild(_drawNode);
_drawNode->clear();
return true;
}
@ -1097,6 +953,138 @@ void PhysicsDebugDraw::end()
{
}
void PhysicsDebugDraw::drawShape(PhysicsShape& shape)
{
const Color4F fillColor(1.0f, 0.0f, 0.0f, 0.3f);
const Color4F outlineColor(1.0f, 0.0f, 0.0f, 1.0f);
for (auto it = shape._info->getShapes().begin(); it != shape._info->getShapes().end(); ++it)
{
cpShape *subShape = *it;
switch ((*it)->klass_private->type)
{
case CP_CIRCLE_SHAPE:
{
float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(subShape));
Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(subShape)))
+ PhysicsHelper::cpv2point(cpCircleShapeGetOffset(subShape));
static const int CIRCLE_SEG_NUM = 12;
Point seg[CIRCLE_SEG_NUM] = {};
for (int i = 0; i < CIRCLE_SEG_NUM; ++i)
{
float angle = (float)i * M_PI / (float)CIRCLE_SEG_NUM * 2.0f;
Point d(radius * cosf(angle), radius * sinf(angle));
seg[i] = centre + d;
}
_drawNode->drawPolygon(seg, CIRCLE_SEG_NUM, fillColor, 1, outlineColor);
break;
}
case CP_SEGMENT_SHAPE:
{
cpSegmentShape *seg = (cpSegmentShape *)subShape;
_drawNode->drawSegment(PhysicsHelper::cpv2point(seg->ta),
PhysicsHelper::cpv2point(seg->tb),
PhysicsHelper::cpfloat2float(seg->r==0 ? 1 : seg->r), outlineColor);
break;
}
case CP_POLY_SHAPE:
{
cpPolyShape* poly = (cpPolyShape*)subShape;
int num = poly->numVerts;
Point* seg = new Point[num];
PhysicsHelper::cpvs2points(poly->tVerts, seg, num);
_drawNode->drawPolygon(seg, num, fillColor, 1.0f, outlineColor);
delete[] seg;
break;
}
default:
break;
}
}
}
void PhysicsDebugDraw::drawJoint(PhysicsJoint& joint)
{
const Color4F lineColor(0.0f, 0.0f, 1.0f, 1.0f);
const Color4F jointPointColor(0.0f, 1.0f, 0.0f, 1.0f);
for (auto it = joint._info->getJoints().begin(); it != joint._info->getJoints().end(); ++it)
{
cpConstraint *constraint = *it;
cpBody *body_a = constraint->a;
cpBody *body_b = constraint->b;
const cpConstraintClass *klass = constraint->klass_private;
if(klass == cpPinJointGetClass())
{
cpPinJoint *subJoint = (cpPinJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, lineColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, jointPointColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, jointPointColor);
}
else if(klass == cpSlideJointGetClass())
{
cpSlideJoint *subJoint = (cpSlideJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, lineColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, jointPointColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, jointPointColor);
}
else if(klass == cpPivotJointGetClass())
{
cpPivotJoint *subJoint = (cpPivotJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, jointPointColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, jointPointColor);
}
else if(klass == cpGrooveJointGetClass())
{
cpGrooveJoint *subJoint = (cpGrooveJoint *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->grv_a, body_a->rot));
cpVect b = cpvadd(body_a->p, cpvrotate(subJoint->grv_b, body_a->rot));
cpVect c = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, lineColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(c), 2, jointPointColor);
}
else if(klass == cpDampedSpringGetClass())
{
cpDampedSpring *subJoint = (cpDampedSpring *)constraint;
cpVect a = cpvadd(body_a->p, cpvrotate(subJoint->anchr1, body_a->rot));
cpVect b = cpvadd(body_b->p, cpvrotate(subJoint->anchr2, body_b->rot));
_drawNode->drawSegment(PhysicsHelper::cpv2point(a), PhysicsHelper::cpv2point(b), 1, lineColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(a), 2, jointPointColor);
_drawNode->drawDot(PhysicsHelper::cpv2point(b), 2, jointPointColor);
}
}
}
void PhysicsDebugDraw::drawContact()
{
}
NS_CC_END
#endif // CC_USE_PHYSICS

View File

@ -8,15 +8,20 @@
-- @return ApplicationProtocol::Platform#ApplicationProtocol::Platform ret (return value: cc.ApplicationProtocol::Platform)
--------------------------------
-- @function [parent=#Application] setAnimationInterval
-- @function [parent=#Application] getCurrentLanguageCode
-- @param self
-- @param #double double
-- @return char#char ret (return value: char)
--------------------------------
-- @function [parent=#Application] getCurrentLanguage
-- @param self
-- @return LanguageType#LanguageType ret (return value: cc.LanguageType)
--------------------------------
-- @function [parent=#Application] setAnimationInterval
-- @param self
-- @param #double double
--------------------------------
-- @function [parent=#Application] getInstance
-- @param self

View File

@ -1 +1 @@
9051708a178a924988d74ec62994d615f1882a3c
adb82cd767b31065425c12591d380c419a3d88ae

View File

@ -1544,6 +1544,7 @@ int register_all_cocos2dx(lua_State* tolua_S);
#endif // __cocos2dx_h__

View File

@ -236,6 +236,29 @@ void ScriptHandlerMgr::removeObjectAllHandlers(void* object)
}
}
ScriptHandlerMgr::HandlerType ScriptHandlerMgr::addCustomHandler(void* object, int handler)
{
assert(nullptr != object);
auto iter = _mapObjectHandlers.find(object);
VecHandlerPairs vecHandlers;
vecHandlers.clear();
HandlerType handlerType = HandlerType::EVENT_CUSTOM_BEGAN;
if (_mapObjectHandlers.end() != iter)
{
vecHandlers = iter->second;
handlerType = static_cast<HandlerType>((int)vecHandlers.back().first + 1);
}
assert(handlerType <= HandlerType::EVENT_CUSTOM_ENDED);
HandlerPair eventHanler = std::make_pair(handlerType, handler);
vecHandlers.push_back(eventHanler);
_mapObjectHandlers[object] = vecHandlers;
return handlerType;
}
NS_CC_END

View File

@ -160,8 +160,11 @@ public:
EVENT_PHYSICS_CONTACT_PRESOLVE,
EVENT_PHYSICS_CONTACT_POSTSOLVE,
EVENT_PHYSICS_CONTACT_SEPERATE,
EVENT_CUSTOM_BEGAN = 10000,
EVENT_CUSTOM_ENDED = 11000,
};
typedef int Handler;
typedef std::pair<HandlerType, Handler> HandlerPair;
typedef std::vector<HandlerPair> VecHandlerPairs;
@ -175,6 +178,7 @@ public:
void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
void removeObjectAllHandlers(void* object);
ScriptHandlerMgr::HandlerType addCustomHandler(void* object, int handler);
private:
void init(void);

View File

@ -4,8 +4,9 @@
@interface AppController : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
}
@property(nonatomic, readonly) RootViewController* viewController;
@end

View File

@ -53,20 +53,20 @@ static AppDelegate s_sharedApplication;
numberOfSamples: 0];
// Use RootViewController manage CCEAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = eaglView;
_viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
_viewController.wantsFullScreenLayout = YES;
_viewController.view = eaglView;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: viewController.view];
[window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:viewController];
[window setRootViewController:_viewController];
}
[window makeKeyAndVisible];

View File

@ -6,7 +6,7 @@ import socket
import time
HOST_MAC = 'localhost'
HOST_ADNROID = '10.10.30.64'
HOST_ADNROID = '10.10.40.64'
HOST_IOS = '10.10.30.61'
PORT = 5678
@ -75,12 +75,24 @@ def MAC_BUILD():
return buildAndRun()
#----------------autotest build and run end----------------#
PATH_ANDROID_SRC = 'tests/cpp-tests/proj.android/'
FILE_ANDROID_DELETE = ['libs','gen','assets','bin','obj']
#----------------autotest-android build and run----------------#
def ANDROID_BUILD():
def checkDevice():
cmd = 'adb devices'
infoDev = os.popen(cmd).readlines()
firstDev = infoDev[1]
if len(firstDev) < 5 or firstDev.find('device') < 0:
print 'no android device.'
return False
else:
print 'device info:', firstDev
return True
def cleanProj():
infoClean = os.system('rm -rf libs gen obj assets bin')
print 'infoClean: ', infoClean
infoClean = os.system('adb uninstall org.cocos2dx.testcpp');
for strFile in FILE_ANDROID_DELETE:
infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile)
infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests');
print 'infoClean: ', infoClean
if infoClean != 0:
print 'clean **CLEAN FAILED**'
@ -88,19 +100,26 @@ def ANDROID_BUILD():
def updateProperty():
infoUpdate = os.system('android update project -p ./cocos/2d/platform/android/java/ -t 12')
print 'cocos update:', infoUpdate
infoUpdate = os.system('android update project -p ./tests/proj.android/ -t 12')
infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12')
print 'test update:', infoUpdate
def buildProj():
infoBuild = os.system('./build/android-build.py testcpp')
print 'infoBuild testcpp: ', infoBuild
infoBuild = os.system('ant -buildfile ./tests/proj.android/ debug install')
infoBuild = os.system('./build/android-build.py -p 13 cpp-tests')
print 'infoBuild cpp_tests: ', infoBuild
infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug')
print 'infoBuild: ', infoBuild
if infoBuild != 0:
print 'build **BUILD FAILED**'
time.sleep(sleep_time)
return infoBuild
def installProj():
cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk'
infoInstall = os.system(cmd)
print 'infoInstall:', infoInstall
if infoInstall != 0:
print 'install **INSTALL FAILED**'
return infoInstall
def openProj():
cmd = 'adb shell am start -n org.cocos2dx.testcpp/org.cocos2dx.testcpp.Cocos2dxActivity'
cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity'
print 'cmd: ', cmd
infoOpen = os.system(cmd)
print 'infoOpen: ', infoOpen
@ -109,11 +128,12 @@ def ANDROID_BUILD():
time.sleep(sleep_time)
return True
def buildAndRun():
if not checkDevice():
return False
cleanProj()
updateProperty()
if buildProj() != 0:
cleanProj()
buildProj()
buildProj()
installProj()
return openProj()
return buildAndRun()
#----------------autotest-android build and run end----------------#
@ -121,11 +141,12 @@ def ANDROID_BUILD():
def main():
print 'will build mac project.'
suc_build_mac = MAC_BUILD()
#print 'will build android project.'
#suc_build_android = ANDROID_BUILD()
print 'will build android project.'
suc_build_android = ANDROID_BUILD()
if suc_build_mac:
autotest(TYPE_MAC)
if suc_build_android:
print 'will run android autotest.'
autotest(TYPE_ANDROID)