2012-04-19 14:35:52 +08:00
|
|
|
#include "ExtensionsTest.h"
|
|
|
|
#include "../testResource.h"
|
|
|
|
#include "NotificationCenterTest/NotificationCenterTest.h"
|
|
|
|
#include "ControlExtensionTest/CCControlSceneManager.h"
|
2012-05-03 12:17:28 +08:00
|
|
|
#include "CocosBuilderTest/CocosBuilderTest.h"
|
2013-06-21 03:15:42 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
|
2012-08-09 10:45:11 +08:00
|
|
|
#include "NetworkTest/HttpClientTest.h"
|
2013-05-08 08:25:39 +08:00
|
|
|
#endif
|
2012-09-09 22:34:32 +08:00
|
|
|
#include "TableViewTest/TableViewTestScene.h"
|
2013-06-04 17:38:43 +08:00
|
|
|
#include "ComponentsTest/ComponentsTestScene.h"
|
2013-06-14 14:34:50 +08:00
|
|
|
#include "ArmatureTest/ArmatureScene.h"
|
2012-09-09 22:34:32 +08:00
|
|
|
|
2013-05-31 23:13:03 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
|
|
|
#include "NetworkTest/WebSocketTest.h"
|
|
|
|
#endif
|
|
|
|
|
2013-05-26 19:40:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
2012-08-15 14:33:56 +08:00
|
|
|
#include "EditBoxTest/EditBoxTest.h"
|
|
|
|
#endif
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LINE_SPACE = 40,
|
|
|
|
kItemTagBasic = 1000,
|
|
|
|
};
|
|
|
|
|
2013-06-08 08:21:11 +08:00
|
|
|
static struct {
|
|
|
|
const char *name;
|
2013-06-20 14:17:10 +08:00
|
|
|
std::function<void(Object* sender)> callback;
|
2013-06-08 08:21:11 +08:00
|
|
|
} g_extensionsTests[] = {
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "NotificationCenterTest", [](Object* sender) { runNotificationCenterTest(); }
|
2013-06-08 08:21:11 +08:00
|
|
|
},
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "CCControlButtonTest", [](Object *sender){
|
|
|
|
ControlSceneManager* pManager = ControlSceneManager::sharedControlSceneManager();
|
|
|
|
Scene* pScene = pManager->currentControlScene();
|
|
|
|
Director::sharedDirector()->replaceScene(pScene);
|
2013-06-08 08:21:11 +08:00
|
|
|
}},
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "CocosBuilderTest", [](Object *sender) {
|
2013-06-08 08:21:11 +08:00
|
|
|
TestScene* pScene = new CocosBuilderTestScene();
|
|
|
|
if (pScene)
|
|
|
|
{
|
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
|
|
|
}
|
|
|
|
}},
|
2013-06-21 03:15:42 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "HttpClientTest", [](Object *sender){ runHttpClientTest();}
|
2013-06-08 08:21:11 +08:00
|
|
|
},
|
2013-05-08 08:25:39 +08:00
|
|
|
#endif
|
2013-05-31 23:13:03 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "WebSocketTest", [](Object *sender){ runWebSocketTest();}
|
2013-06-08 08:21:11 +08:00
|
|
|
},
|
2013-05-31 23:13:03 +08:00
|
|
|
#endif
|
2013-05-26 19:40:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "EditBoxTest", [](Object *sender){ runEditBoxTest();}
|
2013-06-08 08:21:11 +08:00
|
|
|
},
|
2012-08-15 14:33:56 +08:00
|
|
|
#endif
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "TableViewTest", [](Object *sender){ runTableViewTest();}
|
2013-06-08 08:21:11 +08:00
|
|
|
},
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "CommponentTest", [](Object *sender) { runComponentsTestLayerTest(); }
|
2013-06-14 14:34:50 +08:00
|
|
|
},
|
2013-06-20 14:17:10 +08:00
|
|
|
{ "ArmatureTest", [](Object *sender) { ArmatureTestScene *pScene = new ArmatureTestScene();
|
2013-06-14 14:34:50 +08:00
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
|
|
|
}
|
|
|
|
},
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2013-06-08 08:21:11 +08:00
|
|
|
static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]);
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ExtensionsMainLayer
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
void ExtensionsMainLayer::onEnter()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer::onEnter();
|
2013-06-14 14:34:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Size s = Director::sharedDirector()->getWinSize();
|
2013-06-14 14:34:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Menu* pMenu = Menu::create();
|
|
|
|
pMenu->setPosition( PointZero );
|
|
|
|
MenuItemFont::setFontName("Arial");
|
|
|
|
MenuItemFont::setFontSize(24);
|
2013-06-08 08:21:11 +08:00
|
|
|
for (int i = 0; i < g_maxTests; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
MenuItemFont* pItem = MenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback);
|
2012-04-19 14:35:52 +08:00
|
|
|
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
2013-06-14 14:34:50 +08:00
|
|
|
pMenu->addChild(pItem, kItemTagBasic + i);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-06-14 14:34:50 +08:00
|
|
|
|
|
|
|
addChild(pMenu);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ExtensionsTestScene
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ExtensionsTestScene::runThisTest()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
Layer* pLayer = new ExtensionsMainLayer();
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(pLayer);
|
|
|
|
pLayer->release();
|
2013-06-14 14:34:50 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Director::sharedDirector()->replaceScene(this);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|