Skip to content
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

Anvil testcase for ui_label testsuite #4787

Merged
merged 3 commits into from Nov 11, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
157 changes: 157 additions & 0 deletions support/anvil/configSet/Resources/suites/ui_label.js
@@ -0,0 +1,157 @@
/*
* Appcelerator Titanium Mobile
* Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

module.exports = new function() {
var finish;
var valueOf;
this.init = function(testUtils) {
finish = testUtils.finish;
valueOf = testUtils.valueOf;
}

this.name = "ui_label";
this.tests = [
{name: "labelHeight"},
{name: "labelTextid"},
{name: "labelPostlayout"},
{name: "labelBackground"}
]

//TIMOB-4123
this.labelHeight = function(testRun) {
var label = Ti.UI.createLabel({
top:10,
right:10,
height : 'auto',
width:'auto',
borderColor:'red'
});
valueOf(testRun, label.getTop()).shouldBe(10);
valueOf(testRun, label.getHeight()).shouldBe('auto');
valueOf(testRun, label.getWidth()).shouldBe('auto');
valueOf(testRun, label.getBorderColor()).shouldBe('red');
valueOf(testRun, label.getRight()).shouldBe('10');

finish(testRun);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

label is never added to the window. The test creates a proxy and reads value back, is that the purpose of the test . If so, why do we need a window ?


//TIMOB-9912
this.labelTextid=function(testRun){
var win = Titanium.UI.createWindow();
var view = Ti.UI.createView({
top:0,
height:80,
right:0,
left:0
});
var label = Ti.UI.createLabel({
font:{fontSize:30,fontFamily:'Helvetica Neue'},
color:'red',
left:0,
width:'100%',
textid:'new',
right:'10%',
textid:'check'
});
view.add(label);
label.textid='new';
valueOf(testRun, label.textid).shouldBe('new');
label.textid='new';
valueOf(testRun, label.textid).shouldBe('new');
label.textid='new';
valueOf(testRun, label.textid).shouldBe('new');

finish(testRun);
win.add(view)
win.open();
}

//TIMOB-9994
this.labelPostlayout=function(testRun){
var win = Ti.UI.createWindow({
layout : 'vertical'
});
var postlayoutStatus=false;
var label = Ti.UI.createLabel({
text : "hello",
left : 0,
top:10,
color:'red',
width : Ti.UI.SIZE,
height : Ti.UI.SIZE
});
label.addEventListener("postlayout", function(e) {
if(postlayoutStatus){
valueOf(testRun, label.text).shouldBe('newText');
finish(testRun);
}
else {
valueOf(testRun, label.text).shouldBe('hello');
valueOf(testRun, label.left).shouldBe(0);
valueOf(testRun, label.top).shouldBe(10);
valueOf(testRun, label.color).shouldBe('red');
}
})
setTimeout(function(){
label.text = "newText";
postlayoutStatus=true;
},2000);
win.add(label);
win.open();
}

//TIMOB-8955 & TIMOB-8246
this.labelBackground=function(testRun){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ticket number

var win = Ti.UI.createWindow();
win.open();
var signonview = Ti.UI.createView({
top:10,
left:10,
right:10
});
var label = Ti.UI.createLabel({
text:'Appcelerator',
backgroundGradient:{
type:'linear',
colors:['red','blue'],
startPoint:{x:0,y:0},
endPoint:{x:0,y:45},
backFillStart:true
},
shadowColor:'green',
shadowOffset:{x:0,y:1},
top:0,
height:45,
width:290,
textAlign:'center',
backgroundColor: 'red'
});
label.addEventListener("postlayout", function(){
valueOf(testRun,label.getBackgroundGradient().type).shouldBe('linear');
valueOf(testRun,label.getBackgroundGradient().backFillStart).shouldBeTrue();
valueOf(testRun,label.getBackgroundGradient().startPoint.x).shouldBe(0);
valueOf(testRun,label.getBackgroundGradient().startPoint.y).shouldBe(0);
valueOf(testRun,label.getBackgroundGradient().endPoint.x).shouldBe(0);
valueOf(testRun,label.getBackgroundGradient().endPoint.y).shouldBe(45);

valueOf(testRun,label.shadowOffset.x).shouldBe(0);
valueOf(testRun,label.shadowOffset.y).shouldBe(1);
valueOf(testRun,label.getTop()).shouldBe(0);
valueOf(testRun,label.getTextAlign()).shouldBe('center');
valueOf(testRun, label.getText()).shouldBe('Appcelerator');
valueOf(testRun, label.getBackgroundColor()).shouldBe('red');
valueOf(testRun,label.getHeight()).shouldBe(45);
valueOf(testRun,label.getWidth()).shouldBe(290);

finish(testRun);
})
valueOf(testRun, function(){
signonview.add(label);
}).shouldNotThrowException();
win.add(signonview);
}
}
1 change: 1 addition & 0 deletions support/anvil/configSet/configs/default/app.js
Expand Up @@ -18,6 +18,7 @@ var suites = [
{name: "json"},
{name: "jss"},
{name: "kroll"},
{name: "ui_label"},
{name: "locale"},
{name: "media/media"},
{name: "network_httpclient"},
Expand Down