The test below for workingUserId passes if the window.show call comes after I defined all my globals (Window.show at Point B in my launch function below)
If I move it to Point A, then the test fails.
I'm guessing that show is pausing execution or something? Under no circumstances can I get a reference to my window (I tried a lot of different ways)
All of those ways give me a good reference from inside my launch function, just not in my test.
Any insight into what is going on here?
Here's my test:
StartTest(function(t) {
t.beginAsync(); // trying things, this didn't help. What's an 'asynchronous frame' ?
t.is(MyApp.globals.workingUserId, "C164B8E2-3751-44DA-A38B-A02E00A8E679".toLowerCase(), 'Ids equal'); // works if W.show is at Point B, fails if it is at Point A (see launch function below)
var login = Ext.getCmp('loginwindow'); // never gives me a reference in the test. Works if I put same code in the launch function.
t.ok(login, 'login ok');
t.endAsync();
/* Other things I tried.
var login = Ext.getCmp('loginwindow');
var body = Ext.getBody().down('#btnLogin');
var usernameField = Ext.select('txtUid').first();
console.dir(usernameField);
t.ok(usernameField);
console.dir(login);
console.dir(MyApp);
*/
});
launch: function () {
console.log('Entering application launch!');
//Point A
Ext.create('MyApp.desktop.view.login.LoginWindow').show();
Ext.Ajax.cors = true;
Ext.Ajax.useDefaultXhrHeader = false;
MyApp.globals = {};
MyApp.globals.workingUserId = "C164B8E2-3751-44DA-A38B-A02E00A8E679".toLowerCase();
MyApp.globals.eventBroadcaster = Ext.create('MyApp.desktop.event.EventBroadcaster');
MyApp.globals.eventBroadcaster.addListener('testEvent', function () { console.log('fired event testEvent'); }, this);
// Point B
//Ext.create('MyApp.desktop.view.login.LoginWindow').show();
MyApp.app = this;
console.log('Leaving application launch!');
}