transition.html revision b8e54cd0fdbfd4d5482a6c38e53b0d42e2e2baff
224N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
224N/A<html>
224N/A<head>
224N/A<title>Transition tests</title>
224N/A<link type="text/css" rel="stylesheet" href="/build/logreader/assets/skins/sam/logreader.css">
224N/A<script type="text/javascript" src="/build/yui/yui.js"></script>
224N/A<style>
224N/A#demo {
224N/A background: #ccc;
224N/A border: 5px solid green;
224N/A width: 200px;
224N/A height: 200px;
224N/A}
224N/A</style>
224N/A</head>
224N/A<body class="yui3-skin-sam">
224N/A <h1>Transition Tests</h1>
224N/A <div id="demo"></div>
224N/A
224N/A<script type="text/javascript">
844N/AYUI({
224N/A filter: "debug",
224N/A logInclude: { TestRunner: true }
224N/A}).use('transition', 'test', 'console', function (Y) {
224N/A Y.namespace('Tests');
1163N/A Y.Tests.Transition = (function(){
1163N/A var suite = new Y.Test.Suite('Transition Tests');
224N/A
224N/A
618N/A suite.add(new Y.Test.Case({
224N/A name: 'Multiple Transition Tests',
844N/A setUp: function() {
844N/A Y.one('#demo').setStyles({
1163N/A height: '200px',
224N/A width: '200px',
224N/A opacity: '1'
1273N/A });
224N/A },
224N/A
224N/A 'all chained callbacks should fire': function() {
224N/A var node = Y.one('#demo'),
224N/A test = this;
224N/A
224N/A node.transition({
224N/A width: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.log('callback 1');
224N/A Y.Assert.areEqual('0px', node.getComputedStyle('width'));
224N/A node.transition({
224N/A height: 0
224N/A }, function(e) {
224N/A Y.log('callback 2');
224N/A test.resume(function() {
224N/A Y.Assert.areEqual('0px', node.getComputedStyle('height'));
224N/A });
224N/A });
224N/A test.wait();
224N/A });
224N/A });
224N/A
224N/A test.wait(4000);
224N/A },
224N/A 'all serial callbacks should fire': function() {
224N/A var node = Y.one('#demo'),
224N/A test = this;
224N/A
224N/A node.transition({
224N/A width: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.Assert.areEqual('0px', node.getComputedStyle('width'));
224N/A test.wait(4000);
224N/A });
224N/A node.transition({
224N/A duration: 1,
224N/A height: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.Assert.areEqual('0px', node.getComputedStyle('height'));
224N/A });
224N/A });
224N/A });
224N/A
224N/A test.wait(4000);
224N/A },
224N/A 'parallel transition should steal attribute': function() {
224N/A var node = Y.one('#demo'),
224N/A test = this;
224N/A
224N/A node.transition({
224N/A width: 0
224N/A }, function(e) { // should never fire
224N/A test.resume(function() {
224N/A Y.Assert.isNull(1);
224N/A test.wait(4000);
224N/A });
224N/A
224N/A });
224N/A
224N/A node.transition({
224N/A duration: 1,
224N/A width: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.Assert.areEqual('0px', node.getComputedStyle('width'));
224N/A });
224N/A });
224N/A
224N/A test.wait(4000);
224N/A },
224N/A 'parallel transition should shorten duration': function() {
224N/A var node = Y.one('#demo'),
224N/A test = this;
224N/A
224N/A node.transition({
224N/A easing: 'ease-in',
224N/A duration: 2,
224N/A opacity: {
224N/A value: 0,
224N/A duration: 3
224N/A },
224N/A height: 0,
224N/A width: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.Assert.areEqual(2, parseInt(e.elapsedTime));
224N/A });
224N/A });
224N/A
224N/A node.transition({
224N/A duration: 1,
224N/A opacity: 0
224N/A }, function(e) {
224N/A test.resume(function() {
224N/A Y.Assert.areEqual('0', node.getComputedStyle('opacity'));
224N/A Y.Assert.areEqual(1, parseInt(e.elapsedTime));
224N/A test.wait(4000);
224N/A });
224N/A });
224N/A
224N/A test.wait(4000);
224N/A }
224N/A }));
224N/A suite.add(new Y.Test.Case({
224N/A
224N/A name: 'Single Transition Tests',
224N/A setUp: function() {
224N/A var node = Y.one('#demo');
224N/A if (node) {
224N/A node.setStyles({
224N/A height: '200px',
224N/A width: '200px',
224N/A opacity: '1'
224N/A });
224N/A }
224N/A },
224N/A
224N/A 'should end at final value': function() {
224N/A var node = Y.one('#demo'),
test = this;
node.transition({
width: 0
}, function(e) {
test.resume(function() {
Y.Assert.areEqual('0px', node.getComputedStyle('width'));
});
});
test.wait(4000);
},
'should end at final values': function() {
var node = Y.one('#demo'),
test = this;
node.transition({
width: 0,
height: 0,
opacity: 0
}, function(e) {
test.resume(function() {
Y.Assert.areEqual('0px', node.getComputedStyle('width'));
Y.Assert.areEqual('0px', node.getComputedStyle('height'));
Y.Assert.areEqual('0', node.getComputedStyle('opacity'));
});
});
test.wait(4000);
},
'callback should fire after longest duration': function() {
var node = Y.one('#demo'),
test = this;
node.transition({
easing: 'ease-in',
duration: 1,
opacity: {
value: 0,
duration: 2
},
height: 0,
width: 0
}, function(e) {
test.resume(function() {
Y.Assert.areEqual(2, parseInt(e.elapsedTime));
});
});
test.wait(4000);
}
}));
//return it
return suite;
})();
new Y.Console({
verbose : true,
height: 600,
newestOnTop : false
}).render();
//add to the testrunner and run
Y.Test.Runner.add(Y.Tests.Transition);
Y.Test.Runner.run();
/*if (parent && parent != window) {
YAHOO.tool.TestManager.load();
} else {
YAHOO.tool.TestRunner.run();
}*/
});
</script>
</body>
</html>