axmol/tests/cpp-tests/Classes/NewEventDispatcherTest/NewEventDispatcherTest.h

234 lines
5.8 KiB
C
Raw Normal View History

2013-09-13 16:38:21 +08:00
//
// NewEventDispatcherTest.h
// samples
//
// Created by James Chen on 9/13/13.
//
//
#ifndef __samples__NewEventDispatcherTest__
#define __samples__NewEventDispatcherTest__
#include "cocos2d.h"
#include "../BaseTest.h"
DEFINE_TEST_SUITE(EventDispatcherTests);
2013-09-13 16:38:21 +08:00
class EventDispatcherTestDemo : public TestCase
2013-09-13 16:38:21 +08:00
{
public:
virtual std::string title() const override;
2013-09-13 16:38:21 +08:00
};
class TouchableSpriteTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(TouchableSpriteTest);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-09-13 16:38:21 +08:00
};
class FixedPriorityTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(FixedPriorityTest);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class RemoveListenerWhenDispatching : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RemoveListenerWhenDispatching);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class CustomEventTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(CustomEventTest);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::EventListenerCustom* _listener;
cocos2d::EventListenerCustom* _listener2;
};
class LabelKeyboardEventTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelKeyboardEventTest);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class SpriteAccelerationEventTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(SpriteAccelerationEventTest);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class RemoveAndRetainNodeTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RemoveAndRetainNodeTest);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::Sprite* _sprite;
bool _spriteSaved;
};
class RemoveListenerAfterAddingTest : public EventDispatcherTestDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RemoveListenerAfterAddingTest);
virtual void onEnter() override;
virtual void onExit() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2013-12-21 16:56:28 +08:00
class DirectorEventTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(DirectorEventTest);
2014-01-06 18:26:14 +08:00
DirectorEventTest();
2013-12-21 16:56:28 +08:00
virtual void onEnter() override;
virtual void onExit() override;
virtual void update(float dt) override;
void onEvent1(cocos2d::EventCustom* event);
void onEvent2(cocos2d::EventCustom* event);
2013-12-21 16:56:28 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
int _count1, _count2, _count3, _count4;
cocos2d::Label* _label1, *_label2, *_label3, *_label4;
cocos2d::EventListenerCustom* _event1, *_event2, *_event3, *_event4;
2013-12-21 16:56:28 +08:00
};
class GlobalZTouchTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(GlobalZTouchTest);
GlobalZTouchTest();
virtual void update(float dt) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
cocos2d::Sprite* _sprite;
float _accum;
};
class StopPropagationTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(StopPropagationTest);
StopPropagationTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
protected:
bool isPointInNode(cocos2d::Vec2 pt, cocos2d::Node* node);
bool isPointInTopHalfAreaOfScreen(cocos2d::Vec2 pt);
};
class PauseResumeTargetTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(PauseResumeTargetTest);
PauseResumeTargetTest();
virtual ~PauseResumeTargetTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
};
class Issue4129 : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(Issue4129);
Issue4129();
virtual ~Issue4129();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::EventListenerCustom* _customlistener;
bool _bugFixed;
};
class Issue4160 : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(Issue4160);
Issue4160();
virtual ~Issue4160();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
};
class DanglingNodePointersTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(DanglingNodePointersTest);
DanglingNodePointersTest();
virtual ~DanglingNodePointersTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class RegisterAndUnregisterWhileEventHanldingTest : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(RegisterAndUnregisterWhileEventHanldingTest);
RegisterAndUnregisterWhileEventHanldingTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2015-01-13 18:37:45 +08:00
class Issue9898 : public EventDispatcherTestDemo
{
public:
CREATE_FUNC(Issue9898);
Issue9898();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::EventListenerCustom* _listener;
2015-01-13 18:37:45 +08:00
};
2013-09-13 16:38:21 +08:00
#endif /* defined(__samples__NewEventDispatcherTest__) */