mirror of https://github.com/axmolengine/axmol.git
Merge pull request #11357 from WenhaiLin/v3-autotest
Test automation support:Make test cases didn't need to care about TestSuite when invoking Director::getInstance()->replaceScene.
This commit is contained in:
commit
5938fce905
|
@ -290,14 +290,14 @@ void TestSuite::runThisTest()
|
||||||
{
|
{
|
||||||
if (!_childTestNames.empty())
|
if (!_childTestNames.empty())
|
||||||
{
|
{
|
||||||
|
TestController::getInstance()->setCurrTestSuite(this);
|
||||||
|
|
||||||
_currTestIndex = 0;
|
_currTestIndex = 0;
|
||||||
auto scene = _testCallbacks[0]();
|
auto scene = _testCallbacks[0]();
|
||||||
auto testCase = getTestCase(scene);
|
auto testCase = getTestCase(scene);
|
||||||
testCase->setTestSuite(this);
|
testCase->setTestSuite(this);
|
||||||
testCase->setTestCaseName(_childTestNames[_currTestIndex]);
|
testCase->setTestCaseName(_childTestNames[_currTestIndex]);
|
||||||
Director::getInstance()->replaceScene(scene);
|
Director::getInstance()->replaceScene(scene);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,6 +437,11 @@ void TestCase::onEnter()
|
||||||
_titleLabel->setString(title());
|
_titleLabel->setString(title());
|
||||||
_subtitleLabel->setString(subtitle());
|
_subtitleLabel->setString(subtitle());
|
||||||
|
|
||||||
|
if (_testSuite == nullptr)
|
||||||
|
{
|
||||||
|
setTestSuite(TestController::getInstance()->getCurrTestSuite());
|
||||||
|
}
|
||||||
|
|
||||||
if (_testSuite && _testSuite->getChildTestCount() < 2)
|
if (_testSuite && _testSuite->getChildTestCount() < 2)
|
||||||
{
|
{
|
||||||
_priorTestItem->setVisible(false);
|
_priorTestItem->setVisible(false);
|
||||||
|
|
|
@ -11,15 +11,6 @@
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
Scene* Bug1159Layer::scene()
|
|
||||||
{
|
|
||||||
auto scene = Scene::create();
|
|
||||||
auto layer = Bug1159Layer::create();
|
|
||||||
scene->addChild(layer);
|
|
||||||
|
|
||||||
return scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Bug1159Layer::init()
|
bool Bug1159Layer::init()
|
||||||
{
|
{
|
||||||
if (BugsTestBase::init())
|
if (BugsTestBase::init())
|
||||||
|
@ -59,7 +50,7 @@ bool Bug1159Layer::init()
|
||||||
|
|
||||||
void Bug1159Layer::callBack(Ref* sender)
|
void Bug1159Layer::callBack(Ref* sender)
|
||||||
{
|
{
|
||||||
Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false));
|
Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::create(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bug1159Layer::onExit()
|
void Bug1159Layer::onExit()
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Bug1159Layer : public BugsTestBase
|
||||||
public:
|
public:
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
static cocos2d::Scene* scene();
|
|
||||||
void callBack(cocos2d::Ref* sender);
|
void callBack(cocos2d::Ref* sender);
|
||||||
|
|
||||||
CREATE_FUNC(Bug1159Layer);
|
CREATE_FUNC(Bug1159Layer);
|
||||||
|
|
|
@ -11,20 +11,6 @@
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
Scene* Bug914Layer::scene()
|
|
||||||
{
|
|
||||||
// 'scene' is an autorelease object.
|
|
||||||
auto scene = Scene::create();
|
|
||||||
// 'layer' is an autorelease object.
|
|
||||||
auto layer = Bug914Layer::create();
|
|
||||||
|
|
||||||
// add layer as a child to scene
|
|
||||||
scene->addChild(layer);
|
|
||||||
|
|
||||||
// return the scene
|
|
||||||
return scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
// on "init" you need to initialize your instance
|
// on "init" you need to initialize your instance
|
||||||
bool Bug914Layer::init()
|
bool Bug914Layer::init()
|
||||||
{
|
{
|
||||||
|
@ -81,5 +67,5 @@ void Bug914Layer::onTouchesBegan(const std::vector<Touch*>& touches, Event * eve
|
||||||
|
|
||||||
void Bug914Layer::restart(Ref* sender)
|
void Bug914Layer::restart(Ref* sender)
|
||||||
{
|
{
|
||||||
Director::getInstance()->replaceScene(Bug914Layer::scene());
|
Director::getInstance()->replaceScene(Bug914Layer::create());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
class Bug914Layer : public BugsTestBase
|
class Bug914Layer : public BugsTestBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static cocos2d::Scene* scene();
|
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
|
||||||
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
||||||
|
|
|
@ -83,8 +83,6 @@ void GameOverLayer::gameOverDone()
|
||||||
{
|
{
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto newScene = CocoStudioComponentsTest::create();
|
auto newScene = CocoStudioComponentsTest::create();
|
||||||
auto gameoverScene = (GameOverScene*)director->getRunningScene();
|
|
||||||
newScene->setTestSuite(gameoverScene->getTestSuite());
|
|
||||||
director->replaceScene(newScene);
|
director->replaceScene(newScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,6 @@ void SceneController::spriteMoveFinished(Node* sender)
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto gameOverScene = GameOverScene::create();
|
auto gameOverScene = GameOverScene::create();
|
||||||
gameOverScene->getLayer()->getLabel()->setString("You Lose :[");
|
gameOverScene->getLayer()->getLabel()->setString("You Lose :[");
|
||||||
auto currScene = (CocoStudioComponentsTest*)director->getRunningScene();
|
|
||||||
gameOverScene->setTestSuite(currScene->getTestSuite());
|
|
||||||
|
|
||||||
Director::getInstance()->replaceScene(gameOverScene);
|
Director::getInstance()->replaceScene(gameOverScene);
|
||||||
}
|
}
|
||||||
|
@ -107,8 +105,6 @@ void SceneController::increaseKillCount()
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto gameOverScene = GameOverScene::create();
|
auto gameOverScene = GameOverScene::create();
|
||||||
gameOverScene->getLayer()->getLabel()->setString("You Win!");
|
gameOverScene->getLayer()->getLabel()->setString("You Win!");
|
||||||
auto currScene = (CocoStudioComponentsTest*)director->getRunningScene();
|
|
||||||
gameOverScene->setTestSuite(currScene->getTestSuite());
|
|
||||||
Director::getInstance()->replaceScene(gameOverScene);
|
Director::getInstance()->replaceScene(gameOverScene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public:
|
||||||
TestController::TestController()
|
TestController::TestController()
|
||||||
: _stopAutoTest(true)
|
: _stopAutoTest(true)
|
||||||
, _isRunInBackground(false)
|
, _isRunInBackground(false)
|
||||||
|
, _testSuite(nullptr)
|
||||||
{
|
{
|
||||||
_rootTestList = new (std::nothrow) RootTests;
|
_rootTestList = new (std::nothrow) RootTests;
|
||||||
_rootTestList->runThisTest();
|
_rootTestList->runThisTest();
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
|
|
||||||
bool blockTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
|
bool blockTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
|
||||||
|
|
||||||
|
void setCurrTestSuite(TestSuite* testSuite) { _testSuite = testSuite; }
|
||||||
|
TestSuite* getCurrTestSuite() { return _testSuite; }
|
||||||
private:
|
private:
|
||||||
TestController();
|
TestController();
|
||||||
|
|
||||||
|
@ -72,6 +74,7 @@ private:
|
||||||
bool _isRunInBackground;
|
bool _isRunInBackground;
|
||||||
|
|
||||||
TestList* _rootTestList;
|
TestList* _rootTestList;
|
||||||
|
TestSuite* _testSuite;
|
||||||
|
|
||||||
std::thread _autoTestThread;
|
std::thread _autoTestThread;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue