diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp index 8a32353e17..0c75cc28e5 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp @@ -75,7 +75,15 @@ bool UIButtonTest::init() _uiLayer->addChild(imageView); + _button = button; + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -117,6 +125,16 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type) } } +void UIButtonTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData normalFileName = _button->getNormalFile(); + CCLOG("normalFileName Name : %s, Type: %d", normalFileName.file.c_str(), normalFileName.type); + cocos2d::ResourceData clickedFileName = _button->getPressedFile(); + CCLOG("clickedFileName Name : %s, Type: %d", clickedFileName.file.c_str(), clickedFileName.type); + cocos2d::ResourceData disabledFileName = _button->getDisabledFile(); + CCLOG("disabledFileName Name : %s, Type: %d", disabledFileName.file.c_str(), disabledFileName.type); +} + // UIButtonTest_Scale9 UIButtonTest_Scale9::UIButtonTest_Scale9() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h index c52d86f2f2..8a34c6493d 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h @@ -40,8 +40,10 @@ public: virtual bool init() override; void touchEvent(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; + cocos2d::ui::Button* _button; }; class UIButtonTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp index 746705dc41..e750b2bed9 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp @@ -40,15 +40,23 @@ bool UICheckBoxTest::init() _uiLayer->addChild(alert); // Create the checkbox - CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png", + _checkBox = CheckBox::create("cocosui/check_box_normal.png", "cocosui/check_box_normal_press.png", "cocosui/check_box_active.png", "cocosui/check_box_normal_disable.png", "cocosui/check_box_active_disable.png"); - checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); + _checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f)); - checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); - _uiLayer->addChild(checkBox); + _checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this)); + _uiLayer->addChild(_checkBox); + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -73,6 +81,20 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type) } +void UICheckBoxTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData backGroundFileName = _checkBox->getBackNormalFile(); + CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type); + cocos2d::ResourceData backGroundSelectedFileName = _checkBox->getBackPressedFile(); + CCLOG("backGroundSelectedFile Name : %s, Type: %d", backGroundSelectedFileName.file.c_str(), backGroundSelectedFileName.type); + cocos2d::ResourceData backGroundDisabledFileName = _checkBox->getBackDisabledFile(); + CCLOG("backGroundDisabledFile Name : %s, Type: %d", backGroundDisabledFileName.file.c_str(), backGroundDisabledFileName.type); + cocos2d::ResourceData frontCrossFileName = _checkBox->getCrossNormalFile(); + CCLOG("frontCrossFile Name : %s, Type: %d", frontCrossFileName.file.c_str(), frontCrossFileName.type); + cocos2d::ResourceData frontCrossDisabledFileName = _checkBox->getCrossDisabledFile(); + CCLOG("frontCrossDisabledFile Name : %s, Type: %d", frontCrossDisabledFileName.file.c_str(), frontCrossDisabledFileName.type); +} + // UICheckBoxDefaultBehaviorTest UICheckBoxDefaultBehaviorTest::UICheckBoxDefaultBehaviorTest() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h index 061f277c5b..d79722f22c 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h @@ -40,8 +40,10 @@ public: virtual bool init() override; void selectedEvent(cocos2d::Ref* sender,cocos2d::ui::CheckBox::EventType type); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::Text* _displayValueLabel; + cocos2d::ui::CheckBox* _checkBox; }; class UICheckBoxDefaultBehaviorTest : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp index fb941b2f56..ecc7dd380f 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp @@ -35,13 +35,26 @@ bool UIImageViewTest::init() _uiLayer->addChild(imageView); - + _image = imageView; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UIImageViewTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _image->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} // UIImageViewTest_Scale9 diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h index b3cde4867b..6672294576 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h @@ -35,6 +35,10 @@ public: CREATE_FUNC(UIImageViewTest); virtual bool init() override; + + void printWidgetResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::ImageView* _image; }; class UIImageViewTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp index 02cdb5d4d5..89a450d0d0 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp @@ -264,12 +264,28 @@ bool UILayoutTest_BackGroundImage::init() button_scale9->getContentSize().height / 2.0f)); layout->addChild(button_scale9); + + _layout = layout; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UILayoutTest_BackGroundImage::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _layout->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} + // UILayoutTest_BackGroundImage_Scale9 UILayoutTest_BackGroundImage_Scale9::UILayoutTest_BackGroundImage_Scale9() diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h index 65336919c9..c5d8a77319 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h @@ -67,6 +67,10 @@ public: virtual bool init() override; CREATE_FUNC(UILayoutTest_BackGroundImage); + + void printWidgetResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::Layout* _layout; }; class UILayoutTest_BackGroundImage_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp index ad20c3c2a4..ecd6e31722 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp @@ -79,6 +79,16 @@ bool UILoadingBarTest_Left::init() _uiLayer->addChild(loadingBar,1); _uiLayer->addChild(loadingBarCopy,2); _uiLayer->addChild(button); + + _loadingBar = loadingBar; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -98,6 +108,12 @@ void UILoadingBarTest_Left::update(float delta) loadingBarCopy->setPercent(_count); } +void UILoadingBarTest_Left::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _loadingBar->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} + // UILoadingBarTest_Right UILoadingBarTest_Right::UILoadingBarTest_Right() @@ -493,4 +509,4 @@ void UILoadingBarIssue12249::update(float delta) LoadingBar* loadingBarCopy = static_cast(_uiLayer->getChildByTag(1)); loadingBar->setPercent(_count); loadingBarCopy->setPercent(_count); -} \ No newline at end of file +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h index 49d1eeb744..b405d34bf2 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h @@ -38,9 +38,11 @@ public: ~UILoadingBarTest_Left(); virtual bool init() override; void update(float delta)override; + void printWidgetResources(cocos2d::Ref* sender); protected: int _count; + cocos2d::ui::LoadingBar* _loadingBar; }; class UILoadingBarTest_Right : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp index 36c04482fc..80980203fc 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp @@ -54,6 +54,15 @@ bool UISliderTest::init() slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this)); _uiLayer->addChild(slider); + _slider = slider; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } @@ -70,6 +79,19 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type) _displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent)); } } +void UISliderTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _slider->getBackFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); + cocos2d::ResourceData progressBarTextureFile = _slider->getProgressBarFile(); + CCLOG("progressBarTextureFile Name : %s, Type: %d", progressBarTextureFile.file.c_str(), progressBarTextureFile.type); + cocos2d::ResourceData slidBallNormalTextureFile = _slider->getBallNormalFile(); + CCLOG("slidBallNormalTextureFile Name : %s, Type: %d", slidBallNormalTextureFile.file.c_str(), slidBallNormalTextureFile.type); + cocos2d::ResourceData slidBallPressedTextureFile = _slider->getBallPressedFile(); + CCLOG("slidBallPressedTextureFile Name : %s, Type: %d", slidBallPressedTextureFile.file.c_str(), slidBallPressedTextureFile.type); + cocos2d::ResourceData slidBallDisabledTextureFile = _slider->getBallDisabledFile(); + CCLOG("slidBallDisabledTextureFile Name : %s, Type: %d", slidBallDisabledTextureFile.file.c_str(), slidBallDisabledTextureFile.type); +} // UISliderTest_Scale9 diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h index 3e65577dd0..4f504c183b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h @@ -38,9 +38,11 @@ public: ~UISliderTest(); virtual bool init() override; void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type); + void printWidgetResources(cocos2d::Ref* sender); protected: cocos2d::ui::TextBMFont* _displayValueLabel; + cocos2d::ui::Slider* _slider; }; class UISliderTest_Scale9 : public UIScene diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp index 6a09be81f8..fa90a3ff43 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp @@ -34,7 +34,21 @@ bool UITextAtlasTest::init() textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f)); _uiLayer->addChild(textAtlas); + _textAtlas = textAtlas; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); return true; } return false; } +void UITextAtlasTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _textAtlas->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h index 2eef8b80c0..bc7c03aa53 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h @@ -13,6 +13,9 @@ public: CREATE_FUNC(UITextAtlasTest); virtual bool init() override; + void printWidgetResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::TextAtlas* _textAtlas; }; #endif /* defined(__TestCpp__UITextAtlasTest__) */ diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp index 211132dc02..902d724d79 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp @@ -25,7 +25,22 @@ bool UITextBMFontTest::init() textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getContentSize().height / 8.0f)); _uiLayer->addChild(textBMFont); + _textBMFont = textBMFont; + + TTFConfig ttfConfig("fonts/arial.ttf", 15); + auto label1 = Label::createWithTTF(ttfConfig, "Print Resources"); + auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printWidgetResources, this)); + item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3)); + auto pMenu1 = Menu::create(item1, nullptr); + pMenu1->setPosition(Vec2(0, 0)); + this->addChild(pMenu1, 10); + return true; } return false; } +void UITextBMFontTest::printWidgetResources(cocos2d::Ref* sender) +{ + cocos2d::ResourceData textureFile = _textBMFont->getRenderFile(); + CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type); +} diff --git a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h index c3a228a695..795e7bd60b 100644 --- a/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h +++ b/tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h @@ -35,6 +35,9 @@ public: CREATE_FUNC(UITextBMFontTest) virtual bool init() override; + void printWidgetResources(cocos2d::Ref* sender); +protected: + cocos2d::ui::TextBMFont* _textBMFont; }; #endif /* defined(__TestCpp__UITextBMFontTest__) */