2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
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"
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(EventDispatcherTests);
|
2013-09-13 16:38:21 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class EventDispatcherTestDemo : public TestCase
|
2013-09-13 16:38:21 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-12-19 05:52:10 +08:00
|
|
|
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);
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-13 16:38:21 +08:00
|
|
|
};
|
|
|
|
|
2013-09-16 16:02:48 +08:00
|
|
|
class FixedPriorityTest : public EventDispatcherTestDemo
|
2013-09-16 15:43:48 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(FixedPriorityTest);
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-16 15:43:48 +08:00
|
|
|
};
|
|
|
|
|
2013-09-18 22:23:02 +08:00
|
|
|
class RemoveListenerWhenDispatching : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveListenerWhenDispatching);
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class CustomEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(CustomEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-09-18 22:23:02 +08:00
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerCustom* _listener;
|
|
|
|
axis::EventListenerCustom* _listener2;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class LabelKeyboardEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(LabelKeyboardEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteAccelerationEventTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(SpriteAccelerationEventTest);
|
2013-09-18 22:23:02 +08:00
|
|
|
virtual void onEnter() override;
|
2013-09-18 22:45:48 +08:00
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-09-18 22:23:02 +08:00
|
|
|
};
|
2013-09-16 15:43:48 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
class RemoveAndRetainNodeTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveAndRetainNodeTest);
|
2013-10-23 16:14:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* _sprite;
|
2013-10-23 16:14:03 +08:00
|
|
|
bool _spriteSaved;
|
|
|
|
};
|
|
|
|
|
2013-11-02 21:47:00 +08:00
|
|
|
class RemoveListenerAfterAddingTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RemoveListenerAfterAddingTest);
|
2013-11-02 21:47:00 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-11-02 21:47:00 +08:00
|
|
|
};
|
|
|
|
|
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;
|
2013-12-22 02:55:16 +08:00
|
|
|
virtual void onExit() override;
|
|
|
|
|
|
|
|
virtual void update(float dt) override;
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
void onEvent1(axis::EventCustom* event);
|
|
|
|
void onEvent2(axis::EventCustom* event);
|
2013-12-21 16:56:28 +08:00
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
protected:
|
2013-12-22 02:55:16 +08:00
|
|
|
int _count1, _count2, _count3, _count4;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Label *_label1, *_label2, *_label3, *_label4;
|
|
|
|
axis::EventListenerCustom *_event1, *_event2, *_event3, *_event4;
|
2013-12-21 16:56:28 +08:00
|
|
|
};
|
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
class GlobalZTouchTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(GlobalZTouchTest);
|
|
|
|
GlobalZTouchTest();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
virtual void update(float dt) override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-01-21 10:23:05 +08:00
|
|
|
protected:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* _sprite;
|
2014-01-21 10:23:05 +08:00
|
|
|
float _accum;
|
|
|
|
};
|
|
|
|
|
2014-01-27 16:30:20 +08:00
|
|
|
class StopPropagationTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(StopPropagationTest);
|
|
|
|
StopPropagationTest();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-01-27 16:30:20 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-01-27 16:30:20 +08:00
|
|
|
protected:
|
2022-07-11 17:50:21 +08:00
|
|
|
bool isPointInNode(axis::Vec2 pt, axis::Node* node);
|
|
|
|
bool isPointInTopHalfAreaOfScreen(axis::Vec2 pt);
|
2014-01-27 16:30:20 +08:00
|
|
|
};
|
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
class PauseResumeTargetTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(PauseResumeTargetTest);
|
|
|
|
PauseResumeTargetTest();
|
|
|
|
virtual ~PauseResumeTargetTest();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-03-02 15:54:36 +08:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2017-05-19 14:03:51 +08:00
|
|
|
class PauseResumeTargetTest2 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(PauseResumeTargetTest2);
|
|
|
|
PauseResumeTargetTest2();
|
|
|
|
virtual ~PauseResumeTargetTest2();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* _touchableSprite;
|
|
|
|
axis::MenuItemFont* _itemPauseTouch;
|
|
|
|
axis::MenuItemFont* _itemResumeTouch;
|
|
|
|
axis::MenuItemFont* _itemAddToScene;
|
|
|
|
axis::MenuItemFont* _itemRemoveFromScene;
|
2017-05-19 14:03:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class PauseResumeTargetTest3 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(PauseResumeTargetTest3);
|
|
|
|
PauseResumeTargetTest3();
|
|
|
|
virtual ~PauseResumeTargetTest3();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
|
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Sprite* _touchableSprite;
|
2017-05-19 14:03:51 +08:00
|
|
|
};
|
|
|
|
|
2014-02-28 15:46:48 +08:00
|
|
|
class Issue4129 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue4129);
|
|
|
|
Issue4129();
|
|
|
|
virtual ~Issue4129();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-02-28 15:46:48 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-02-28 15:46:48 +08:00
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerCustom* _customlistener;
|
2014-02-28 15:46:48 +08:00
|
|
|
bool _bugFixed;
|
|
|
|
};
|
|
|
|
|
2014-03-02 16:22:57 +08:00
|
|
|
class Issue4160 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue4160);
|
|
|
|
Issue4160();
|
|
|
|
virtual ~Issue4160();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-03-02 16:22:57 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-03-02 16:22:57 +08:00
|
|
|
private:
|
|
|
|
};
|
2014-02-28 15:46:48 +08:00
|
|
|
|
2014-03-28 07:38:06 +08:00
|
|
|
class DanglingNodePointersTest : public EventDispatcherTestDemo
|
2014-03-28 07:00:21 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-03-28 07:38:06 +08:00
|
|
|
CREATE_FUNC(DanglingNodePointersTest);
|
|
|
|
DanglingNodePointersTest();
|
|
|
|
virtual ~DanglingNodePointersTest();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-03-28 07:00:21 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2014-04-08 07:46:03 +08:00
|
|
|
class RegisterAndUnregisterWhileEventHanldingTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(RegisterAndUnregisterWhileEventHanldingTest);
|
|
|
|
RegisterAndUnregisterWhileEventHanldingTest();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-04-08 07:46:03 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2016-09-21 11:32:33 +08:00
|
|
|
class WindowEventsTest : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(WindowEventsTest);
|
|
|
|
WindowEventsTest();
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2015-07-01 14:39:35 +08:00
|
|
|
class Issue8194 : public EventDispatcherTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(Issue8194);
|
|
|
|
Issue8194();
|
|
|
|
virtual ~Issue8194();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-01 14:39:35 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-01 14:39:35 +08:00
|
|
|
private:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerCustom* _listener;
|
2015-07-01 14:39:35 +08:00
|
|
|
};
|
|
|
|
|
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:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventListenerCustom* _listener;
|
2015-01-13 18:37:45 +08:00
|
|
|
};
|
|
|
|
|
2013-09-13 16:38:21 +08:00
|
|
|
#endif /* defined(__samples__NewEventDispatcherTest__) */
|