33#define TEST_TIME_OUT 50
34#define CREATE_TIME_OUT 25
35#define LOG_INDENTATION " "
36#define LOG_TAG "[TestController]"
47 addTest(
"ActionManager", [](){
return new (std::nothrow) ActionManagerTests(); });
48 addTest(
"Actions - Basic", [](){
return new (std::nothrow) ActionsTests(); });
49 addTest(
"Actions - Ease", [](){
return new (std::nothrow) ActionsEaseTests(); });
50 addTest(
"Actions - Progress", [](){
return new (std::nothrow) ActionsProgressTests(); });
51 addTest(
"Audio - NewAudioEngine", []() {
return new (std::nothrow) AudioEngineTests(); });
52#if CC_ENABLE_CHIPMUNK_INTEGRATION
53 addTest(
"Chipmunk", []() {
return new ChipmunkTests(); });
55 addTest(
"Bugs", []() {
return new BugsTests(); });
56 addTest(
"Click and Move", [](){
return new ClickAndMoveTest(); });
57 addTest(
"Configuration", []() {
return new ConfigurationTests(); });
58 addTest(
"Console", []() {
return new ConsoleTests(); });
59#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
61 addTest(
"Curl", []() {
return new CurlTests(); });
63 addTest(
"Current Language", []() {
return new CurrentLanguageTests(); });
64 addTest(
"Downloader Test", []() {
return new DownloaderTests(); });
65 addTest(
"EventDispatcher", []() {
return new EventDispatcherTests(); });
66 addTest(
"Effects - Advanced", []() {
return new EffectAdvanceTests(); });
67 addTest(
"Effects - Basic", [](){
return new EffectTests(); });
68 addTest(
"Extensions", []() {
return new ExtensionsTests(); });
69 addTest(
"FileUtils", []() {
return new FileUtilsTests(); });
70 addTest(
"Fonts", []() {
return new FontTests(); });
71 addTest(
"Interval", [](){
return new IntervalTests(); });
72#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
73 addTest(
"JNIHelper", []() {
return new JNITests(); });
75 addTest(
"Material System", [](){
return new MaterialSystemTest(); });
76 addTest(
"Navigation Mesh", [](){
return new NavMeshTests(); });
77 addTest(
"Node: BillBoard Test", [](){
return new BillBoardTests(); });
78 addTest(
"Node: Camera 3D Test", [](){
return new Camera3DTests(); });
79 addTest(
"Node: Clipping", []() {
return new ClippingNodeTests(); });
80 addTest(
"Node: Draw", [](){
return new DrawPrimitivesTests(); });
81 addTest(
"Node: Label - New API", [](){
return new NewLabelTests(); });
82 addTest(
"Node: Layer", [](){
return new LayerTests(); });
83 addTest(
"Node: Light", [](){
return new LightTests(); });
84 addTest(
"Node: Menu", [](){
return new MenuTests(); });
85 addTest(
"Node: MotionStreak", [](){
return new MotionStreakTests(); });
86 addTest(
"Node: Node", [](){
return new CocosNodeTests(); });
87 addTest(
"Node: Parallax", [](){
return new ParallaxTests(); });
88 addTest(
"Node: Particles", [](){
return new ParticleTests(); });
89 addTest(
"Node: Particle3D (PU)", [](){
return new Particle3DTests(); });
91 addTest(
"Node: Physics", []() {
return new PhysicsTests(); });
93 addTest(
"Node: Physics3D", []() {
return new Physics3DTests(); } );
94 addTest(
"Node: RenderTexture", [](){
return new RenderTextureTests(); });
95 addTest(
"Node: Scene", [](){
return new SceneTests(); });
97 addTest(
"Node: Sprite", [](){
return new SpriteTests(); });
98 addTest(
"Node: Sprite3D", [](){
return new Sprite3DTests(); });
99 addTest(
"Node: SpritePolygon", [](){
return new (std::nothrow) SpritePolygonTest(); });
100 addTest(
"Node: Terrain", [](){
return new TerrainTests(); });
101 addTest(
"Node: TileMap", [](){
return new TileMapTests(); });
102 addTest(
"Node: FastTileMap", [](){
return new FastTileMapTests(); });
103 addTest(
"Node: Text Input", [](){
return new TextInputTests(); });
105 addTest(
"Mouse", []() {
return new MouseTests(); });
106 addTest(
"MultiTouch", []() {
return new MultiTouchTests(); });
107 addTest(
"Renderer", []() {
return new NewRendererTests(); });
108 addTest(
"ReleasePool", [](){
return new ReleasePoolTests(); });
109 addTest(
"Rotate World", [](){
return new RotateWorldTests(); });
110 addTest(
"Scheduler", [](){
return new SchedulerTests(); });
111 addTest(
"Shader - Basic", []() {
return new ShaderTests(); });
112 addTest(
"Shader - Sprite", []() {
return new Shader2Tests(); });
113 addTest(
"Texture2D", [](){
return new Texture2DTests(); });
114 addTest(
"TextureCache", []() {
return new TextureCacheTests(); });
115 addTest(
"TexturePacker Encryption", []() {
return new TextureAtlasEncryptionTests(); });
116 addTest(
"Touches", [](){
return new TouchesTests(); });
117 addTest(
"Transitions", [](){
return new TransitionsTests(); });
118 addTest(
"Unit Test", []() {
return new UnitTests(); });
119 addTest(
"Unzip Test", []() {
return new ZipTests();});
120 addTest(
"URL Open Test", []() {
return new OpenURLTests(); });
121 addTest(
"UserDefault", []() {
return new UserDefaultTests(); });
122#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
123 addTest(
"Vibrate", []() {
return new VibrateTests(); });
125 addTest(
"Zwoptex", []() {
return new ZwoptexTests(); });
126 addTest(
"SpriteFrameCache", []() {
return new SpriteFrameCacheTests(); });
127#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
128 addTest(
"Window Test", []() {
return new WindowTests(); });
135, _isRunInBackground(false)
180 std::mutex sleepMutex;
181 auto lock = std::unique_lock<std::mutex>(sleepMutex);
200 auto scheduler =
_director->getScheduler();
207 logEx(
"_director is paused");
212 auto test = callback();
213 test->setTestParent(testList);
215 if (test->isTestList())
217 scheduler->performFunctionInCocosThread([&](){
239 scheduler->performFunctionInCocosThread([&](){
252 auto scheduler =
_director->getScheduler();
254 float testCaseDuration = 0.0f;
266 Scene* testScene =
nullptr;
268 TransitionScene* transitionScene =
nullptr;
274 logEx(
"_director is paused");
278 scheduler->performFunctionInCocosThread([&, logIndentation, testName](){
280 logEx(
"%s%sRun test:%s.",
LOG_TAG, logIndentation.c_str(), testName.c_str());
282 auto scene = callback();
287 transitionScene =
dynamic_cast<TransitionScene*
>(scene);
290 testCase = (
TestCase*)transitionScene->getInScene();
291 testCaseDuration = transitionScene->
getDuration() + 0.5f;
310 float waitTime = 0.0f;
321 logEx(
"%sCreate test %s time out",
LOG_TAG, testName.c_str());
332 if (transitionScene ==
nullptr)
345 logEx(
"%sRun test %s time out",
LOG_TAG, testName.c_str());
363 scheduler->performFunctionInCocosThread([&](){
364 parentTest->runThisTest();
368 testSuite->release();
436 va_start(args, format);
437 vsnprintf(buff, 1020, format, args);
440#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
441 __android_log_print(ANDROID_LOG_DEBUG,
"cocos2d-x debug info",
"%s", buff);
443#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
444 WCHAR wszBuf[1024] = { 0 };
445 MultiByteToWideChar(CP_UTF8, 0, buff, -1, wszBuf,
sizeof(wszBuf));
446 OutputDebugStringW(wszBuf);
450 fprintf(stdout,
"%s", buff);
488#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
498 return EXCEPTION_EXECUTE_HANDLER;
507 SetUnhandledExceptionFilter(UnhandledExceptionFilter);
510#elif CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
512#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
513static int s_fatal_signals[] = {
523static int s_fatal_signals[] = {
535static void signalHandler(
int sig)
545 for (
auto sig : s_fatal_signals)
547 signal(sig, signalHandler);
553 for (
auto sig : s_fatal_signals)
555 signal(sig, SIG_DFL);
virtual void runThisTest()
std::string getTestName() const
std::vector< std::string > _childTestNames
virtual std::string getExpectedOutput() const
std::string getTestCaseName() const
virtual Type getTestType() const
void setTestCaseName(const std::string &name)
virtual float getDuration() const
virtual std::string getActualOutput() const
void setTestSuite(TestSuite *testSuite)
bool checkTest(TestCase *testCase)
cocos2d::Director * _director
static void destroyInstance()
bool blockTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
void traverseTestList(TestList *testList)
std::string _logIndentation
std::unique_lock< std::mutex > * _sleepUniqueLock
cocos2d::EventListenerTouchOneByOne * _touchListener
std::thread _autoTestThread
std::condition_variable _sleepCondition
static TestController * getInstance()
void traverseTestSuite(TestSuite *testSuite)
std::atomic< bool > _stopAutoTest
void traverseThreadFunc()
void logEx(const char *format,...)
virtual void runThisTest() override
std::vector< std::function< TestBase *()> > _testCallbacks
void addTest(const std::string &testName, std::function< TestBase *()> callback)
std::vector< std::function< cocos2d::Scene *()> > _testCallbacks
static long __stdcall windowExceptionFilter(_EXCEPTION_POINTERS *excp)
static TestController * s_testController
static void disableCrashCatch()
static void initCrashCatch()