From aff6e7852b2aa6c568a0b64d535ccc902d0b1055 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 20 Jul 2016 19:34:04 -0700 Subject: [PATCH] test case for issue #16113 --- .../RenderTextureTest/RenderTextureTest.cpp | 37 +++++++++++++++++++ .../RenderTextureTest/RenderTextureTest.h | 13 +++++++ 2 files changed, 50 insertions(+) diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp index c5293e0616..97c22d2727 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -12,6 +12,7 @@ RenderTextureTests::RenderTextureTests() ADD_TEST_CASE(RenderTextureTargetNode); ADD_TEST_CASE(SpriteRenderTextureBug); ADD_TEST_CASE(RenderTexturePartTest); + ADD_TEST_CASE(Issue16113Test); }; /** @@ -698,3 +699,39 @@ std::string SpriteRenderTextureBug::subtitle() const { return "Touch the screen. Sprite should appear on under the touch"; } + + +// +// Issue16113Test +// +Issue16113Test::Issue16113Test() +{ + auto s = Director::getInstance()->getWinSize(); + + // Save Image menu + MenuItemFont::setFontSize(16); + auto item1 = MenuItemFont::create("Save Image", [&](Ref* ref){ + auto winSize = Director::getInstance()->getVisibleSize(); + auto text = Label::createWithTTF("hello world", "fonts/Marker Felt.ttf", 40); + text->setTextColor(Color4B::RED); + auto target = RenderTexture::create(winSize.width, winSize.height, Texture2D::PixelFormat::RGBA8888); + target->beginWithClear(0,0,0,0); + text->setPosition(winSize.width / 2,winSize.height/2); + text->Node::visit(); + target->end(); + target->saveToFile("issue16113.png", Image::Format::PNG); + }); + auto menu = Menu::create(item1, nullptr); + this->addChild(menu); + menu->setPosition(s.width/2, s.height/2); +} + +std::string Issue16113Test::title() const +{ + return "Github Issue 16113"; +} + +std::string Issue16113Test::subtitle() const +{ + return "aaa.png file without white border on iOS"; +} diff --git a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h index 8f7a3e4308..97f21a2aa5 100644 --- a/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h +++ b/tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h @@ -142,4 +142,17 @@ public: SimpleSprite* addNewSpriteWithCoords(const cocos2d::Vec2& p); }; +class Issue16113Test : public RenderTextureTest +{ +public: + CREATE_FUNC(Issue16113Test); + Issue16113Test(); + virtual std::string title() const override; + virtual std::string subtitle() const override; + +private: + cocos2d::RenderTexture* _rend; + cocos2d::Sprite* _spriteDraw; +}; + #endif