From ed30993f59c982a00f29cc3421e858968675ea94 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Tue, 28 Jun 2016 17:08:56 -0700 Subject: [PATCH] fix: add testcase for issue #14050 fix --- .../ActionManagerTest/ActionManagerTest.cpp | 36 +++++++++++++++++++ .../ActionManagerTest/ActionManagerTest.h | 10 ++++++ 2 files changed, 46 insertions(+) diff --git a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp index d8f0b9f4aa..1481c890cc 100644 --- a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -20,6 +20,7 @@ ActionManagerTests::ActionManagerTests() ADD_TEST_CASE(StopAllActionsTest); ADD_TEST_CASE(StopActionsByFlagsTest); ADD_TEST_CASE(ResumeTest); + ADD_TEST_CASE(Issue14050Test); } //------------------------------------------------------------------ @@ -342,3 +343,38 @@ std::string StopActionsByFlagsTest::subtitle() const { return "Stop All Actions By Flags Test"; } + +//------------------------------------------------------------------ +// +// Issue14050Test +// +//------------------------------------------------------------------ +class SpriteIssue14050: public Sprite +{ +public: + SpriteIssue14050() + { + log("SpriteIssue14050::constructor"); + } + virtual ~SpriteIssue14050() + { + log("SpriteIssue14050::destructor"); + } +}; + +void Issue14050Test::onEnter() +{ + ActionManagerTest::onEnter(); + + auto sprite = new (std::nothrow) SpriteIssue14050; + sprite->initWithFile("Images/grossini.png"); + sprite->autorelease(); + + auto move = MoveBy::create(2, Vec2(100, 100)); + sprite->runAction(move); +} + +std::string Issue14050Test::subtitle() const +{ + return "Issue14050. Sprite should not leak."; +} diff --git a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.h b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.h index a63b0a7e39..feafa16857 100644 --- a/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.h +++ b/tests/cpp-tests/Classes/ActionManagerTest/ActionManagerTest.h @@ -95,4 +95,14 @@ protected: const unsigned int kRepeatForeverFlag = 0x08; // You don't need this for the test, but it's for demonstration how to activate several flags on an action. }; +class Issue14050Test : public ActionManagerTest +{ +public: + CREATE_FUNC(Issue14050Test); + + virtual std::string subtitle() const override; + virtual void onEnter() override; +protected: +}; + #endif