Created
April 19, 2012 13:47
-
-
Save pec1985/2421069 to your computer and use it in GitHub Desktop.
Memory Leak Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var TabGroup = require('tabgroup'); | |
TabGroup.open() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var W = require('testwindows'); | |
function TabGroup(){ | |
var self = {}; | |
var root = W.RootWindow(); | |
var tabgroup = Ti.UI.createTabGroup(); | |
var tab = Ti.UI.createTab({ | |
title:'Memory Leak', | |
icon:'KS_nav_views.png', | |
window: root.Window | |
}); | |
tabgroup.addTab(tab); | |
self.TabGroup = tabgroup; | |
self.Tab = tab; | |
self.open = function(){ | |
tabgroup.open(); | |
} | |
return self; | |
} | |
module.exports = TabGroup(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = []; | |
exports.RootWindow = function(){ | |
var self = {}; | |
var win = Ti.UI.createWindow({ | |
backgroundColor:'#ccc' | |
}); | |
var button = Ti.UI.createButton({ | |
left: 20, | |
right:20, | |
height: Ti.UI.SIZE, | |
title:'Open Next Window' | |
}); | |
win.add(button); | |
button.addEventListener('click', function(){ | |
var TabGroup = require('tabgroup'); | |
var mem = exports.MemoryWindow(); | |
TabGroup.Tab.open(mem.Window); | |
}); | |
self.Window = win; | |
return self; | |
} | |
exports.MemoryWindow = function(){ | |
var self = {}; | |
var win = Ti.UI.createWindow({ | |
backgroundColor:'#eee' | |
}); | |
// Memory Leak | |
function changeTitle(){ | |
win.title= 'foo'; | |
} | |
foo.push(win); | |
Ti.App.addEventListener('foo', changeTitle); | |
win.addEventListener('close', function(){ | |
foo.pop(); | |
Ti.App.removeEventListener('foo', changeTitle); | |
}); | |
self.Window = win; | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment