issue #5056. move gui test from ExtensionsTest to the outside

This commit is contained in:
andyque 2014-05-08 14:35:45 +08:00
parent 4defe28f1f
commit 898a66131a
95 changed files with 578 additions and 647 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@
#include "CocoStudioArmatureTest/ArmatureScene.h"
#include "CocoStudioComponentsTest/ComponentsTestScene.h"
#include "CocoStudioSceneTest/SceneEditorTest.h"
#include "CocoStudioGUITest/CocoStudioGUITest.h"
#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_WP8)
#include "NetworkTest/WebSocketTest.h"
@ -86,13 +85,6 @@ static struct {
scene->release();
}
},
{ "CocoStudioGUITest", [](Ref *sender)
{
CocoStudioGUITestScene* pScene = new CocoStudioGUITestScene();
pScene->runThisTest();
pScene->release();
}
},
};
static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]);

View File

@ -5,7 +5,8 @@
#include "CocosGUIScene.h"
#include "GUIEditorTest.h"
#include "CustomGUIScene.h"
#include "controller.h"
#include "cocostudio/CocoStudio.h"
enum
{
@ -93,35 +94,6 @@ void CocoStudioGUIMainLayer::onTouchesBegan(const std::vector<Touch*>& touches,
_beginPos = touch->getLocation();
}
/*
void CocoStudioGUIMainLayer::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
{
auto touch = static_cast<Touch*>(touches[0]);
auto touchLocation = touch->getLocation();
float nMoveY = touchLocation.y - _beginPos.y;
auto curPos = _itemMenu->getPosition();
auto nextPos = Vector2(curPos.x, curPos.y + nMoveY);
if (nextPos.y < 0.0f)
{
_itemMenu->setPosition(Vector2::ZERO);
return;
}
float y = (g_maxTests + 1)* LINE_SPACE - VisibleRect::getVisibleRect().size.height;
if (nextPos.y > y)
{
_itemMenu->setPosition(Vector2(0, y));
return;
}
_itemMenu->setPosition(nextPos);
_beginPos = touchLocation;
_curPos = nextPos;
}
*/
////////////////////////////////////////////////////////
//
@ -156,7 +128,13 @@ void CocoStudioGUITestScene::runThisTest()
void CocoStudioGUITestScene::BackCallback(Ref* pSender)
{
ExtensionsTestScene* pScene = new ExtensionsTestScene();
pScene->runThisTest();
pScene->release();
auto scene = Scene::create();
auto layer = new TestController();
scene->addChild(layer);
layer->release();
Director::getInstance()->replaceScene(scene);
cocostudio::ArmatureDataManager::destroyInstance();
}

View File

@ -1,7 +1,6 @@
#include "CocosGUIScene.h"
#include "CocoStudioGUITest.h"
#include "UISceneManager.h"
#include "../ExtensionsTest.h"
#include "cocostudio/CocoStudio.h"
enum
@ -389,78 +388,3 @@ void CocosGUITestScene::BackCallback(Ref* pSender)
pScene->runThisTest();
pScene->release();
}
/*
const char* gui_scene_names[1] =
{
"CocosGUIWidgetTest",
};
CocosGUITestScene::CocosGUITestScene(bool bPortrait)
: _ul(nullptr)
, _label(nullptr)
, _itemMenu(nullptr)
{
TestScene::init();
}
CocosGUITestScene::~CocosGUITestScene()
{
cocostudio::SceneReader::getInstance()->purgeSceneReader();
cocostudio::ActionManagerEx::purgeActionManager();
}
void CocosGUITestScene::runThisTest()
{
Director::getInstance()->replaceScene(this);
Size s = Director::getInstance()->getWinSize();
_itemMenu = Menu::create();
_itemMenu->setPosition(Vector2::ZERO);
MenuItemFont::setFontName("fonts/arial.ttf");
MenuItemFont::setFontSize(24);
for (int i = 0; i < sizeof(gui_scene_names) / sizeof(gui_scene_names[0]); ++i)
{
auto item = MenuItemFont::create(gui_scene_names[i],
CC_CALLBACK_1( CocosGUITestScene::menuCallback, this));
item->setPosition(Vector2(s.width / 2, s.height - s.height / 4 - (i + 1) * 40));
item->setTag(i);
_itemMenu->addChild(item);
}
addChild(_itemMenu);
}
void CocosGUITestScene::MainMenuCallback(Ref* pSender)
{
auto pScene = new ExtensionsTestScene();
pScene->runThisTest();
}
void CocosGUITestScene::load(Ref *pSender, int count)
{
char tmp[10];
sprintf(tmp,"%d", count);
_label->setString(CCString::createWithFormat("%i", count)->getCString());
}
void CocosGUITestScene::menuCallback(Ref *pSender)
{
auto pItem = static_cast<MenuItemFont*>(pSender);
switch (pItem->getTag())
{
case 0:
{
UISceneManager* pManager = UISceneManager::sharedUISceneManager();
Scene* pScene = pManager->currentUIScene();
Director::getInstance()->replaceScene(pScene);
}
break;
break;
default:
break;
}
}
*/

View File

@ -225,7 +225,7 @@ bool UIFocusTestVertical::init()
_verticalLayout->setPosition(Vector2(winSize.width/2 - 100, winSize.height - 70));
_uiLayer->addChild(_verticalLayout);
_verticalLayout->setTag(100);
_verticalLayout->setScale(0.8);
_verticalLayout->setScale(0.5);
_verticalLayout->setFocused(true);
_verticalLayout->setLoopFocus(true);
@ -292,9 +292,9 @@ bool UIFocusTestNestedLayout1::init()
Size winSize = Director::getInstance()->getVisibleSize();
_verticalLayout = VBox::create();
_verticalLayout->setPosition(Vector2(winSize.width/2 - 100, winSize.height - 70));
_verticalLayout->setPosition(Vector2(winSize.width/2 - 80, winSize.height - 70));
_uiLayer->addChild(_verticalLayout);
_verticalLayout->setScale(0.8);
_verticalLayout->setScale(0.5);
_verticalLayout->setFocused(true);
_verticalLayout->setLoopFocus(true);
@ -396,7 +396,7 @@ bool UIFocusTestNestedLayout2::init()
_horizontalLayout = HBox::create();
_horizontalLayout->setPosition(Vector2(winSize.width/2 - 200, winSize.height - 70));
_uiLayer->addChild(_horizontalLayout);
_horizontalLayout->setScale(0.8);
_horizontalLayout->setScale(0.6);
_horizontalLayout->setFocused(true);
_horizontalLayout->setLoopFocus(true);

View File

@ -2,7 +2,6 @@
#include "extensions/cocos-ext.h"
#include "UIScene.h"
#include "UISceneManager.h"
#include "../ExtensionsTest.h"
#include "editor-support/cocostudio/CCSGUIReader.h"
#include "CocosGUIScene.h"
@ -73,9 +72,7 @@ void UIScene::menuCloseCallback(Ref* pSender, TouchEventType type)
if (type == TOUCH_EVENT_ENDED)
{
_uiLayer->removeFromParent();
auto scene = new ExtensionsTestScene();
scene->runThisTest();
scene->release();
}
}

View File

@ -0,0 +1,8 @@
#include "UITest.h"
#include "CocoStudioGUITest/CocoStudioGUITest.h"
void UITestScene::runThisTest()
{
CocoStudioGUITestScene* pScene = new CocoStudioGUITestScene();
pScene->runThisTest();
}

View File

@ -0,0 +1,13 @@
#ifndef __cocos2d_tests__UITest__
#define __cocos2d_tests__UITest__
#include "../testBasic.h"
#include "../BaseTest.h"
class UITestScene : public TestScene
{
public:
virtual void runThisTest() override;
};
#endif /* defined(__cocos2d_tests__UITest__) */

View File

@ -19,6 +19,7 @@
#include <io.h>
#endif
#include "cocostudio/CocoStudio.h"
#include "UITest/UITest.h"
typedef struct _Controller{
const char *test_name;
@ -30,6 +31,7 @@ Controller g_aTestNames[] = {
// TESTS MUST BE ORDERED ALPHABETICALLY
// violators will be prosecuted
//
{ "A new UI", [](){ return new UITestScene(); }},
{ "Accelerometer", []() { return new AccelerometerTestScene(); } },
{ "ActionManager", [](){return new ActionManagerTestScene(); } },
{ "Actions - Basic", [](){ return new ActionsTestScene(); } },