globalevents.html revision c28f85fdfe5f4318a887f384ac1e58d40414fdba
<PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI io Global Events Tests</title>
</head>
<body class="yui3-skin-sam">
<h1>YUI io Global Events Tests</h1>
<script type="text/javascript" src="/build/yui/yui.js"></script>
<script type="text/javascript">
(function() {
YUI({
base: "/build/",
filter: "debug",
logExclude: {
attribute: true,
dom: true,
node: true,
event: true,
base: true,
widget: true,
selector: true,
io: true
},
useConsole: true
}).use("test", "console", "io-base", function(Y) {
var console = new Y.Console().render();
var ioGlobalEventSuccessFlowTest = new Y.Test.Case(
{
name: 'Success flow test',
setUp: function() {
var t = this;
this.a0 = [];
this.a1 = ['start', 'complete', 'success', 'end'];
this.start = function(id, a) {
t.a0.push(a);
};
this.complete = function(id, o, a) {
t.a0.push(a);
};
this.success = function(id, o, a) {
t.a0.push(a);
};
this.end = function(id, a) {
t.a0.push(a);
t.resume(t.resolve);
};
this.resolve = function() {
for (var i=0; i < 4; i++) {
Y.log(t.a1[i]);
Y.Assert.areSame(t.a1[i], t.a0[i]);
}
};
this.start = Y.on('io:start', t.start, t, 'start');
this.complete = Y.on('io:complete', t.complete, t, 'complete');
this.success = Y.on('io:success', t.success, t, 'success');
this.end = Y.on('io:end', t.end, t, 'end');
},
tearDown: function() {
this.start.detach();
this.complete.detach();
this.success.detach();
this.end.detach();
},
testSuccessFlow: function() {
Y.io('get.php');
this.wait(null, 1000);
}
});
var ioGlobalEventFailureFlowTest = new Y.Test.Case({
name: 'Failure flow test',
setUp: function() {
var t = this;
this.a0 = [];
this.a2 = ['start', 'complete', 'failure', 'end'];
this.start = function(id, a) {
t.a0.push(a);
};
this.complete = function(id, o, a) {
t.a0.push(a);
};
this.failure = function(id, o, a) {
t.a0.push(a);
};
this.end = function(id, a) {
t.a0.push(a);
t.resume(t.resolve);
};
this.resolve = function() {
for (var i=0; i < 4; i++) {
Y.log(t.a2[i]);
Y.Assert.areSame(t.a2[i], t.a0[i]);
}
};
this.start = Y.on('io:start', t.start, t, 'start');
this.complete = Y.on('io:complete', t.complete, t, 'complete');
this.failure = Y.on('io:failure', t.failure, t, 'failure');
this.end = Y.on('io:end', t.end, t, 'end');
},
tearDown: function() {
this.start.detach();
this.complete.detach();
this.failure.detach();
this.end.detach();
},
testFailureFlow: function() {
Y.io('http.php?a=404');
this.wait(null, 1000);
}
});
Y.Test.Runner.add(ioGlobalEventSuccessFlowTest);
Y.Test.Runner.add(ioGlobalEventFailureFlowTest);
Y.Test.Runner.run();
})
})();
</script>
</body>
</html>