Skip to content

Instantly share code, notes, and snippets.

@mogya
Created Jun 30, 2011
Embed
What would you like to do?
A test library for Titanium Mobile
var win = Titanium.UI.currentWindow;
var view = Ti.UI.createView();
view.layout = 'vertical';
function addTest(title,action){
var button = Ti.UI.createButton({
title:title,
width:300,
height:30
});
button.addEventListener('click',function(){
Ti.API.info('start:'+title);
if(action) {
action();
}
Ti.API.info('end:'+title);
});
view.add(button);
}
function addSpacer(){
var spacer = Ti.UI.createView({
width:200,
height:10
});
view.add(spacer);
}
function musttrue(assert,title){
if (assert){
Ti.API.info('OK:'+title);
}else{
Ti.API.error('NG:'+title);
}
}
function mustequal(value,expect,title){
if (value==expect){
Ti.API.info('OK:'+title);
}else{
Ti.API.error('NG:'+title);
Ti.API.error('value:'+value);
Ti.API.error('expect:'+expect);
}
}
function mustdifferent(value,expect,title){
if (value!=expect){
Ti.API.info('OK:'+title);
}else{
Ti.API.error('NG:'+title);
Ti.API.error('value:'+value);
Ti.API.error('expect:'+expect);
}
}
win.add(view);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment