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-05-08 08:25:39 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
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-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,
|
|
|
|
};
|
|
|
|
|
2012-05-03 10:12:00 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEST_NOTIFICATIONCENTER = 0,
|
|
|
|
TEST_CCCONTROLBUTTON,
|
2012-05-03 12:17:28 +08:00
|
|
|
TEST_COCOSBUILDER,
|
2012-08-09 10:45:11 +08:00
|
|
|
TEST_HTTPCLIENT,
|
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)
|
|
|
|
TEST_WEBSOCKET,
|
|
|
|
#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
|
|
|
TEST_EDITBOX,
|
|
|
|
#endif
|
2012-09-09 22:34:32 +08:00
|
|
|
TEST_TABLEVIEW,
|
2012-05-03 12:17:28 +08:00
|
|
|
TEST_MAX_COUNT,
|
2012-05-03 10:12:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const std::string testsName[TEST_MAX_COUNT] =
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
"NotificationCenterTest",
|
2012-04-27 18:47:49 +08:00
|
|
|
"CCControlButtonTest",
|
2012-05-03 12:17:28 +08:00
|
|
|
"CocosBuilderTest",
|
2013-05-08 08:25:39 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
2012-08-09 10:45:11 +08:00
|
|
|
"HttpClientTest",
|
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)
|
|
|
|
"WebSocketTest",
|
|
|
|
#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-09-09 22:34:32 +08:00
|
|
|
"EditBoxTest",
|
2012-08-15 14:33:56 +08:00
|
|
|
#endif
|
2012-09-09 22:34:32 +08:00
|
|
|
"TableViewTest"
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ExtensionsMainLayer
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
void ExtensionsMainLayer::onEnter()
|
|
|
|
{
|
|
|
|
CCLayer::onEnter();
|
|
|
|
|
|
|
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenu* pMenu = CCMenu::create();
|
2012-04-19 14:35:52 +08:00
|
|
|
pMenu->setPosition( CCPointZero );
|
|
|
|
CCMenuItemFont::setFontName("Arial");
|
|
|
|
CCMenuItemFont::setFontSize(24);
|
2012-05-03 10:12:00 +08:00
|
|
|
for (int i = 0; i < TEST_MAX_COUNT; ++i)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
2012-04-19 14:35:52 +08:00
|
|
|
menu_selector(ExtensionsMainLayer::menuCallback));
|
|
|
|
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
|
|
|
pMenu->addChild(pItem, kItemTagBasic + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
addChild(pMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExtensionsMainLayer::menuCallback(CCObject* pSender)
|
|
|
|
{
|
|
|
|
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
|
|
|
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
|
|
|
|
|
|
|
switch (nIndex)
|
|
|
|
{
|
2012-10-24 08:03:06 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) // MARMALADE CHANGE: Not yet avaiable on Marmalade
|
2012-05-03 10:12:00 +08:00
|
|
|
case TEST_NOTIFICATIONCENTER:
|
|
|
|
{
|
|
|
|
runNotificationCenterTest();
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
break;
|
2012-10-24 08:03:06 +08:00
|
|
|
#endif
|
2012-05-03 10:12:00 +08:00
|
|
|
case TEST_CCCONTROLBUTTON:
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
|
|
|
CCScene* pScene = pManager->currentControlScene();
|
|
|
|
CCDirector::sharedDirector()->replaceScene(pScene);
|
|
|
|
}
|
|
|
|
break;
|
2012-05-03 12:17:28 +08:00
|
|
|
case TEST_COCOSBUILDER:
|
|
|
|
{
|
|
|
|
TestScene* pScene = new CocosBuilderTestScene();
|
|
|
|
if (pScene)
|
|
|
|
{
|
|
|
|
pScene->runThisTest();
|
|
|
|
pScene->release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-05-08 08:25:39 +08:00
|
|
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE && CC_TARGET_PLATFORM != CC_PLATFORM_NACL && CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
2012-08-09 10:45:11 +08:00
|
|
|
case TEST_HTTPCLIENT:
|
2012-08-04 18:27:27 +08:00
|
|
|
{
|
2012-08-09 10:45:11 +08:00
|
|
|
runHttpClientTest();
|
2012-08-04 18:27:27 +08:00
|
|
|
}
|
2012-08-15 14:33:56 +08:00
|
|
|
break;
|
2012-10-24 08:03:06 +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)
|
|
|
|
case TEST_WEBSOCKET:
|
|
|
|
{
|
|
|
|
runWebSocketTest();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#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
|
|
|
case TEST_EDITBOX:
|
|
|
|
{
|
|
|
|
runEditBoxTest();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2012-09-09 22:34:32 +08:00
|
|
|
case TEST_TABLEVIEW:
|
|
|
|
{
|
|
|
|
runTableViewTest();
|
|
|
|
}
|
|
|
|
break;
|
2012-04-19 14:35:52 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ExtensionsTestScene
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ExtensionsTestScene::runThisTest()
|
|
|
|
{
|
|
|
|
CCLayer* pLayer = new ExtensionsMainLayer();
|
|
|
|
addChild(pLayer);
|
|
|
|
pLayer->release();
|
|
|
|
|
|
|
|
CCDirector::sharedDirector()->replaceScene(this);
|
|
|
|
}
|