Skip to content

test case for issue #16113 #16180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RenderTextureTests::RenderTextureTests()
ADD_TEST_CASE(RenderTextureTargetNode);
ADD_TEST_CASE(SpriteRenderTextureBug);
ADD_TEST_CASE(RenderTexturePartTest);
ADD_TEST_CASE(Issue16113Test);
};

/**
Expand Down Expand Up @@ -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";
}
13 changes: 13 additions & 0 deletions tests/cpp-tests/Classes/RenderTextureTest/RenderTextureTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,17 @@ class SpriteRenderTextureBug : public RenderTextureTest
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