Skip to content

Commit 6054dc0

Browse files
LiamLiam
Liam
authored and
Liam
committed
update for ui test
1 parent 9ff7069 commit 6054dc0

File tree

16 files changed

+163
-5
lines changed

16 files changed

+163
-5
lines changed

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ bool UIButtonTest::init()
7575

7676
_uiLayer->addChild(imageView);
7777

78+
_button = button;
7879

80+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
81+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
82+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIButtonTest::printCheckBoxResources, this));
83+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
84+
auto pMenu1 = Menu::create(item1, nullptr);
85+
pMenu1->setPosition(Vec2(0, 0));
86+
this->addChild(pMenu1, 10);
7987

8088
return true;
8189
}
@@ -117,6 +125,16 @@ void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
117125
}
118126
}
119127

128+
void UIButtonTest::printCheckBoxResources(cocos2d::Ref* sender)
129+
{
130+
cocos2d::ResouceData normalFileName = _button->getNormalFile();
131+
CCLOG("normalFileName Name : %s, Type: %d", normalFileName.file.c_str(), normalFileName.type);
132+
cocos2d::ResouceData clickedFileName = _button->getPressedFile();
133+
CCLOG("clickedFileName Name : %s, Type: %d", clickedFileName.file.c_str(), clickedFileName.type);
134+
cocos2d::ResouceData disabledFileName = _button->getDisabledFile();
135+
CCLOG("disabledFileName Name : %s, Type: %d", disabledFileName.file.c_str(), disabledFileName.type);
136+
}
137+
120138

121139
// UIButtonTest_Scale9
122140
UIButtonTest_Scale9::UIButtonTest_Scale9()

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class UIButtonTest : public UIScene
4040
virtual bool init() override;
4141
void touchEvent(cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type);
4242

43+
void printCheckBoxResources(cocos2d::Ref* sender);
4344
protected:
4445
cocos2d::ui::Text* _displayValueLabel;
46+
cocos2d::ui::Button* _button;
4547
};
4648

4749
class UIButtonTest_Scale9 : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@ bool UICheckBoxTest::init()
4040
_uiLayer->addChild(alert);
4141

4242
// Create the checkbox
43-
CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png",
43+
_checkBox = CheckBox::create("cocosui/check_box_normal.png",
4444
"cocosui/check_box_normal_press.png",
4545
"cocosui/check_box_active.png",
4646
"cocosui/check_box_normal_disable.png",
4747
"cocosui/check_box_active_disable.png");
48-
checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
48+
_checkBox->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
4949

50-
checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this));
51-
_uiLayer->addChild(checkBox);
50+
_checkBox->addEventListener(CC_CALLBACK_2(UICheckBoxTest::selectedEvent, this));
51+
_uiLayer->addChild(_checkBox);
52+
53+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
54+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
55+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UICheckBoxTest::printCheckBoxResources, this));
56+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
57+
auto pMenu1 = Menu::create(item1, nullptr);
58+
pMenu1->setPosition(Vec2(0, 0));
59+
this->addChild(pMenu1, 10);
5260

5361
return true;
5462
}
@@ -73,6 +81,20 @@ void UICheckBoxTest::selectedEvent(Ref* pSender,CheckBox::EventType type)
7381

7482
}
7583

84+
void UICheckBoxTest::printCheckBoxResources(cocos2d::Ref* sender)
85+
{
86+
cocos2d::ResouceData backGroundFileName = _checkBox->getBackNormalFile();
87+
CCLOG("backGroundFile Name : %s, Type: %d", backGroundFileName.file.c_str(),backGroundFileName.type);
88+
cocos2d::ResouceData backGroundSelectedFileName = _checkBox->getBackPressedFile();
89+
CCLOG("backGroundSelectedFile Name : %s, Type: %d", backGroundSelectedFileName.file.c_str(), backGroundSelectedFileName.type);
90+
cocos2d::ResouceData backGroundDisabledFileName = _checkBox->getBackDisabledFile();
91+
CCLOG("backGroundDisabledFile Name : %s, Type: %d", backGroundDisabledFileName.file.c_str(), backGroundDisabledFileName.type);
92+
cocos2d::ResouceData frontCrossFileName = _checkBox->getCrossNormalFile();
93+
CCLOG("frontCrossFile Name : %s, Type: %d", frontCrossFileName.file.c_str(), frontCrossFileName.type);
94+
cocos2d::ResouceData frontCrossDisabledFileName = _checkBox->getCrossDisabeldFile();
95+
CCLOG("frontCrossDisabledFile Name : %s, Type: %d", frontCrossDisabledFileName.file.c_str(), frontCrossDisabledFileName.type);
96+
}
97+
7698

7799
// UICheckBoxDefaultBehaviorTest
78100
UICheckBoxDefaultBehaviorTest::UICheckBoxDefaultBehaviorTest()

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class UICheckBoxTest : public UIScene
4040
virtual bool init() override;
4141
void selectedEvent(cocos2d::Ref* sender,cocos2d::ui::CheckBox::EventType type);
4242

43+
void printCheckBoxResources(cocos2d::Ref* sender);
4344
protected:
4445
cocos2d::ui::Text* _displayValueLabel;
46+
cocos2d::ui::CheckBox* _checkBox;
4547
};
4648

4749
class UICheckBoxDefaultBehaviorTest : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,26 @@ bool UIImageViewTest::init()
3434

3535
_uiLayer->addChild(imageView);
3636

37-
37+
_image = imageView;
38+
39+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
40+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
41+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UIImageViewTest::printCheckBoxResources, this));
42+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
43+
auto pMenu1 = Menu::create(item1, nullptr);
44+
pMenu1->setPosition(Vec2(0, 0));
45+
this->addChild(pMenu1, 10);
3846

3947
return true;
4048
}
4149
return false;
4250
}
4351

52+
void UIImageViewTest::printCheckBoxResources(cocos2d::Ref* sender)
53+
{
54+
cocos2d::ResouceData textureFile = _image->getRenderFile();
55+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
56+
}
4457

4558
// UIImageViewTest_Scale9
4659

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIImageViewTest/UIImageViewTest.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class UIImageViewTest : public UIScene
3535
CREATE_FUNC(UIImageViewTest);
3636

3737
virtual bool init() override;
38+
39+
void printCheckBoxResources(cocos2d::Ref* sender);
40+
protected:
41+
cocos2d::ui::ImageView* _image;
3842
};
3943

4044
class UIImageViewTest_Scale9 : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,28 @@ bool UILayoutTest_BackGroundImage::init()
264264
button_scale9->getContentSize().height / 2.0f));
265265

266266
layout->addChild(button_scale9);
267+
268+
_layout = layout;
269+
270+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
271+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
272+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILayoutTest_BackGroundImage::printCheckBoxResources, this));
273+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
274+
auto pMenu1 = Menu::create(item1, nullptr);
275+
pMenu1->setPosition(Vec2(0, 0));
276+
this->addChild(pMenu1, 10);
267277

268278
return true;
269279
}
270280
return false;
271281
}
272282

283+
void UILayoutTest_BackGroundImage::printCheckBoxResources(cocos2d::Ref* sender)
284+
{
285+
cocos2d::ResouceData textureFile = _layout->getRenderFile();
286+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
287+
}
288+
273289
// UILayoutTest_BackGroundImage_Scale9
274290

275291
UILayoutTest_BackGroundImage_Scale9::UILayoutTest_BackGroundImage_Scale9()

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILayoutTest/UILayoutTest.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class UILayoutTest_BackGroundImage : public UIScene
6767
virtual bool init() override;
6868

6969
CREATE_FUNC(UILayoutTest_BackGroundImage);
70+
71+
void printCheckBoxResources(cocos2d::Ref* sender);
72+
protected:
73+
cocos2d::ui::Layout* _layout;
7074
};
7175

7276
class UILayoutTest_BackGroundImage_Scale9 : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ bool UILoadingBarTest_Left::init()
7878
_uiLayer->addChild(loadingBar,1);
7979
_uiLayer->addChild(loadingBarCopy,2);
8080
_uiLayer->addChild(button);
81+
82+
_loadingBar = loadingBar;
83+
84+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
85+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
86+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UILoadingBarTest_Left::printCheckBoxResources, this));
87+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
88+
auto pMenu1 = Menu::create(item1, nullptr);
89+
pMenu1->setPosition(Vec2(0, 0));
90+
this->addChild(pMenu1, 10);
8191

8292
return true;
8393
}
@@ -97,6 +107,12 @@ void UILoadingBarTest_Left::update(float delta)
97107
loadingBarCopy->setPercent(_count);
98108
}
99109

110+
void UILoadingBarTest_Left::printCheckBoxResources(cocos2d::Ref* sender)
111+
{
112+
cocos2d::ResouceData textureFile = _loadingBar->getRenderFile();
113+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
114+
}
115+
100116
// UILoadingBarTest_Right
101117

102118
UILoadingBarTest_Right::UILoadingBarTest_Right()

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UILoadingBarTest/UILoadingBarTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class UILoadingBarTest_Left : public UIScene
3838
~UILoadingBarTest_Left();
3939
virtual bool init() override;
4040
void update(float delta)override;
41+
void printCheckBoxResources(cocos2d::Ref* sender);
4142

4243
protected:
4344
int _count;
45+
cocos2d::ui::LoadingBar* _loadingBar;
4446
};
4547

4648
class UILoadingBarTest_Right : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ bool UISliderTest::init()
5353
slider->addEventListener(CC_CALLBACK_2(UISliderTest::sliderEvent, this));
5454
_uiLayer->addChild(slider);
5555

56+
_slider = slider;
57+
58+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
59+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
60+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UISliderTest::printCheckBoxResources, this));
61+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
62+
auto pMenu1 = Menu::create(item1, nullptr);
63+
pMenu1->setPosition(Vec2(0, 0));
64+
this->addChild(pMenu1, 10);
5665

5766
return true;
5867
}
@@ -69,6 +78,19 @@ void UISliderTest::sliderEvent(Ref *pSender, Slider::EventType type)
6978
_displayValueLabel->setString(StringUtils::format("Percent %f", 10000.0 * percent / maxPercent));
7079
}
7180
}
81+
void UISliderTest::printCheckBoxResources(cocos2d::Ref* sender)
82+
{
83+
cocos2d::ResouceData textureFile = _slider->getBackFile();
84+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
85+
cocos2d::ResouceData progressBarTextureFile = _slider->getProgressBarFile();
86+
CCLOG("progressBarTextureFile Name : %s, Type: %d", progressBarTextureFile.file.c_str(), progressBarTextureFile.type);
87+
cocos2d::ResouceData slidBallNormalTextureFile = _slider->getBallNormalFile();
88+
CCLOG("slidBallNormalTextureFile Name : %s, Type: %d", slidBallNormalTextureFile.file.c_str(), slidBallNormalTextureFile.type);
89+
cocos2d::ResouceData slidBallPressedTextureFile = _slider->getBallPressedFile();
90+
CCLOG("slidBallPressedTextureFile Name : %s, Type: %d", slidBallPressedTextureFile.file.c_str(), slidBallPressedTextureFile.type);
91+
cocos2d::ResouceData slidBallDisabledTextureFile = _slider->getBallDisabeldFile();
92+
CCLOG("slidBallDisabledTextureFile Name : %s, Type: %d", slidBallDisabledTextureFile.file.c_str(), slidBallDisabledTextureFile.type);
93+
}
7294

7395
// UISliderTest_Scale9
7496

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ class UISliderTest : public UIScene
3838
~UISliderTest();
3939
virtual bool init() override;
4040
void sliderEvent(cocos2d::Ref* sender, cocos2d::ui::Slider::EventType type);
41+
void printCheckBoxResources(cocos2d::Ref* sender);
4142

4243
protected:
4344
cocos2d::ui::TextBMFont* _displayValueLabel;
45+
cocos2d::ui::Slider* _slider;
4446
};
4547

4648
class UISliderTest_Scale9 : public UIScene

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,21 @@ bool UITextAtlasTest::init()
3434
textAtlas->setPosition(Vec2((widgetSize.width) / 2, widgetSize.height / 2.0f));
3535
_uiLayer->addChild(textAtlas);
3636

37+
_textAtlas = textAtlas;
38+
39+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
40+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
41+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextAtlasTest::printCheckBoxResources, this));
42+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
43+
auto pMenu1 = Menu::create(item1, nullptr);
44+
pMenu1->setPosition(Vec2(0, 0));
45+
this->addChild(pMenu1, 10);
3746
return true;
3847
}
3948
return false;
4049
}
50+
void UITextAtlasTest::printCheckBoxResources(cocos2d::Ref* sender)
51+
{
52+
cocos2d::ResouceData textureFile = _textAtlas->getRenderFile();
53+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
54+
}

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextAtlasTest/UITextAtlasTest.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class UITextAtlasTest : public UIScene
1313
CREATE_FUNC(UITextAtlasTest);
1414

1515
virtual bool init() override;
16+
void printCheckBoxResources(cocos2d::Ref* sender);
17+
protected:
18+
cocos2d::ui::TextAtlas* _textAtlas;
1619
};
1720

1821
#endif /* defined(__TestCpp__UITextAtlasTest__) */

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,22 @@ bool UITextBMFontTest::init()
2525
textBMFont->setPosition(Vec2(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getContentSize().height / 8.0f));
2626
_uiLayer->addChild(textBMFont);
2727

28+
_textBMFont = textBMFont;
29+
30+
TTFConfig ttfConfig("fonts/arial.ttf", 15);
31+
auto label1 = Label::createWithTTF(ttfConfig, "Print Resources");
32+
auto item1 = MenuItemLabel::create(label1, CC_CALLBACK_1(UITextBMFontTest::printCheckBoxResources, this));
33+
item1->setPosition(Vec2(VisibleRect::left().x + 60, VisibleRect::bottom().y + item1->getContentSize().height * 3));
34+
auto pMenu1 = Menu::create(item1, nullptr);
35+
pMenu1->setPosition(Vec2(0, 0));
36+
this->addChild(pMenu1, 10);
37+
2838
return true;
2939
}
3040
return false;
3141
}
42+
void UITextBMFontTest::printCheckBoxResources(cocos2d::Ref* sender)
43+
{
44+
cocos2d::ResouceData textureFile = _textBMFont->getRenderFile();
45+
CCLOG("textureFile Name : %s, Type: %d", textureFile.file.c_str(), textureFile.type);
46+
}

tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class UITextBMFontTest : public UIScene
3535
CREATE_FUNC(UITextBMFontTest)
3636

3737
virtual bool init() override;
38+
void printCheckBoxResources(cocos2d::Ref* sender);
39+
protected:
40+
cocos2d::ui::TextBMFont* _textBMFont;
3841
};
3942

4043
#endif /* defined(__TestCpp__UITextBMFontTest__) */

0 commit comments

Comments
 (0)