2014-01-14 06:48:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2012 cocos2d-x.org
|
2016-08-05 09:42:15 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
2014-01-14 06:48:12 +08:00
|
|
|
|
|
|
|
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-03-21 13:36:24 +08:00
|
|
|
#ifndef _NODE_TEST_H_
|
|
|
|
#define _NODE_TEST_H_
|
|
|
|
|
|
|
|
////----#include "cocos2d.h"
|
2013-06-07 08:12:28 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-03-21 13:36:24 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(CocosNodeTests);
|
|
|
|
|
|
|
|
class TestCocosNodeDemo : public TestCase
|
2010-08-26 15:09:02 +08:00
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
TestCocosNodeDemo();
|
|
|
|
virtual ~TestCocosNodeDemo();
|
2015-04-03 14:31:03 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Director::Projection _preProjection;
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class NodeTest2 : public TestCocosNodeDemo
|
2010-08-26 15:09:02 +08:00
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(NodeTest2);
|
|
|
|
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class NodeTest4 : public TestCocosNodeDemo
|
2010-08-26 15:09:02 +08:00
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(NodeTest4);
|
2012-06-08 13:55:28 +08:00
|
|
|
void delay2(float dt);
|
|
|
|
void delay4(float dt);
|
2010-08-26 15:09:02 +08:00
|
|
|
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-03 14:31:03 +08:00
|
|
|
NodeTest4();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class NodeTest5 : public TestCocosNodeDemo
|
2010-08-26 15:09:02 +08:00
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(NodeTest5);
|
2010-08-26 15:09:02 +08:00
|
|
|
|
2014-01-03 07:51:26 +08:00
|
|
|
void addAndRemove(float dt);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-03 14:31:03 +08:00
|
|
|
NodeTest5();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class NodeTest6 : public TestCocosNodeDemo
|
2010-08-26 15:09:02 +08:00
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(NodeTest6);
|
2012-06-08 13:55:28 +08:00
|
|
|
void addAndRemove(float dt);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-03 14:31:03 +08:00
|
|
|
NodeTest6();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class StressTest1 : public TestCocosNodeDemo
|
|
|
|
{
|
2014-01-03 07:51:26 +08:00
|
|
|
public:
|
|
|
|
CREATE_FUNC(StressTest1);
|
2012-06-08 13:55:28 +08:00
|
|
|
void shouldNotCrash(float dt);
|
2013-06-20 14:17:10 +08:00
|
|
|
void removeMe(Node* node);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
StressTest1();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class StressTest2 : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(StressTest2);
|
|
|
|
void shouldNotLeak(float dt);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
StressTest2();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SchedulerTest1 : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(SchedulerTest1);
|
2012-06-08 13:55:28 +08:00
|
|
|
void doSomething(float dt);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SchedulerTest1();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2014-10-03 12:25:55 +08:00
|
|
|
class SchedulerCallbackTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(SchedulerCallbackTest);
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void onEnter() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float _total;
|
|
|
|
SchedulerCallbackTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-08-26 15:09:02 +08:00
|
|
|
class NodeToWorld : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(NodeToWorld);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeToWorld();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2014-01-10 06:26:36 +08:00
|
|
|
class NodeToWorld3D : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeToWorld3D);
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-10 06:26:36 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeToWorld3D();
|
|
|
|
};
|
|
|
|
|
2010-08-26 15:09:02 +08:00
|
|
|
class CameraOrbitTest : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(CameraOrbitTest);
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CameraOrbitTest();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class CameraZoomTest : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(CameraZoomTest);
|
2015-03-15 02:33:15 +08:00
|
|
|
void update(float dt) override;
|
2010-08-26 15:09:02 +08:00
|
|
|
|
2014-01-03 07:51:26 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-02-28 23:02:22 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CameraZoomTest();
|
|
|
|
float _z;
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class CameraCenterTest : public TestCocosNodeDemo
|
|
|
|
{
|
2012-03-21 13:36:24 +08:00
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(CameraCenterTest);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-03-31 18:17:00 +08:00
|
|
|
|
2015-03-15 02:33:15 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
CameraCenterTest();
|
2010-08-26 15:09:02 +08:00
|
|
|
};
|
|
|
|
|
2014-01-10 06:26:36 +08:00
|
|
|
class CameraTest1 : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(CameraTest1);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CameraTest1();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Sprite* _sprite1;
|
|
|
|
cocos2d::Sprite* _sprite2;
|
2014-01-10 06:26:36 +08:00
|
|
|
};
|
|
|
|
|
2014-01-09 08:28:18 +08:00
|
|
|
class CameraTest2 : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(CameraTest2);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CameraTest2();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Sprite* _sprite1;
|
|
|
|
cocos2d::Sprite* _sprite2;
|
2014-01-09 08:28:18 +08:00
|
|
|
};
|
|
|
|
|
2011-02-23 16:47:25 +08:00
|
|
|
class ConvertToNode : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(ConvertToNode);
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ConvertToNode();
|
2011-02-23 16:47:25 +08:00
|
|
|
};
|
|
|
|
|
2012-03-21 13:36:24 +08:00
|
|
|
class NodeOpaqueTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(NodeOpaqueTest);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeOpaqueTest();
|
2012-03-21 13:36:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeNonOpaqueTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
2014-01-03 07:51:26 +08:00
|
|
|
CREATE_FUNC(NodeNonOpaqueTest);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-01-03 07:51:26 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeNonOpaqueTest();
|
2012-03-21 13:36:24 +08:00
|
|
|
};
|
|
|
|
|
2014-01-19 03:35:27 +08:00
|
|
|
class NodeGlobalZValueTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeGlobalZValueTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeGlobalZValueTest();
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Sprite* _sprite;
|
2014-01-19 03:35:27 +08:00
|
|
|
};
|
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
class NodeNormalizedPositionTest1 : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeNormalizedPositionTest1);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeNormalizedPositionTest1();
|
|
|
|
};
|
|
|
|
|
|
|
|
class NodeNormalizedPositionTest2 : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeNormalizedPositionTest2);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeNormalizedPositionTest2();
|
|
|
|
|
2015-03-15 02:33:15 +08:00
|
|
|
void update(float dt) override;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Size _copyContentSize;
|
2014-05-31 07:42:05 +08:00
|
|
|
float _accum;
|
|
|
|
};
|
|
|
|
|
2014-09-01 11:29:40 +08:00
|
|
|
class NodeNormalizedPositionBugTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeNormalizedPositionBugTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
NodeNormalizedPositionBugTest();
|
|
|
|
|
2015-03-15 02:33:15 +08:00
|
|
|
void update(float dt) override;
|
2014-09-01 11:29:40 +08:00
|
|
|
float _accum;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Sprite* sprite;
|
2014-09-01 11:29:40 +08:00
|
|
|
};
|
|
|
|
|
2014-06-12 13:55:23 +08:00
|
|
|
class NodeNameTest : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(NodeNameTest);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
virtual void onEnter() override;
|
2016-05-18 16:26:13 +08:00
|
|
|
virtual void onExit() override;
|
2014-07-01 18:23:20 +08:00
|
|
|
|
|
|
|
void test(float dt);
|
2014-06-12 13:55:23 +08:00
|
|
|
};
|
2014-05-31 07:42:05 +08:00
|
|
|
|
2016-07-15 05:58:04 +08:00
|
|
|
class Issue16100Test : public TestCocosNodeDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue16100Test);
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
|
|
|
};
|
|
|
|
|
2010-08-26 15:09:02 +08:00
|
|
|
#endif
|