Skip to content

Commit 126accd

Browse files
committed
add test for UILayout - Scaled Widget - JS
1 parent 792579e commit 126accd

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

tests/js-tests/src/GUITest/UILayoutTest/UILayoutTest.js

+42
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,48 @@ var UILayoutTest_Layout_Relative_Location = UIMainLayer.extend({
406406
}
407407
});
408408

409+
var UILayoutTest_Layout_Scaled_Widget = UIMainLayer.extend({
410+
init: function(){
411+
if (this._super()) {
412+
var widgetSize = this._widget.getContentSize();
413+
414+
// Add the alert
415+
var alert = new ccui.Text("Layout Scaled Widget", "Marker Felt", 20);
416+
alert.setColor(cc.color(159, 168, 176));
417+
alert.setPosition(widgetSize.width / 2.0, widgetSize.height / 2.0 - alert.height * 4.5);
418+
this._mainNode.addChild(alert);
419+
420+
var root = this._mainNode.getChildByTag(81);
421+
var background = root.getChildByName("background_Panel");
422+
423+
// Create the layout
424+
var layout = new ccui.Layout();
425+
layout.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);
426+
layout.setContentSize(280, 150);
427+
var backgroundSize = background.getContentSize();
428+
layout.setPosition((widgetSize.width - backgroundSize.width) / 2.0 + (backgroundSize.width - layout.width) / 2.0,
429+
(widgetSize.height - backgroundSize.height) / 2.0 + (backgroundSize.height - layout.height) / 2.0 );
430+
this._mainNode.addChild(layout);
431+
432+
// center
433+
var imageView_Center1 = new ccui.ImageView("ccs-res/cocosui/scrollviewbg.png");
434+
imageView_Center1.scale = 0.5;
435+
layout.addChild(imageView_Center1);
436+
437+
var imageView_Center2 = new ccui.ImageView("ccs-res/cocosui/scrollviewbg.png");
438+
imageView_Center2.scale = 1.2;
439+
layout.addChild(imageView_Center2);
440+
441+
var imageView_Center3 = new ccui.ImageView("ccs-res/cocosui/scrollviewbg.png");
442+
imageView_Center3.scale = 0.8;
443+
layout.addChild(imageView_Center3);
444+
445+
return true;
446+
}
447+
return false;
448+
}
449+
});
450+
409451
var UILayoutComponentTest = UIMainLayer.extend({
410452
_baseLayer: null,
411453
init: function(){

tests/js-tests/src/GUITest/UISceneManager.js

+6
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@
410410
return new UILayoutTest_Layout_Relative_Location();
411411
}
412412
},
413+
{
414+
title: "UILayoutTest_Layout_Scaled_Widget",
415+
func: function () {
416+
return new UILayoutTest_Layout_Scaled_Widget();
417+
}
418+
},
413419
{
414420
title: "UILayoutComponent_Berth_Test",
415421
func: function () {

0 commit comments

Comments
 (0)