2014-01-15 09:22:45 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2011 Zynga Inc.
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
#ifndef __PERFORMANCE_SPRITE_TEST_H__
|
|
|
|
#define __PERFORMANCE_SPRITE_TEST_H__
|
|
|
|
|
|
|
|
#include "PerformanceTest.h"
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SubTest
|
|
|
|
{
|
|
|
|
public:
|
2011-04-07 14:30:35 +08:00
|
|
|
~SubTest();
|
2011-03-25 13:59:08 +08:00
|
|
|
void removeByTag(int tag);
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* createSpriteWithTag(int tag);
|
|
|
|
void initWithSubTest(int nSubTest, Node* parent);
|
2011-03-25 13:59:08 +08:00
|
|
|
|
|
|
|
protected:
|
2014-01-15 09:22:45 +08:00
|
|
|
int subtestNumber;
|
2014-01-17 05:07:56 +08:00
|
|
|
Node *_parentNode;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteMenuLayer : public PerformBasicLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SpriteMenuLayer(bool bControlMenuVisible, int nMaxCases = 0, int nCurCase = 0)
|
|
|
|
: PerformBasicLayer(bControlMenuVisible, nMaxCases, nCurCase)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
virtual void restartCallback(Ref* sender);
|
|
|
|
virtual void nextCallback(Ref* sender);
|
|
|
|
virtual void backCallback(Ref* sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void showCurrentTest();
|
2011-03-25 13:59:08 +08:00
|
|
|
};
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class SpriteMainScene : public Scene
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~SpriteMainScene();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const;
|
2011-03-25 13:59:08 +08:00
|
|
|
|
|
|
|
void initWithSubTest(int nSubTest, int nNodes);
|
|
|
|
void updateNodes();
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void testNCallback(Ref* sender);
|
|
|
|
void onIncrease(Ref* sender);
|
|
|
|
void onDecrease(Ref* sender);
|
2011-03-25 13:59:08 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual void doTest(Sprite* sprite) = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
int getSubTestNum() { return subtestNumber; }
|
|
|
|
int getNodesNum() { return quantityNodes; }
|
2013-09-30 16:22:55 +08:00
|
|
|
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-09-30 16:22:55 +08:00
|
|
|
void updateAutoTest(float dt);
|
2014-02-20 10:53:49 +08:00
|
|
|
void onAutoTest(Ref* sender);
|
2014-01-15 09:22:45 +08:00
|
|
|
|
|
|
|
static bool _s_autoTest;
|
|
|
|
static int _s_nSpriteCurCase;
|
|
|
|
|
|
|
|
protected:
|
2013-09-30 16:22:55 +08:00
|
|
|
void dumpProfilerFPS();
|
|
|
|
void beginAutoTest();
|
|
|
|
void endAutoTest();
|
|
|
|
void nextAutoTest();
|
|
|
|
void finishAutoTest();
|
|
|
|
void autoShowSpriteTests(int curCase, int subTest,int nodes);
|
2014-01-15 09:22:45 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
int lastRenderedCount;
|
|
|
|
int quantityNodes;
|
2013-06-15 14:03:30 +08:00
|
|
|
SubTest *_subTest;
|
2012-04-19 14:35:52 +08:00
|
|
|
int subtestNumber;
|
2013-09-30 16:22:55 +08:00
|
|
|
std::vector<float> _vecFPS;
|
|
|
|
int _executeTimes;
|
2014-01-15 09:22:45 +08:00
|
|
|
|
2013-10-10 17:17:10 +08:00
|
|
|
static const int MAX_AUTO_TEST_TIMES = 25;
|
|
|
|
static const int MAX_SPRITE_TEST_CASE = 7;
|
2014-05-06 13:59:16 +08:00
|
|
|
static const int MAX_SUB_TEST_NUMS = 13;
|
2013-10-10 17:17:10 +08:00
|
|
|
static const int AUTO_TEST_NODE_NUM1 = 500;
|
|
|
|
static const int AUTO_TEST_NODE_NUM2 = 1500;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest1 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest2 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest3 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest4 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest5 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
2011-03-25 13:59:08 +08:00
|
|
|
class SpritePerformTest6 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2011-03-25 13:59:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpritePerformTest7 : public SpriteMainScene
|
|
|
|
{
|
|
|
|
public:
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual void doTest(Sprite* sprite) override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-15 09:22:45 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void runSpriteTest();
|
|
|
|
|
|
|
|
#endif
|