Merge #302 from @drkibitz, and fix conflicts
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.project
|
.project
|
||||||
*.sublime-*
|
*.sublime-*
|
||||||
|
*.log
|
||||||
|
|
8
.travis.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- 0.10
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g grunt-cli
|
||||||
|
- export DISPLAY=:99.0
|
||||||
|
- sh -e /etc/init.d/xvfb start
|
68
Gruntfile.js
|
@ -1,12 +1,13 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.loadNpmTasks('grunt-concat-sourcemap');
|
grunt.loadNpmTasks('grunt-concat-sourcemap');
|
||||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
||||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
grunt.loadTasks('tasks');
|
||||||
|
|
||||||
var root = 'src/pixi/',
|
var root = 'src/pixi/',
|
||||||
debug = 'bin/pixi.dev.js',
|
debug = 'bin/pixi.dev.js',
|
||||||
|
@ -100,7 +101,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
srcBlob: '<%= dirs.src %>/**/*.js',
|
srcBlob: '<%= dirs.src %>/**/*.js',
|
||||||
testBlob: '<%= dirs.test %>/unit/**/*.js',
|
testBlob: '<%= dirs.test %>/{functional,lib/pixi,unit}/**/*.js',
|
||||||
build: '<%= dirs.build %>/pixi.dev.js',
|
build: '<%= dirs.build %>/pixi.dev.js',
|
||||||
buildMin: '<%= dirs.build %>/pixi.js'
|
buildMin: '<%= dirs.build %>/pixi.js'
|
||||||
},
|
},
|
||||||
|
@ -124,24 +125,16 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
beforeconcat: {
|
beforeconcat: srcFiles,
|
||||||
src: srcFiles,
|
|
||||||
options: {
|
|
||||||
jshintrc: '.jshintrc',
|
|
||||||
ignores: ['<%= dirs.src %>/{Intro,Outro}.js']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
afterconcat: {
|
|
||||||
src: '<%= files.build %>',
|
|
||||||
options: {
|
|
||||||
jshintrc: '.jshintrc',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
test: {
|
test: {
|
||||||
src: ['<%= files.testBlob %>'],
|
src: ['<%= files.testBlob %>'],
|
||||||
options: {
|
options: {
|
||||||
expr: true
|
expr: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
asi: true,
|
||||||
|
smarttabs: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uglify: {
|
uglify: {
|
||||||
|
@ -154,12 +147,6 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
connect: {
|
connect: {
|
||||||
qunit: {
|
|
||||||
options: {
|
|
||||||
port: grunt.option('port-test') || 9002,
|
|
||||||
base: './'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
test: {
|
test: {
|
||||||
options: {
|
options: {
|
||||||
port: grunt.option('port-test') || 9002,
|
port: grunt.option('port-test') || 9002,
|
||||||
|
@ -168,13 +155,6 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
qunit: {
|
|
||||||
all: {
|
|
||||||
options: {
|
|
||||||
urls: ['http://localhost:' + (grunt.option('port-test') || 9002) + '/test/index.html']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
yuidoc: {
|
yuidoc: {
|
||||||
compile: {
|
compile: {
|
||||||
name: '<%= pkg.name %>',
|
name: '<%= pkg.name %>',
|
||||||
|
@ -188,24 +168,22 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
karma: {
|
||||||
dev: {
|
unit: {
|
||||||
files: ['Gruntfile.js', 'src/**/*.js', 'examples/**/*.html'],
|
configFile: 'test/karma.conf.js',
|
||||||
tasks: ['build-debug'],
|
// browsers: ['Chrome'],
|
||||||
|
singleRun: true
|
||||||
// We would need to inject <script> in each HTML...
|
|
||||||
// options: {
|
|
||||||
// livereload: true
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('build-debug', ['concat_sourcemap', 'uglify']);
|
grunt.registerTask('default', ['build', 'test']);
|
||||||
grunt.registerTask('lintconcat', ['jshint:beforeconcat', 'concat', 'jshint:afterconcat']);
|
|
||||||
grunt.registerTask('default', ['lintconcat', 'uglify']);
|
|
||||||
grunt.registerTask('build', ['lintconcat', 'uglify']);
|
|
||||||
grunt.registerTask('test', ['build', 'connect:qunit', 'qunit']);
|
|
||||||
grunt.registerTask('docs', ['yuidoc']);
|
|
||||||
|
|
||||||
}
|
grunt.registerTask('build', ['jshint', 'concat', 'uglify']);
|
||||||
|
grunt.registerTask('build-debug', ['concat_sourcemap', 'uglify']);
|
||||||
|
|
||||||
|
grunt.registerTask('test', ['concat', 'jshint:test', 'karma']);
|
||||||
|
|
||||||
|
grunt.registerTask('docs', ['yuidoc']);
|
||||||
|
grunt.registerTask('travis', ['test']);
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ Pixi Renderer
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
[](http://travis-ci.org/drkibitz/pixi.js)
|
||||||
|
|
||||||
#### JavaScript 2D Renderer ####
|
#### JavaScript 2D Renderer ####
|
||||||
|
|
||||||
The aim of this project is to provide a fast lightweight 2D library that works
|
The aim of this project is to provide a fast lightweight 2D library that works
|
||||||
|
|
16
package.json
|
@ -18,16 +18,22 @@
|
||||||
|
|
||||||
"main": "bin/pixi.js",
|
"main": "bin/pixi.js",
|
||||||
|
|
||||||
|
"scripts": {
|
||||||
|
"test": "grunt travis --verbose"
|
||||||
|
},
|
||||||
|
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"grunt": "~0.4.x",
|
"grunt": "~0.4.x",
|
||||||
"grunt-contrib-jshint": "0.3.x",
|
"grunt-contrib-jshint": "0.6.x",
|
||||||
"grunt-contrib-uglify": "0.2.x",
|
"grunt-contrib-uglify": "0.2.x",
|
||||||
"grunt-contrib-connect": "0.2.x",
|
"grunt-contrib-connect": "0.3.x",
|
||||||
"grunt-contrib-qunit": "0.2.x",
|
|
||||||
"grunt-contrib-yuidoc": "0.4.x",
|
"grunt-contrib-yuidoc": "0.4.x",
|
||||||
"grunt-contrib-concat": "0.1.x",
|
|
||||||
"grunt-concat-sourcemap": "0.3.x",
|
"grunt-concat-sourcemap": "0.3.x",
|
||||||
"grunt-contrib-concat": "0.1.x"
|
"grunt-contrib-concat": "0.3.x",
|
||||||
|
"chai": "~1.7.0",
|
||||||
|
"karma": "0.11.0",
|
||||||
|
"karma-firefox-launcher": "0.1.0",
|
||||||
|
"karma-mocha": "0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,6 @@ PIXI.InteractionManager = function(stage)
|
||||||
this.onTouchStart = this.onTouchStart.bind(this);
|
this.onTouchStart = this.onTouchStart.bind(this);
|
||||||
this.onTouchEnd = this.onTouchEnd.bind(this);
|
this.onTouchEnd = this.onTouchEnd.bind(this);
|
||||||
this.onTouchMove = this.onTouchMove.bind(this);
|
this.onTouchMove = this.onTouchMove.bind(this);
|
||||||
|
|
||||||
|
|
||||||
this.last = 0;
|
this.last = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ PIXI.Ellipse.prototype.contains = function(x, y)
|
||||||
return (normx + normy < 0.25);
|
return (normx + normy < 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIXI.Ellipse.getBounds = function()
|
PIXI.Ellipse.prototype.getBounds = function()
|
||||||
{
|
{
|
||||||
return new PIXI.Rectangle(this.x, this.y, this.width, this.height);
|
return new PIXI.Rectangle(this.x, this.y, this.width, this.height);
|
||||||
}
|
}
|
||||||
|
|
27
tasks/karma.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var server = require('karma').server;
|
||||||
|
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
grunt.registerMultiTask('karma', 'run karma.', function() {
|
||||||
|
var done = this.async();
|
||||||
|
var options = this.options({
|
||||||
|
background: false
|
||||||
|
});
|
||||||
|
var data = this.data;
|
||||||
|
|
||||||
|
//merge options onto data, with data taking precedence
|
||||||
|
data = grunt.util._.merge(options, data);
|
||||||
|
data.configFile = path.resolve(data.configFile);
|
||||||
|
if (data.configFile) {
|
||||||
|
data.configFile = grunt.template.process(data.configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.start(
|
||||||
|
data,
|
||||||
|
function(code) {
|
||||||
|
done(!code);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
BIN
test/functional/example-1-basics/bunny.png
Normal file
After Width: | Height: | Size: 449 B |
BIN
test/functional/example-1-basics/frame-30.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
test/functional/example-1-basics/frame-60.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
test/functional/example-1-basics/frame-90.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
133
test/functional/example-1-basics/index.js
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
describe('Example 1 - Basics', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var baseUri = '/base/test/functional/example-1-basics';
|
||||||
|
var expect = chai.expect;
|
||||||
|
var currentFrame = 0;
|
||||||
|
var frameEvents = {};
|
||||||
|
var stage;
|
||||||
|
var renderer;
|
||||||
|
var bunny;
|
||||||
|
|
||||||
|
function onFrame(frame, callback) {
|
||||||
|
frameEvents[frame] = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function animate() {
|
||||||
|
currentFrame += 1;
|
||||||
|
|
||||||
|
requestAnimFrame( animate );
|
||||||
|
|
||||||
|
// just for fun, lets rotate mr rabbit a little
|
||||||
|
bunny.rotation += 0.1;
|
||||||
|
|
||||||
|
// render the stage
|
||||||
|
renderer.render(stage);
|
||||||
|
|
||||||
|
if (frameEvents[currentFrame])
|
||||||
|
frameEvents[currentFrame](currentFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initScene() {
|
||||||
|
// create an new instance of a pixi stage
|
||||||
|
stage = new PIXI.Stage(0x66FF99);
|
||||||
|
|
||||||
|
// create a renderer instance
|
||||||
|
renderer = PIXI.autoDetectRenderer(400, 300);
|
||||||
|
console.log('Is PIXI.WebGLRenderer: ' + (renderer instanceof PIXI.WebGLRenderer));
|
||||||
|
|
||||||
|
// add the renderer view element to the DOM
|
||||||
|
document.body.appendChild(renderer.view);
|
||||||
|
|
||||||
|
requestAnimFrame( animate );
|
||||||
|
|
||||||
|
// create a texture from an image path
|
||||||
|
var texture = PIXI.Texture.fromImage(baseUri + "/bunny.png");
|
||||||
|
// create a new Sprite using the texture
|
||||||
|
bunny = new PIXI.Sprite(texture);
|
||||||
|
|
||||||
|
// center the sprites anchor point
|
||||||
|
bunny.anchor.x = 0.5;
|
||||||
|
bunny.anchor.y = 0.5;
|
||||||
|
|
||||||
|
// move the sprite t the center of the screen
|
||||||
|
bunny.position.x = 200;
|
||||||
|
bunny.position.y = 150;
|
||||||
|
|
||||||
|
stage.addChild(bunny);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('assets loaded', function (done) {
|
||||||
|
var loader = new PIXI.AssetLoader([
|
||||||
|
baseUri + '/bunny.png',
|
||||||
|
baseUri + '/frame-30.png',
|
||||||
|
baseUri + '/frame-60.png',
|
||||||
|
baseUri + '/frame-90.png'
|
||||||
|
]);
|
||||||
|
// loader.on('onProgress', function (event) {
|
||||||
|
// console.log(event.content);
|
||||||
|
// });
|
||||||
|
loader.on('onComplete', function (event) {
|
||||||
|
done();
|
||||||
|
initScene();
|
||||||
|
});
|
||||||
|
loader.load();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('frame 30 should match', function (done) {
|
||||||
|
this.timeout(700);
|
||||||
|
onFrame(30, function () {
|
||||||
|
var str = renderer.view.toDataURL('image/png');
|
||||||
|
//console.log('<img src="' + str + '" />');
|
||||||
|
resemble(str)
|
||||||
|
.compareTo(baseUri + '/frame-30.png')
|
||||||
|
.onComplete(function (data) {
|
||||||
|
expect(data).to.be.an('object');
|
||||||
|
expect(data.isSameDimensions).to.equal(true);
|
||||||
|
expect(data.misMatchPercentage).to.be.below(0.2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('frame 60 should match', function (done) {
|
||||||
|
this.timeout(1200);
|
||||||
|
onFrame(60, function () {
|
||||||
|
var str = renderer.view.toDataURL('image/png');
|
||||||
|
//console.log('<img src="' + str + '" />');
|
||||||
|
resemble(str)
|
||||||
|
.compareTo(baseUri + '/frame-60.png')
|
||||||
|
.onComplete(function (data) {
|
||||||
|
expect(data).to.be.an('object');
|
||||||
|
expect(data.isSameDimensions).to.equal(true);
|
||||||
|
expect(data.misMatchPercentage).to.be.below(0.2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('frame 90 should match', function (done) {
|
||||||
|
this.timeout(1700);
|
||||||
|
onFrame(90, function () {
|
||||||
|
var str = renderer.view.toDataURL('image/png');
|
||||||
|
//console.log('<img src="' + str + '" />');
|
||||||
|
resemble(str)
|
||||||
|
.compareTo(baseUri + '/frame-90.png')
|
||||||
|
.onComplete(function (data) {
|
||||||
|
expect(data).to.be.an('object');
|
||||||
|
expect(data.isSameDimensions).to.equal(true);
|
||||||
|
expect(data.misMatchPercentage).to.be.below(0.2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// it('capture something', function (done) {
|
||||||
|
// this.timeout(2000000);
|
||||||
|
// onFrame(30, function () {
|
||||||
|
// var img = new Image();
|
||||||
|
// img.src = renderer.view.toDataURL('image/png');
|
||||||
|
// document.body.appendChild(img);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
});
|
|
@ -1,22 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Pixi.js Test Suite</title>
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/test/lib/qunit-1.11.0.css" />
|
|
||||||
|
|
||||||
<!-- QUnit includes -->
|
|
||||||
<script src="/test/lib/qunit-1.11.0.js"></script>
|
|
||||||
<script>
|
|
||||||
window.Q = QUnit; //alias QUnit
|
|
||||||
Q.config.autostart = false;
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="qunit"></div>
|
|
||||||
<div id="qunit-fixture"></div>
|
|
||||||
|
|
||||||
<script src="/bin/pixi.dev.js"></script>
|
|
||||||
<script src="/test/lib/require.js" data-main="testsuite"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
82
test/karma.conf.js
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
module.exports = function(config) {
|
||||||
|
config.set({
|
||||||
|
|
||||||
|
// base path, that will be used to resolve files and exclude
|
||||||
|
basePath : '../',
|
||||||
|
|
||||||
|
frameworks : ['mocha'],
|
||||||
|
|
||||||
|
// list of files / patterns to load in the browser
|
||||||
|
files : [
|
||||||
|
'node_modules/chai/chai.js',
|
||||||
|
'bin/pixi.dev.js',
|
||||||
|
'test/lib/**/*.js',
|
||||||
|
'test/unit/**/*.js',
|
||||||
|
// 'test/functional/**/*.js',
|
||||||
|
{pattern: 'test/**/*.png', watched: false, included: false, served: true}
|
||||||
|
],
|
||||||
|
|
||||||
|
// list of files to exclude
|
||||||
|
exclude : [],
|
||||||
|
|
||||||
|
// use dolts reporter, as travis terminal does not support escaping sequences
|
||||||
|
// possible values: 'dots', 'progress', 'junit', 'teamcity'
|
||||||
|
// CLI --reporters progress
|
||||||
|
reporters : ['progress'],
|
||||||
|
|
||||||
|
// web server port
|
||||||
|
// CLI --port 9876
|
||||||
|
port : 9876,
|
||||||
|
|
||||||
|
// cli runner port
|
||||||
|
// CLI --runner-port 9100
|
||||||
|
runnerPort : 9100,
|
||||||
|
|
||||||
|
// enable / disable colors in the output (reporters and logs)
|
||||||
|
// CLI --colors --no-colors
|
||||||
|
colors : true,
|
||||||
|
|
||||||
|
// level of logging
|
||||||
|
// possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
|
||||||
|
// CLI --log-level debug
|
||||||
|
logLevel : config.LOG_DEBUG,
|
||||||
|
|
||||||
|
// enable / disable watching file and executing tests whenever any file changes
|
||||||
|
// CLI --auto-watch --no-auto-watch
|
||||||
|
autoWatch : false,
|
||||||
|
|
||||||
|
// Start these browsers, currently available:
|
||||||
|
// - Chrome
|
||||||
|
// - ChromeCanary
|
||||||
|
// - Firefox
|
||||||
|
// - Opera
|
||||||
|
// - Safari (only Mac)
|
||||||
|
// - PhantomJS
|
||||||
|
// - IE (only Windows)
|
||||||
|
// CLI --browsers Chrome,Firefox,Safari
|
||||||
|
browsers : ['Firefox'],
|
||||||
|
|
||||||
|
// If browser does not capture in given timeout [ms], kill it
|
||||||
|
// CLI --capture-timeout 5000
|
||||||
|
captureTimeout : 5000,
|
||||||
|
|
||||||
|
// Auto run tests on start (when browsers are captured) and exit
|
||||||
|
// CLI --single-run --no-single-run
|
||||||
|
singleRun : true,
|
||||||
|
|
||||||
|
// report which specs are slower than 500ms
|
||||||
|
// CLI --report-slower-than 500
|
||||||
|
reportSlowerThan : 1000,
|
||||||
|
|
||||||
|
preprocessors : {
|
||||||
|
// '**/client/js/*.js': 'coverage'
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins : [
|
||||||
|
'karma-mocha',
|
||||||
|
// 'karma-chrome-launcher',
|
||||||
|
'karma-firefox-launcher',
|
||||||
|
// 'karma-phantomjs-launcher'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
};
|
40
test/lib/pixi/core/Matrix.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
function pixi_core_Matrix_confirmNewMat3(matrix) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(matrix).to.be.an.instanceof(PIXI.Matrix);
|
||||||
|
expect(matrix).to.not.be.empty;
|
||||||
|
|
||||||
|
expect(matrix[1]).to.equal(0);
|
||||||
|
expect(matrix[2]).to.equal(0);
|
||||||
|
expect(matrix[3]).to.equal(0);
|
||||||
|
expect(matrix[4]).to.equal(1);
|
||||||
|
expect(matrix[5]).to.equal(0);
|
||||||
|
expect(matrix[6]).to.equal(0);
|
||||||
|
expect(matrix[7]).to.equal(0);
|
||||||
|
expect(matrix[8]).to.equal(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pixi_core_Matrix_confirmNewMat4(matrix) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(matrix).to.be.an.instanceof(PIXI.Matrix);
|
||||||
|
expect(matrix).to.not.be.empty;
|
||||||
|
|
||||||
|
expect(matrix[0]).to.equal(1);
|
||||||
|
expect(matrix[1]).to.equal(0);
|
||||||
|
expect(matrix[2]).to.equal(0);
|
||||||
|
expect(matrix[3]).to.equal(0);
|
||||||
|
expect(matrix[4]).to.equal(0);
|
||||||
|
expect(matrix[5]).to.equal(1);
|
||||||
|
expect(matrix[6]).to.equal(0);
|
||||||
|
expect(matrix[7]).to.equal(0);
|
||||||
|
expect(matrix[8]).to.equal(0);
|
||||||
|
expect(matrix[9]).to.equal(0);
|
||||||
|
expect(matrix[10]).to.equal(1);
|
||||||
|
expect(matrix[11]).to.equal(0);
|
||||||
|
expect(matrix[12]).to.equal(0);
|
||||||
|
expect(matrix[13]).to.equal(0);
|
||||||
|
expect(matrix[14]).to.equal(0);
|
||||||
|
expect(matrix[15]).to.equal(1);
|
||||||
|
}
|
10
test/lib/pixi/core/Point.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
function pixi_core_Point_confirm(obj, x, y) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.Point);
|
||||||
|
expect(obj).to.respondTo('clone');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('x', x);
|
||||||
|
expect(obj).to.have.property('y', y);
|
||||||
|
}
|
13
test/lib/pixi/core/Rectangle.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
function pixi_core_Rectangle_confirm(obj, x, y, width, height) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.Rectangle);
|
||||||
|
expect(obj).to.respondTo('clone');
|
||||||
|
expect(obj).to.respondTo('contains');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('x', x);
|
||||||
|
expect(obj).to.have.property('y', y);
|
||||||
|
expect(obj).to.have.property('width', width);
|
||||||
|
expect(obj).to.have.property('height', height);
|
||||||
|
}
|
43
test/lib/pixi/display/DisplayObject.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
function pixi_display_DisplayObject_confirmNew(obj) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.DisplayObject);
|
||||||
|
expect(obj).to.respondTo('setInteractive');
|
||||||
|
expect(obj).to.respondTo('addFilter');
|
||||||
|
expect(obj).to.respondTo('removeFilter');
|
||||||
|
expect(obj).to.respondTo('updateTransform');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('last', obj);
|
||||||
|
expect(obj).to.have.property('first', obj);
|
||||||
|
|
||||||
|
expect(obj).to.contain.property('position');
|
||||||
|
pixi_core_Point_confirm(obj.position, 0, 0);
|
||||||
|
expect(obj).to.contain.property('scale');
|
||||||
|
pixi_core_Point_confirm(obj.scale, 1, 1);
|
||||||
|
expect(obj).to.contain.property('pivot');
|
||||||
|
pixi_core_Point_confirm(obj.pivot, 0, 0);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('rotation', 0);
|
||||||
|
expect(obj).to.have.property('alpha', 1);
|
||||||
|
expect(obj).to.have.property('visible', true);
|
||||||
|
expect(obj).to.have.property('buttonMode', false);
|
||||||
|
expect(obj).to.have.property('parent', null);
|
||||||
|
expect(obj).to.have.property('worldAlpha', 1);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('hitArea');
|
||||||
|
expect(obj).to.have.property('interactive'); // TODO: Have a better default value
|
||||||
|
expect('mask' in obj).to.be.true; // TODO: Have a better default value
|
||||||
|
expect(obj.mask).to.be.undefined;
|
||||||
|
|
||||||
|
expect(obj).to.have.property('renderable');
|
||||||
|
expect(obj).to.have.property('stage');
|
||||||
|
|
||||||
|
expect(obj).to.have.deep.property('worldTransform.length', 9);
|
||||||
|
pixi_core_Matrix_confirmNewMat3(obj.worldTransform);
|
||||||
|
expect(obj).to.have.deep.property('localTransform.length', 9);
|
||||||
|
pixi_core_Matrix_confirmNewMat3(obj.localTransform);
|
||||||
|
|
||||||
|
expect(obj).to.have.deep.property('color.length', 0);
|
||||||
|
expect(obj).to.have.property('dynamic', true);
|
||||||
|
}
|
16
test/lib/pixi/display/DisplayObjectContainer.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
function pixi_display_DisplayObjectContainer_confirmNew(obj) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
pixi_display_DisplayObject_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.DisplayObjectContainer);
|
||||||
|
expect(obj).to.respondTo('addChild');
|
||||||
|
expect(obj).to.respondTo('addChildAt');
|
||||||
|
expect(obj).to.respondTo('swapChildren');
|
||||||
|
expect(obj).to.respondTo('getChildAt');
|
||||||
|
expect(obj).to.respondTo('removeChild');
|
||||||
|
expect(obj).to.respondTo('updateTransform');
|
||||||
|
|
||||||
|
expect(obj).to.have.deep.property('children.length', 0);
|
||||||
|
}
|
28
test/lib/pixi/display/Sprite.js
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
function pixi_display_Sprite_confirmNew(obj, done) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.Sprite);
|
||||||
|
expect(obj).to.respondTo('setTexture');
|
||||||
|
expect(obj).to.respondTo('onTextureUpdate');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('hitArea', null);
|
||||||
|
expect(obj).to.have.property('interactive', false);
|
||||||
|
expect(obj).to.have.property('renderable', true);
|
||||||
|
expect(obj).to.have.property('stage', null);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('anchor');
|
||||||
|
pixi_core_Point_confirm(obj.anchor, 0, 0);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('blendMode', PIXI.blendModes.NORMAL);
|
||||||
|
expect(obj).to.have.property('width', 1); // TODO: is 1 expected
|
||||||
|
expect(obj).to.have.property('height', 1); // TODO: is 1 expected
|
||||||
|
|
||||||
|
// FIXME: Just make this a boolean that is always there
|
||||||
|
expect(!!obj.updateFrame).to.equal(obj.texture.baseTexture.hasLoaded);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('texture');
|
||||||
|
pixi_textures_Texture_confirmNew(obj.texture, done);
|
||||||
|
}
|
12
test/lib/pixi/extras/Strip.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
function pixi_extras_Strip_confirmNew(obj) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.Strip);
|
||||||
|
expect(obj).to.respondTo('setTexture');
|
||||||
|
expect(obj).to.respondTo('onTextureUpdate');
|
||||||
|
|
||||||
|
// TODO: Test properties
|
||||||
|
}
|
31
test/lib/pixi/textures/Texture.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
function pixi_textures_Texture_confirmNew(obj, done) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
function confirmFrameDone() {
|
||||||
|
pixi_core_Rectangle_confirm(obj.frame, 0, 0, obj.baseTexture.width, obj.baseTexture.height);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('width', obj.baseTexture.width);
|
||||||
|
expect(obj).to.have.property('height', obj.baseTexture.height);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(PIXI.Texture);
|
||||||
|
pixi_utils_EventTarget_like(obj);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('baseTexture')
|
||||||
|
.and.to.be.an.instanceof(PIXI.BaseTexture);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('scope', obj);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('trim');
|
||||||
|
pixi_core_Point_confirm(obj.trim, 0, 0);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('frame');
|
||||||
|
if (obj.baseTexture.hasLoaded) {
|
||||||
|
confirmFrameDone();
|
||||||
|
} else {
|
||||||
|
pixi_core_Rectangle_confirm(obj.frame, 0, 0, 1, 1);
|
||||||
|
obj.addEventListener('update', confirmFrameDone);
|
||||||
|
}
|
||||||
|
}
|
8
test/lib/pixi/utils/EventTarget.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
function pixi_utils_EventTarget_like(obj) {
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
expect(obj).to.respondTo('addEventListener');
|
||||||
|
expect(obj).to.respondTo('dispatchEvent');
|
||||||
|
expect(obj).to.respondTo('removeEventListener');
|
||||||
|
}
|
|
@ -1,244 +0,0 @@
|
||||||
/**
|
|
||||||
* QUnit v1.11.0 - A JavaScript Unit Testing Framework
|
|
||||||
*
|
|
||||||
* http://qunitjs.com
|
|
||||||
*
|
|
||||||
* Copyright 2012 jQuery Foundation and other contributors
|
|
||||||
* Released under the MIT license.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Font Family and Sizes */
|
|
||||||
|
|
||||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
|
||||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
|
||||||
#qunit-tests { font-size: smaller; }
|
|
||||||
|
|
||||||
|
|
||||||
/** Resets */
|
|
||||||
|
|
||||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Header */
|
|
||||||
|
|
||||||
#qunit-header {
|
|
||||||
padding: 0.5em 0 0.5em 1em;
|
|
||||||
|
|
||||||
color: #8699a4;
|
|
||||||
background-color: #0d3349;
|
|
||||||
|
|
||||||
font-size: 1.5em;
|
|
||||||
line-height: 1em;
|
|
||||||
font-weight: normal;
|
|
||||||
|
|
||||||
border-radius: 5px 5px 0 0;
|
|
||||||
-moz-border-radius: 5px 5px 0 0;
|
|
||||||
-webkit-border-top-right-radius: 5px;
|
|
||||||
-webkit-border-top-left-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-header a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: #c2ccd1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-header a:hover,
|
|
||||||
#qunit-header a:focus {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-testrunner-toolbar label {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 0 .5em 0 .1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-banner {
|
|
||||||
height: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-testrunner-toolbar {
|
|
||||||
padding: 0.5em 0 0.5em 2em;
|
|
||||||
color: #5E740B;
|
|
||||||
background-color: #eee;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-userAgent {
|
|
||||||
padding: 0.5em 0 0.5em 2.5em;
|
|
||||||
background-color: #2b81af;
|
|
||||||
color: #fff;
|
|
||||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-modulefilter-container {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tests: Pass/Fail */
|
|
||||||
|
|
||||||
#qunit-tests {
|
|
||||||
list-style-position: inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests li {
|
|
||||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
|
||||||
border-bottom: 1px solid #fff;
|
|
||||||
list-style-position: inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests li strong {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests li a {
|
|
||||||
padding: 0.5em;
|
|
||||||
color: #c2ccd1;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
#qunit-tests li a:hover,
|
|
||||||
#qunit-tests li a:focus {
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests li .runtime {
|
|
||||||
float: right;
|
|
||||||
font-size: smaller;
|
|
||||||
}
|
|
||||||
|
|
||||||
.qunit-assert-list {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
padding: 0.5em;
|
|
||||||
|
|
||||||
background-color: #fff;
|
|
||||||
|
|
||||||
border-radius: 5px;
|
|
||||||
-moz-border-radius: 5px;
|
|
||||||
-webkit-border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.qunit-collapsed {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin-top: .2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests th {
|
|
||||||
text-align: right;
|
|
||||||
vertical-align: top;
|
|
||||||
padding: 0 .5em 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests td {
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests pre {
|
|
||||||
margin: 0;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests del {
|
|
||||||
background-color: #e0f2be;
|
|
||||||
color: #374e0c;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests ins {
|
|
||||||
background-color: #ffcaca;
|
|
||||||
color: #500;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Test Counts */
|
|
||||||
|
|
||||||
#qunit-tests b.counts { color: black; }
|
|
||||||
#qunit-tests b.passed { color: #5E740B; }
|
|
||||||
#qunit-tests b.failed { color: #710909; }
|
|
||||||
|
|
||||||
#qunit-tests li li {
|
|
||||||
padding: 5px;
|
|
||||||
background-color: #fff;
|
|
||||||
border-bottom: none;
|
|
||||||
list-style-position: inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Passing Styles */
|
|
||||||
|
|
||||||
#qunit-tests li li.pass {
|
|
||||||
color: #3c510c;
|
|
||||||
background-color: #fff;
|
|
||||||
border-left: 10px solid #C6E746;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
|
||||||
#qunit-tests .pass .test-name { color: #366097; }
|
|
||||||
|
|
||||||
#qunit-tests .pass .test-actual,
|
|
||||||
#qunit-tests .pass .test-expected { color: #999999; }
|
|
||||||
|
|
||||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
|
||||||
|
|
||||||
/*** Failing Styles */
|
|
||||||
|
|
||||||
#qunit-tests li li.fail {
|
|
||||||
color: #710909;
|
|
||||||
background-color: #fff;
|
|
||||||
border-left: 10px solid #EE5757;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests > li:last-child {
|
|
||||||
border-radius: 0 0 5px 5px;
|
|
||||||
-moz-border-radius: 0 0 5px 5px;
|
|
||||||
-webkit-border-bottom-right-radius: 5px;
|
|
||||||
-webkit-border-bottom-left-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
|
||||||
#qunit-tests .fail .test-name,
|
|
||||||
#qunit-tests .fail .module-name { color: #000000; }
|
|
||||||
|
|
||||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
|
||||||
#qunit-tests .fail .test-expected { color: green; }
|
|
||||||
|
|
||||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
|
||||||
|
|
||||||
|
|
||||||
/** Result */
|
|
||||||
|
|
||||||
#qunit-testresult {
|
|
||||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
|
||||||
|
|
||||||
color: #2b81af;
|
|
||||||
background-color: #D2E0E6;
|
|
||||||
|
|
||||||
border-bottom: 1px solid white;
|
|
||||||
}
|
|
||||||
#qunit-testresult .module-name {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Fixture */
|
|
||||||
|
|
||||||
#qunit-fixture {
|
|
||||||
position: absolute;
|
|
||||||
top: -10000px;
|
|
||||||
left: -10000px;
|
|
||||||
width: 1000px;
|
|
||||||
height: 1000px;
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
/*
|
|
||||||
RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
|
||||||
Available via the MIT or new BSD license.
|
|
||||||
see: http://github.com/jrburke/requirejs for details
|
|
||||||
*/
|
|
||||||
var requirejs,require,define;
|
|
||||||
(function(aa){function I(b){return"[object Function]"===L.call(b)}function J(b){return"[object Array]"===L.call(b)}function y(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function M(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function s(b,c){return ga.call(b,c)}function m(b,c){return s(b,c)&&b[c]}function G(b,c){for(var d in b)if(s(b,d)&&c(b[d],d))break}function R(b,c,d,m){c&&G(c,function(c,j){if(d||!s(b,j))m&&"string"!==typeof c?(b[j]||(b[j]={}),R(b[j],
|
|
||||||
c,d,m)):b[j]=c});return b}function u(b,c){return function(){return c.apply(b,arguments)}}function ba(b){if(!b)return b;var c=aa;y(b.split("."),function(b){c=c[b]});return c}function B(b,c,d,m){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=m;d&&(c.originalError=d);return c}function ha(b){function c(a,f,b){var e,n,c,g,d,S,i,h=f&&f.split("/");e=h;var j=k.map,l=j&&j["*"];if(a&&"."===a.charAt(0))if(f){e=m(k.pkgs,f)?h=[f]:h.slice(0,h.length-1);f=a=e.concat(a.split("/"));
|
|
||||||
for(e=0;f[e];e+=1)if(n=f[e],"."===n)f.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===f[2]||".."===f[0]))break;else 0<e&&(f.splice(e-1,2),e-=2);e=m(k.pkgs,f=a[0]);a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else 0===a.indexOf("./")&&(a=a.substring(2));if(b&&j&&(h||l)){f=a.split("/");for(e=f.length;0<e;e-=1){c=f.slice(0,e).join("/");if(h)for(n=h.length;0<n;n-=1)if(b=m(j,h.slice(0,n).join("/")))if(b=m(b,c)){g=b;d=e;break}if(g)break;!S&&(l&&m(l,c))&&(S=m(l,c),i=e)}!g&&S&&(g=S,d=i);g&&(f.splice(0,d,
|
|
||||||
g),a=f.join("/"))}return a}function d(a){A&&y(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===i.contextName)return f.parentNode.removeChild(f),!0})}function z(a){var f=m(k.paths,a);if(f&&J(f)&&1<f.length)return d(a),f.shift(),i.require.undef(a),i.require([a]),!0}function h(a){var f,b=a?a.indexOf("!"):-1;-1<b&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function j(a,f,b,e){var n,C,g=null,d=f?f.name:
|
|
||||||
null,j=a,l=!0,k="";a||(l=!1,a="_@r"+(M+=1));a=h(a);g=a[0];a=a[1];g&&(g=c(g,d,e),C=m(q,g));a&&(g?k=C&&C.normalize?C.normalize(a,function(a){return c(a,d,e)}):c(a,d,e):(k=c(a,d,e),a=h(k),g=a[0],k=a[1],b=!0,n=i.nameToUrl(k)));b=g&&!C&&!b?"_unnormalized"+(Q+=1):"";return{prefix:g,name:k,parentMap:f,unnormalized:!!b,url:n,originalName:j,isDefine:l,id:(g?g+"!"+k:k)+b}}function r(a){var f=a.id,b=m(p,f);b||(b=p[f]=new i.Module(a));return b}function t(a,f,b){var e=a.id,n=m(p,e);if(s(q,e)&&(!n||n.defineEmitComplete))"defined"===
|
|
||||||
f&&b(q[e]);else r(a).on(f,b)}function v(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(y(b,function(f){if(f=m(p,f))f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)l.onError(a)}function w(){T.length&&(ia.apply(H,[H.length-1,0].concat(T)),T=[])}function x(a){delete p[a];delete V[a]}function F(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,y(a.depMaps,function(e,c){var g=e.id,d=m(p,g);d&&(!a.depMatched[c]&&!b[g])&&(m(f,g)?(a.defineDep(c,q[g]),a.check()):F(d,f,b))}),b[e]=!0)}
|
|
||||||
function D(){var a,f,b,e,n=(b=1E3*k.waitSeconds)&&i.startTime+b<(new Date).getTime(),c=[],g=[],h=!1,j=!0;if(!W){W=!0;G(V,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||g.push(b),!b.error))if(!b.inited&&n)z(f)?h=e=!0:(c.push(f),d(f));else if(!b.inited&&(b.fetched&&a.isDefine)&&(h=!0,!a.prefix))return j=!1});if(n&&c.length)return b=B("timeout","Load timeout for modules: "+c,null,c),b.contextName=i.contextName,v(b);j&&y(g,function(a){F(a,{},{})});if((!n||e)&&h)if((A||da)&&!X)X=setTimeout(function(){X=
|
|
||||||
0;D()},50);W=!1}}function E(a){s(q,a[0])||r(j(a[0],null,!0)).init(a[1],a[2])}function K(a){var a=a.currentTarget||a.srcElement,b=i.onScriptLoad;a.detachEvent&&!Y?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=i.onScriptError;(!a.detachEvent||Y)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function L(){var a;for(w();H.length;){a=H.shift();if(null===a[0])return v(B("mismatch","Mismatched anonymous define() module: "+a[a.length-
|
|
||||||
1]));E(a)}}var W,Z,i,N,X,k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},config:{}},p={},V={},$={},H=[],q={},U={},M=1,Q=1;N={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=q[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&&m(k.config,a.map.id)||{}},exports:q[a.map.id]}}};Z=function(a){this.events=
|
|
||||||
m($,a.id)||{};this.map=a;this.shim=m(k.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};Z.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=u(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=
|
|
||||||
!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],u(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;U[a]||(U[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;
|
|
||||||
var e=this.exports,n=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(I(n)){if(this.events.error)try{e=i.execCb(c,n,b,e)}catch(d){a=d}else e=i.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=[this.map.id],a.requireType="define",v(this.error=
|
|
||||||
a)}else e=n;this.exports=e;if(this.map.isDefine&&!this.ignore&&(q[c]=e,l.onResourceLoad))l.onResourceLoad(i,this.map,this.depMaps);x(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=j(a.prefix);this.depMaps.push(d);t(d,"defined",u(this,function(e){var n,d;d=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,h=
|
|
||||||
i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,g,!0)})||""),e=j(a.prefix+"!"+d,this.map.parentMap),t(e,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(p,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else n=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=u(this,
|
|
||||||
function(a){this.inited=!0;this.error=a;a.requireModules=[b];G(p,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&x(a.map.id)});v(a)}),n.fromText=u(this,function(e,c){var d=a.name,g=j(d),C=O;c&&(e=c);C&&(O=!1);r(g);s(k.config,b)&&(k.config[d]=k.config[b]);try{l.exec(e)}catch(ca){return v(B("fromtexteval","fromText eval for "+b+" failed: "+ca,ca,[b]))}C&&(O=!0);this.depMaps.push(g);i.completeLoad(d);h([d],n)}),e.load(a.name,h,n,k)}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=
|
|
||||||
this;this.enabling=this.enabled=!0;y(this.depMaps,u(this,function(a,b){var c,e;if("string"===typeof a){a=j(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(N,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;t(a,"defined",u(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&t(a,"error",this.errback)}c=a.id;e=p[c];!s(N,c)&&(e&&!e.enabled)&&i.enable(a,this)}));G(this.pluginMaps,u(this,function(a){var b=m(p,a.id);b&&!b.enabled&&i.enable(a,
|
|
||||||
this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){y(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:k,contextName:b,registry:p,defined:q,urlFetched:U,defQueue:H,Module:Z,makeModuleMap:j,nextTick:l.nextTick,onError:v,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e={paths:!0,config:!0,map:!0};G(a,function(a,b){e[b]?
|
|
||||||
"map"===b?(k.map||(k.map={}),R(k[b],a,!0,!0)):R(k[b],a,!0):k[b]=a});a.shim&&(G(a.shim,function(a,b){J(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);c[b]=a}),k.shim=c);a.packages&&(y(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ea,"")}}),k.pkgs=b);G(p,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=j(b))});if(a.deps||a.callback)i.require(a.deps||[],
|
|
||||||
a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(aa,arguments));return b||a.exports&&ba(a.exports)}},makeRequire:function(a,f){function d(e,c,h){var g,k;f.enableBuildCallback&&(c&&I(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(I(c))return v(B("requireargs","Invalid require call"),h);if(a&&s(N,e))return N[e](p[a.id]);if(l.get)return l.get(i,e,a,d);g=j(e,a,!1,!0);g=g.id;return!s(q,g)?v(B("notloaded",'Module name "'+g+'" has not been loaded yet for context: '+
|
|
||||||
b+(a?"":". Use require([])"))):q[g]}L();i.nextTick(function(){L();k=r(j(null,a));k.skipMap=f.skipMap;k.init(e,c,h,{enabled:!0});D()});return d}f=f||{};R(d,{isBrowser:A,toUrl:function(b){var d,f=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==f&&(!("."===g||".."===g)||1<f))d=b.substring(f,b.length),b=b.substring(0,f);return i.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return s(q,j(b,a,!1,!0).id)},specified:function(b){b=j(b,a,!1,!0).id;return s(q,b)||s(p,b)}});a||(d.undef=function(b){w();var c=
|
|
||||||
j(b,a,!0),d=m(p,b);delete q[b];delete U[c.url];delete $[b];d&&(d.events.defined&&($[b]=d.events),x(b))});return d},enable:function(a){m(p,a.id)&&r(a).enable()},completeLoad:function(a){var b,c,e=m(k.shim,a)||{},d=e.exports;for(w();H.length;){c=H.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=m(p,a);if(!b&&!s(q,a)&&c&&!c.inited){if(k.enforceDefine&&(!d||!ba(d)))return z(a)?void 0:v(B("nodefine","No define call for "+a,null,[a]));E([a,e.deps||[],e.exportsFn])}D()},nameToUrl:function(a,
|
|
||||||
b,c){var e,d,h,g,j,i;if(l.jsExtRegExp.test(a))g=a+(b||"");else{e=k.paths;d=k.pkgs;g=a.split("/");for(j=g.length;0<j;j-=1)if(i=g.slice(0,j).join("/"),h=m(d,i),i=m(e,i)){J(i)&&(i=i[0]);g.splice(0,j,i);break}else if(h){a=a===h.name?h.location+"/"+h.main:h.location;g.splice(0,j,a);break}g=g.join("/");g+=b||(/\?/.test(g)||c?"":".js");g=("/"===g.charAt(0)||g.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+g}return k.urlArgs?g+((-1===g.indexOf("?")?"?":"&")+k.urlArgs):g},load:function(a,b){l.load(i,a,b)},execCb:function(a,
|
|
||||||
b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ka.test((a.currentTarget||a.srcElement).readyState))P=null,a=K(a),i.completeLoad(a.id)},onScriptError:function(a){var b=K(a);if(!z(b.id))return v(B("scripterror","Script error",a,[b.id]))}};i.require=i.makeRequire();return i}var l,w,x,D,t,E,P,K,Q,fa,la=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ma=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,ea=/\.js$/,ja=/^\.\//;w=Object.prototype;var L=w.toString,ga=w.hasOwnProperty,ia=
|
|
||||||
Array.prototype.splice,A=!!("undefined"!==typeof window&&navigator&&document),da=!A&&"undefined"!==typeof importScripts,ka=A&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,Y="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},r={},T=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(I(requirejs))return;r=requirejs;requirejs=void 0}"undefined"!==typeof require&&!I(require)&&(r=require,require=void 0);l=requirejs=function(b,c,d,z){var h,
|
|
||||||
j="_";!J(b)&&"string"!==typeof b&&(h=b,J(c)?(b=c,c=d,d=z):b=[]);h&&h.context&&(j=h.context);(z=m(F,j))||(z=F[j]=l.s.newContext(j));h&&z.configure(h);return z.require(b,c,d)};l.config=function(b){return l(b)};l.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=l);l.version="2.1.5";l.jsExtRegExp=/^\/|:|\?|\.js$/;l.isBrowser=A;w=l.s={contexts:F,newContext:ha};l({});y(["toUrl","undef","defined","specified"],function(b){l[b]=function(){var c=F._;return c.require[b].apply(c,
|
|
||||||
arguments)}});if(A&&(x=w.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))x=w.head=D.parentNode;l.onError=function(b){throw b;};l.load=function(b,c,d){var l=b&&b.config||{},h;if(A)return h=l.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),h.type=l.scriptType||"text/javascript",h.charset="utf-8",h.async=!0,h.setAttribute("data-requirecontext",b.contextName),h.setAttribute("data-requiremodule",c),
|
|
||||||
h.attachEvent&&!(h.attachEvent.toString&&0>h.attachEvent.toString().indexOf("[native code"))&&!Y?(O=!0,h.attachEvent("onreadystatechange",b.onScriptLoad)):(h.addEventListener("load",b.onScriptLoad,!1),h.addEventListener("error",b.onScriptError,!1)),h.src=d,K=h,D?x.insertBefore(h,D):x.appendChild(h),K=null,h;if(da)try{importScripts(d),b.completeLoad(c)}catch(j){b.onError(B("importscripts","importScripts failed for "+c+" at "+d,j,[c]))}};A&&M(document.getElementsByTagName("script"),function(b){x||(x=
|
|
||||||
b.parentNode);if(t=b.getAttribute("data-main"))return r.baseUrl||(E=t.split("/"),Q=E.pop(),fa=E.length?E.join("/")+"/":"./",r.baseUrl=fa,t=Q),t=t.replace(ea,""),r.deps=r.deps?r.deps.concat(t):[t],!0});define=function(b,c,d){var l,h;"string"!==typeof b&&(d=c,c=b,b=null);J(c)||(d=c,c=[]);!c.length&&I(d)&&d.length&&(d.toString().replace(la,"").replace(ma,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c));if(O){if(!(l=K))P&&"interactive"===P.readyState||M(document.getElementsByTagName("script"),
|
|
||||||
function(b){if("interactive"===b.readyState)return P=b}),l=P;l&&(b||(b=l.getAttribute("data-requiremodule")),h=F[l.getAttribute("data-requirecontext")])}(h?h.defQueue:T).push([b,c,d])};define.amd={jQuery:!0};l.exec=function(b){return eval(b)};l(r)}})(this);
|
|
535
test/lib/resemble.js
Normal file
|
@ -0,0 +1,535 @@
|
||||||
|
/*
|
||||||
|
Author: James Cryer
|
||||||
|
Company: Huddle
|
||||||
|
Last updated date: 21 Feb 2013
|
||||||
|
URL: https://github.com/Huddle/Resemble.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(_this){
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
_this['resemble'] = function( fileData ){
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
var images = [];
|
||||||
|
var updateCallbackArray = [];
|
||||||
|
|
||||||
|
var tolerance = { // between 0 and 255
|
||||||
|
red: 16,
|
||||||
|
green: 16,
|
||||||
|
blue: 16,
|
||||||
|
minBrightness: 16,
|
||||||
|
maxBrightness: 240
|
||||||
|
};
|
||||||
|
|
||||||
|
var ignoreAntialiasing = false;
|
||||||
|
var ignoreColors = false;
|
||||||
|
|
||||||
|
function triggerDataUpdate(){
|
||||||
|
var len = updateCallbackArray.length;
|
||||||
|
var i;
|
||||||
|
for(i=0;i<len;i++){
|
||||||
|
if (typeof updateCallbackArray[i] === 'function'){
|
||||||
|
updateCallbackArray[i](data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loop(x, y, callback){
|
||||||
|
var i,j;
|
||||||
|
|
||||||
|
for (i=0;i<x;i++){
|
||||||
|
for (j=0;j<y;j++){
|
||||||
|
callback(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseImage(sourceImageData, width, height){
|
||||||
|
|
||||||
|
var pixleCount = 0;
|
||||||
|
var redTotal = 0;
|
||||||
|
var greenTotal = 0;
|
||||||
|
var blueTotal = 0;
|
||||||
|
var brightnessTotal = 0;
|
||||||
|
|
||||||
|
loop(height, width, function(verticalPos, horizontalPos){
|
||||||
|
var offset = (verticalPos*width + horizontalPos) * 4;
|
||||||
|
var red = sourceImageData[offset];
|
||||||
|
var green = sourceImageData[offset + 1];
|
||||||
|
var blue = sourceImageData[offset + 2];
|
||||||
|
var brightness = getBrightness(red,green,blue);
|
||||||
|
|
||||||
|
pixleCount++;
|
||||||
|
|
||||||
|
redTotal += red / 255 * 100;
|
||||||
|
greenTotal += green / 255 * 100;
|
||||||
|
blueTotal += blue / 255 * 100;
|
||||||
|
brightnessTotal += brightness / 255 * 100;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.red = Math.floor(redTotal / pixleCount);
|
||||||
|
data.green = Math.floor(greenTotal / pixleCount);
|
||||||
|
data.blue = Math.floor(blueTotal / pixleCount);
|
||||||
|
data.brightness = Math.floor(brightnessTotal / pixleCount);
|
||||||
|
|
||||||
|
triggerDataUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadImageData( fileData, callback ){
|
||||||
|
var fileReader,
|
||||||
|
hiddenImage = new Image();
|
||||||
|
|
||||||
|
hiddenImage.onload = function() {
|
||||||
|
|
||||||
|
var hiddenCanvas = document.createElement('canvas');
|
||||||
|
var imageData;
|
||||||
|
var width = hiddenImage.width;
|
||||||
|
var height = hiddenImage.height;
|
||||||
|
|
||||||
|
hiddenCanvas.width = width;
|
||||||
|
hiddenCanvas.height = height;
|
||||||
|
hiddenCanvas.getContext('2d').drawImage(hiddenImage, 0, 0, width, height);
|
||||||
|
imageData = hiddenCanvas.getContext('2d').getImageData(0, 0, width, height);
|
||||||
|
|
||||||
|
images.push(imageData);
|
||||||
|
|
||||||
|
callback(imageData, width, height);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof fileData === 'string') {
|
||||||
|
hiddenImage.src = fileData;
|
||||||
|
} else {
|
||||||
|
fileReader = new FileReader();
|
||||||
|
fileReader.onload = function (event) {
|
||||||
|
hiddenImage.src = event.target.result;
|
||||||
|
};
|
||||||
|
fileReader.readAsDataURL(fileData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isColorSimilar(a, b, color){
|
||||||
|
|
||||||
|
var absDiff = Math.abs(a - b);
|
||||||
|
|
||||||
|
if(typeof a === 'undefined'){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(typeof b === 'undefined'){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(a === b){
|
||||||
|
return true;
|
||||||
|
} else if ( absDiff < tolerance[color] ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNumber(n) {
|
||||||
|
return !isNaN(parseFloat(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPixelBrightnessSimilar(d1, d2){
|
||||||
|
return Math.abs(d1.brightness - d2.brightness) < tolerance.minBrightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBrightness(r,g,b){
|
||||||
|
return 0.3*r + 0.59*g + 0.11*b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRGBSame(d1,d2){
|
||||||
|
var red = d1.r === d2.r;
|
||||||
|
var green = d1.g === d2.g;
|
||||||
|
var blue = d1.b === d2.b;
|
||||||
|
return red && green && blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRGBSimilar(d1, d2){
|
||||||
|
var red = isColorSimilar(d1.r,d2.r,'red');
|
||||||
|
var green = isColorSimilar(d1.g,d2.g,'green');
|
||||||
|
var blue = isColorSimilar(d1.b,d2.b,'blue');
|
||||||
|
|
||||||
|
return red && green && blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isContrasting(d1, d2){
|
||||||
|
return Math.abs(d1.brightness - d2.brightness) > tolerance.maxBrightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHue(r,g,b){
|
||||||
|
|
||||||
|
r = r / 255;
|
||||||
|
g = g / 255;
|
||||||
|
b = b / 255;
|
||||||
|
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
||||||
|
var h;
|
||||||
|
var d;
|
||||||
|
|
||||||
|
if (max == min){
|
||||||
|
h = 0; // achromatic
|
||||||
|
} else{
|
||||||
|
d = max - min;
|
||||||
|
switch(max){
|
||||||
|
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||||
|
case g: h = (b - r) / d + 2; break;
|
||||||
|
case b: h = (r - g) / d + 4; break;
|
||||||
|
}
|
||||||
|
h /= 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAntialiased(sourcePix, data, cacheSet, verticalPos, horizontalPos, width){
|
||||||
|
var offset;
|
||||||
|
var targetPix;
|
||||||
|
var distance = 1;
|
||||||
|
var i;
|
||||||
|
var j;
|
||||||
|
var hasHighContrastSibling = 0;
|
||||||
|
var hasSiblingWithDifferentHue = 0;
|
||||||
|
var hasEquivilantSibling = 0;
|
||||||
|
|
||||||
|
addHueInfo(sourcePix);
|
||||||
|
|
||||||
|
for (i = distance*-1; i <= distance; i++){
|
||||||
|
for (j = distance*-1; j <= distance; j++){
|
||||||
|
|
||||||
|
if(i===0 && j===0){
|
||||||
|
// ignore source pixel
|
||||||
|
} else {
|
||||||
|
|
||||||
|
offset = ((verticalPos+j)*width + (horizontalPos+i)) * 4;
|
||||||
|
targetPix = getPixelInfo(data, offset, cacheSet);
|
||||||
|
|
||||||
|
if(targetPix === null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addBrightnessInfo(targetPix);
|
||||||
|
addHueInfo(targetPix);
|
||||||
|
|
||||||
|
if( isContrasting(sourcePix, targetPix) ){
|
||||||
|
hasHighContrastSibling++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( isRGBSame(sourcePix,targetPix) ){
|
||||||
|
hasEquivilantSibling++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( Math.abs(targetPix.h - sourcePix.h) > 0.3 ){
|
||||||
|
hasSiblingWithDifferentHue++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasSiblingWithDifferentHue > 1 || hasHighContrastSibling > 1){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasEquivilantSibling < 2){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorPixel(px, offset){
|
||||||
|
px[offset] = 255; //r
|
||||||
|
px[offset + 1] = 0; //g
|
||||||
|
px[offset + 2] = 255; //b
|
||||||
|
px[offset + 3] = 255; //a
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPixel(px, offset, data){
|
||||||
|
px[offset] = data.r; //r
|
||||||
|
px[offset + 1] = data.g; //g
|
||||||
|
px[offset + 2] = data.b; //b
|
||||||
|
px[offset + 3] = 255; //a
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyGrayScalePixel(px, offset, data){
|
||||||
|
px[offset] = data.brightness; //r
|
||||||
|
px[offset + 1] = data.brightness; //g
|
||||||
|
px[offset + 2] = data.brightness; //b
|
||||||
|
px[offset + 3] = 255; //a
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getPixelInfo(data, offset, cacheSet){
|
||||||
|
var r;
|
||||||
|
var g;
|
||||||
|
var b;
|
||||||
|
var d;
|
||||||
|
|
||||||
|
if(typeof data[offset] !== 'undefined'){
|
||||||
|
r = data[offset];
|
||||||
|
g = data[offset+1];
|
||||||
|
b = data[offset+2];
|
||||||
|
d = {
|
||||||
|
r: r,
|
||||||
|
g: g,
|
||||||
|
b: b
|
||||||
|
};
|
||||||
|
|
||||||
|
return d;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBrightnessInfo(data){
|
||||||
|
data.brightness = getBrightness(data.r,data.g,data.b); // 'corrected' lightness
|
||||||
|
}
|
||||||
|
|
||||||
|
function addHueInfo(data){
|
||||||
|
data.h = getHue(data.r,data.g,data.b);
|
||||||
|
}
|
||||||
|
|
||||||
|
function analyseImages(img1, img2, width, height){
|
||||||
|
|
||||||
|
var hiddenCanvas = document.createElement('canvas');
|
||||||
|
|
||||||
|
var data1 = img1.data;
|
||||||
|
var data2 = img2.data;
|
||||||
|
|
||||||
|
hiddenCanvas.width = width;
|
||||||
|
hiddenCanvas.height = height;
|
||||||
|
|
||||||
|
var context = hiddenCanvas.getContext('2d');
|
||||||
|
var imgd = context.createImageData(width,height);
|
||||||
|
var targetPix = imgd.data;
|
||||||
|
|
||||||
|
var mismatchCount = 0;
|
||||||
|
|
||||||
|
var time = Date.now();
|
||||||
|
|
||||||
|
var skip;
|
||||||
|
|
||||||
|
if( (width > 1200 || height > 1200) && ignoreAntialiasing){
|
||||||
|
skip = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
loop(height, width, function(verticalPos, horizontalPos){
|
||||||
|
|
||||||
|
if(skip){ // only skip if the image isn't small
|
||||||
|
if(verticalPos % skip === 0 || horizontalPos % skip === 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var offset = (verticalPos*width + horizontalPos) * 4;
|
||||||
|
var pixel1 = getPixelInfo(data1, offset, 1);
|
||||||
|
var pixel2 = getPixelInfo(data2, offset, 2);
|
||||||
|
|
||||||
|
if(pixel1 === null || pixel2 === null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ignoreColors){
|
||||||
|
|
||||||
|
addBrightnessInfo(pixel1);
|
||||||
|
addBrightnessInfo(pixel2);
|
||||||
|
|
||||||
|
if( isPixelBrightnessSimilar(pixel1, pixel2) ){
|
||||||
|
copyGrayScalePixel(targetPix, offset, pixel2);
|
||||||
|
} else {
|
||||||
|
errorPixel(targetPix, offset);
|
||||||
|
mismatchCount++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( isRGBSimilar(pixel1, pixel2) ){
|
||||||
|
copyPixel(targetPix, offset, pixel2);
|
||||||
|
|
||||||
|
} else if( ignoreAntialiasing && (
|
||||||
|
addBrightnessInfo(pixel1), // jit pixel info augmentation looks a little weird, sorry.
|
||||||
|
addBrightnessInfo(pixel2),
|
||||||
|
isAntialiased(pixel1, data1, 1, verticalPos, horizontalPos, width) ||
|
||||||
|
isAntialiased(pixel2, data2, 2, verticalPos, horizontalPos, width)
|
||||||
|
)){
|
||||||
|
|
||||||
|
if( isPixelBrightnessSimilar(pixel1, pixel2) ){
|
||||||
|
copyGrayScalePixel(targetPix, offset, pixel2);
|
||||||
|
} else {
|
||||||
|
errorPixel(targetPix, offset);
|
||||||
|
mismatchCount++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errorPixel(targetPix, offset);
|
||||||
|
mismatchCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
data.misMatchPercentage = (mismatchCount / (height*width) * 100).toFixed(2);
|
||||||
|
data.analysisTime = Date.now() - time;
|
||||||
|
|
||||||
|
data.getImageDataUrl = function(text){
|
||||||
|
var barHeight = 0;
|
||||||
|
|
||||||
|
if(text){
|
||||||
|
barHeight = addLabel(text,context,hiddenCanvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
context.putImageData(imgd, 0, barHeight);
|
||||||
|
|
||||||
|
return hiddenCanvas.toDataURL("image/png");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function addLabel(text, context, hiddenCanvas){
|
||||||
|
var textPadding = 2;
|
||||||
|
|
||||||
|
context.font = '12px sans-serif';
|
||||||
|
|
||||||
|
var textWidth = context.measureText(text).width + textPadding*2;
|
||||||
|
var barHeight = 22;
|
||||||
|
|
||||||
|
if(textWidth > hiddenCanvas.width){
|
||||||
|
hiddenCanvas.width = textWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
hiddenCanvas.height += barHeight;
|
||||||
|
|
||||||
|
context.fillStyle = "#666";
|
||||||
|
context.fillRect(0,0,hiddenCanvas.width,barHeight -4);
|
||||||
|
context.fillStyle = "#fff";
|
||||||
|
context.fillRect(0,barHeight -4,hiddenCanvas.width, 4);
|
||||||
|
|
||||||
|
context.fillStyle = "#fff";
|
||||||
|
context.textBaseline = "top";
|
||||||
|
context.font = '12px sans-serif';
|
||||||
|
context.fillText(text, textPadding, 1);
|
||||||
|
|
||||||
|
return barHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalise(img, w, h){
|
||||||
|
var c;
|
||||||
|
var context;
|
||||||
|
|
||||||
|
if(img.height < h || img.width < w){
|
||||||
|
c = document.createElement('canvas');
|
||||||
|
c.width = w;
|
||||||
|
c.height = h;
|
||||||
|
context = c.getContext('2d');
|
||||||
|
context.putImageData(img, 0, 0);
|
||||||
|
return context.getImageData(0, 0, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
|
function compare(one, two){
|
||||||
|
|
||||||
|
function onceWeHaveBoth(){
|
||||||
|
var width;
|
||||||
|
var height;
|
||||||
|
if(images.length === 2){
|
||||||
|
width = images[0].width > images[1].width ? images[0].width : images[1].width;
|
||||||
|
height = images[0].height > images[1].height ? images[0].height : images[1].height;
|
||||||
|
|
||||||
|
if( (images[0].width === images[1].width) && (images[0].height === images[1].height) ){
|
||||||
|
data.isSameDimensions = true;
|
||||||
|
} else {
|
||||||
|
data.isSameDimensions = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height);
|
||||||
|
|
||||||
|
triggerDataUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
images = [];
|
||||||
|
loadImageData(one, onceWeHaveBoth);
|
||||||
|
loadImageData(two, onceWeHaveBoth);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCompareApi(param){
|
||||||
|
|
||||||
|
var secondFileData,
|
||||||
|
hasMethod = typeof param === 'function';
|
||||||
|
|
||||||
|
if( !hasMethod ){
|
||||||
|
// assume it's file data
|
||||||
|
secondFileData = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = {
|
||||||
|
ignoreNothing: function(){
|
||||||
|
|
||||||
|
tolerance.red = 16;
|
||||||
|
tolerance.green = 16;
|
||||||
|
tolerance.blue = 16;
|
||||||
|
tolerance.minBrightness = 16;
|
||||||
|
tolerance.maxBrightness = 240;
|
||||||
|
|
||||||
|
ignoreAntialiasing = false;
|
||||||
|
ignoreColors = false;
|
||||||
|
|
||||||
|
if(hasMethod) { param(); }
|
||||||
|
return self;
|
||||||
|
},
|
||||||
|
ignoreAntialiasing: function(){
|
||||||
|
|
||||||
|
tolerance.red = 32;
|
||||||
|
tolerance.green = 32;
|
||||||
|
tolerance.blue = 32;
|
||||||
|
tolerance.minBrightness = 64;
|
||||||
|
tolerance.maxBrightness = 96;
|
||||||
|
|
||||||
|
ignoreAntialiasing = true;
|
||||||
|
ignoreColors = false;
|
||||||
|
|
||||||
|
if(hasMethod) { param(); }
|
||||||
|
return self;
|
||||||
|
},
|
||||||
|
ignoreColors: function(){
|
||||||
|
|
||||||
|
tolerance.minBrightness = 16;
|
||||||
|
tolerance.maxBrightness = 240;
|
||||||
|
|
||||||
|
ignoreAntialiasing = false;
|
||||||
|
ignoreColors = true;
|
||||||
|
|
||||||
|
if(hasMethod) { param(); }
|
||||||
|
return self;
|
||||||
|
},
|
||||||
|
onComplete: function( callback ){
|
||||||
|
|
||||||
|
updateCallbackArray.push(callback);
|
||||||
|
|
||||||
|
var wrapper = function(){
|
||||||
|
compare(fileData, secondFileData);
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapper();
|
||||||
|
|
||||||
|
return getCompareApi(wrapper);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
onComplete: function( callback ){
|
||||||
|
updateCallbackArray.push(callback);
|
||||||
|
loadImageData(fileData, function(imageData, width, height){
|
||||||
|
parseImage(imageData.data, width, height);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
compareTo: function(secondFileData){
|
||||||
|
return getCompareApi(secondFileData);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}(this));
|
|
@ -1,36 +0,0 @@
|
||||||
requirejs.config({
|
|
||||||
baseUrl: '/test/unit/'
|
|
||||||
});
|
|
||||||
|
|
||||||
define(function(require) {
|
|
||||||
var testModules = [
|
|
||||||
'Pixi',
|
|
||||||
'Point',
|
|
||||||
'Rectangle',
|
|
||||||
'DisplayObject',
|
|
||||||
'DisplayObjectContainer',
|
|
||||||
'Sprite',
|
|
||||||
'MovieClip',
|
|
||||||
'InteractionManager',
|
|
||||||
'Stage',
|
|
||||||
'utils/Utils',
|
|
||||||
'utils/EventTarget',
|
|
||||||
'utils/Matrix',
|
|
||||||
'utils/Detector',
|
|
||||||
'renderers/WebGLShaders',
|
|
||||||
'renderers/WebGLRenderer',
|
|
||||||
'renderers/WebGLBatch',
|
|
||||||
'renderers/CanvasRenderer',
|
|
||||||
'extras/Strip',
|
|
||||||
'extras/Rope',
|
|
||||||
'textures/BaseTexture',
|
|
||||||
'textures/Texture',
|
|
||||||
'loaders/SpriteSheetLoader',
|
|
||||||
'loaders/AssetLoader'
|
|
||||||
];
|
|
||||||
|
|
||||||
// Resolve all testModules and then start the Test Runner.
|
|
||||||
require(testModules, function() {
|
|
||||||
QUnit.start();
|
|
||||||
});
|
|
||||||
});
|
|
BIN
test/textures/SpriteSheet-Aliens.png
Normal file
After Width: | Height: | Size: 142 KiB |
BIN
test/textures/SpriteSheet-Explosion.png
Executable file
After Width: | Height: | Size: 899 KiB |
BIN
test/textures/bunny.png
Normal file
After Width: | Height: | Size: 449 B |
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('DisplayObject');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('DisplayObjectContainer');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('InteractionManager');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('MovieClip');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Pixi');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Point');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Rectangle');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Sprite');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Stage');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Rope');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Strip');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('AssetLoader');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('SpriteSheetLoader');
|
|
||||||
});
|
|
10
test/unit/pixi/InteractionManager.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/InteractionManager', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var InteractionManager = PIXI.InteractionManager;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(InteractionManager).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
9
test/unit/pixi/Pixi.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
describe('pixi/Pixi', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(global).to.have.property('PIXI').and.to.be.an('object');
|
||||||
|
});
|
||||||
|
});
|
22
test/unit/pixi/core/Circle.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
describe('pixi/core/Circle', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Circle = PIXI.Circle;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Circle).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Circle();
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Circle);
|
||||||
|
expect(obj).to.respondTo('clone');
|
||||||
|
expect(obj).to.respondTo('contains');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('x', 0);
|
||||||
|
expect(obj).to.have.property('y', 0);
|
||||||
|
expect(obj).to.have.property('radius', 0);
|
||||||
|
});
|
||||||
|
});
|
24
test/unit/pixi/core/Ellipse.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
describe('pixi/core/Ellipse', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Ellipse = PIXI.Ellipse;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Ellipse).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Ellipse();
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Ellipse);
|
||||||
|
expect(obj).to.respondTo('clone');
|
||||||
|
expect(obj).to.respondTo('contains');
|
||||||
|
expect(obj).to.respondTo('getBounds');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('x', 0);
|
||||||
|
expect(obj).to.have.property('y', 0);
|
||||||
|
expect(obj).to.have.property('width', 0);
|
||||||
|
expect(obj).to.have.property('height', 0);
|
||||||
|
});
|
||||||
|
});
|
30
test/unit/pixi/core/Matrix.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
describe('pixi/core/Matrix', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var mat3 = PIXI.mat3;
|
||||||
|
var mat4 = PIXI.mat4;
|
||||||
|
var Matrix = PIXI.Matrix;
|
||||||
|
|
||||||
|
it('Ensure determineMatrixArrayType works', function () {
|
||||||
|
expect(Matrix).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('mat3 exists', function () {
|
||||||
|
expect(mat3).to.be.an('object');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new mat3 matrix', function () {
|
||||||
|
var matrix = new mat3.create();
|
||||||
|
pixi_core_Matrix_confirmNewMat3(matrix);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('mat3 exists', function () {
|
||||||
|
expect(mat4).to.be.an('object');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new mat4 matrix', function () {
|
||||||
|
var matrix = new mat4.create();
|
||||||
|
pixi_core_Matrix_confirmNewMat4(matrix);
|
||||||
|
});
|
||||||
|
});
|
15
test/unit/pixi/core/Point.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
describe('pixi/core/Point', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Point = PIXI.Point;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Point).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Point();
|
||||||
|
pixi_core_Point_confirm(obj, 0, 0);
|
||||||
|
});
|
||||||
|
});
|
20
test/unit/pixi/core/Polygon.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
describe('pixi/core/Polygon', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Polygon = PIXI.Polygon;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Polygon).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Polygon();
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Polygon);
|
||||||
|
expect(obj).to.respondTo('clone');
|
||||||
|
expect(obj).to.respondTo('contains');
|
||||||
|
|
||||||
|
expect(obj).to.have.deep.property('points.length', 0);
|
||||||
|
});
|
||||||
|
});
|
15
test/unit/pixi/core/Rectangle.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
describe('pixi/core/Rectangle', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Rectangle = PIXI.Rectangle;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Rectangle).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var rect = new Rectangle();
|
||||||
|
pixi_core_Rectangle_confirm(rect, 0, 0, 0, 0);
|
||||||
|
});
|
||||||
|
});
|
21
test/unit/pixi/display/DisplayObject.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
describe('pixi/display/DisplayObject', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var DisplayObject = PIXI.DisplayObject;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(DisplayObject).to.be.a('function');
|
||||||
|
expect(PIXI).to.have.property('visibleCount', 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new DisplayObject();
|
||||||
|
|
||||||
|
pixi_display_DisplayObject_confirmNew(obj);
|
||||||
|
expect(obj).to.have.property('hitArea', null);
|
||||||
|
expect(obj).to.have.property('interactive', false);
|
||||||
|
expect(obj).to.have.property('renderable', false);
|
||||||
|
expect(obj).to.have.property('stage', null);
|
||||||
|
});
|
||||||
|
});
|
20
test/unit/pixi/display/DisplayObjectContainer.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
describe('pixi/display/DisplayObjectContainer', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var DisplayObjectContainer = PIXI.DisplayObjectContainer;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(DisplayObjectContainer).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new DisplayObjectContainer();
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
expect(obj).to.have.property('hitArea', null);
|
||||||
|
expect(obj).to.have.property('interactive', false);
|
||||||
|
expect(obj).to.have.property('renderable', false);
|
||||||
|
expect(obj).to.have.property('stage', null);
|
||||||
|
});
|
||||||
|
});
|
33
test/unit/pixi/display/MovieClip.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
describe('pixi/display/MovieClip', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var MovieClip = PIXI.MovieClip;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(MovieClip).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function (done) {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Explosion.png');
|
||||||
|
var obj = new MovieClip([texture]);
|
||||||
|
|
||||||
|
pixi_display_Sprite_confirmNew(obj, done);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(MovieClip);
|
||||||
|
expect(obj).to.respondTo('stop');
|
||||||
|
expect(obj).to.respondTo('play');
|
||||||
|
expect(obj).to.respondTo('gotoAndStop');
|
||||||
|
expect(obj).to.respondTo('gotoAndPlay');
|
||||||
|
expect(obj).to.respondTo('updateTransform');
|
||||||
|
|
||||||
|
expect(obj).to.have.deep.property('textures.length', 1);
|
||||||
|
expect(obj).to.have.deep.property('textures[0]', texture);
|
||||||
|
expect(obj).to.have.property('animationSpeed', 1);
|
||||||
|
expect(obj).to.have.property('loop', true);
|
||||||
|
expect(obj).to.have.property('onComplete', null);
|
||||||
|
expect(obj).to.have.property('currentFrame', 0);
|
||||||
|
expect(obj).to.have.property('playing', false);
|
||||||
|
});
|
||||||
|
});
|
25
test/unit/pixi/display/Sprite.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
describe('pixi/display/Sprite', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Sprite = PIXI.Sprite;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Sprite).to.be.a('function');
|
||||||
|
expect(PIXI).to.have.deep.property('blendModes.NORMAL', 0);
|
||||||
|
expect(PIXI).to.have.deep.property('blendModes.SCREEN', 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Members exist', function () {
|
||||||
|
expect(Sprite).itself.to.respondTo('fromImage');
|
||||||
|
expect(Sprite).itself.to.respondTo('fromFrame');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function (done) {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/SpriteSheet-Aliens.png');
|
||||||
|
var obj = new Sprite(texture);
|
||||||
|
|
||||||
|
pixi_display_Sprite_confirmNew(obj, done);
|
||||||
|
});
|
||||||
|
});
|
49
test/unit/pixi/display/Stage.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
describe('pixi/display/Stage', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Stage = PIXI.Stage;
|
||||||
|
var InteractionManager = PIXI.InteractionManager;
|
||||||
|
var Rectangle = PIXI.Rectangle;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Stage).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Stage(null, true);
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Stage);
|
||||||
|
expect(obj).to.respondTo('updateTransform');
|
||||||
|
expect(obj).to.respondTo('setBackgroundColor');
|
||||||
|
expect(obj).to.respondTo('getMousePosition');
|
||||||
|
|
||||||
|
// FIXME: duplicate member in DisplayObject
|
||||||
|
pixi_core_Matrix_confirmNewMat3(obj.worldTransform);
|
||||||
|
// FIXME: convert arg to bool in constructor
|
||||||
|
expect(obj).to.have.property('interactive', true);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('interactionManager')
|
||||||
|
.and.to.be.an.instanceof(InteractionManager)
|
||||||
|
.and.to.have.property('stage', obj);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('dirty', true);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('stage', obj);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('hitArea')
|
||||||
|
.and.to.be.an.instanceof(Rectangle);
|
||||||
|
pixi_core_Rectangle_confirm(obj.hitArea, 0, 0, 100000, 100000);
|
||||||
|
|
||||||
|
expect(obj).to.have.property('backgroundColor', 0x000000);
|
||||||
|
expect(obj).to.have.deep.property('backgroundColorSplit.length', 3);
|
||||||
|
expect(obj).to.have.deep.property('backgroundColorSplit[0]', 0);
|
||||||
|
expect(obj).to.have.deep.property('backgroundColorSplit[1]', 0);
|
||||||
|
expect(obj).to.have.deep.property('backgroundColorSplit[2]', 0);
|
||||||
|
expect(obj).to.have.property('backgroundColorString', '#000000');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('worldVisible', true);
|
||||||
|
});
|
||||||
|
});
|
21
test/unit/pixi/extras/CustomRenderable.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
describe('pixi/extras/CustomRenderable', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var CustomRenderable = PIXI.CustomRenderable;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(CustomRenderable).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new CustomRenderable();
|
||||||
|
|
||||||
|
pixi_display_DisplayObject_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(CustomRenderable);
|
||||||
|
expect(obj).to.respondTo('renderCanvas');
|
||||||
|
expect(obj).to.respondTo('initWebGL');
|
||||||
|
expect(obj).to.respondTo('renderWebGL');
|
||||||
|
});
|
||||||
|
});
|
26
test/unit/pixi/extras/Rope.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
describe('pixi/extras/Rope', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Rope = PIXI.Rope;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
var Point = PIXI.Point;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Rope).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/bunny.png');
|
||||||
|
var obj = new Rope(texture, [new Point(), new Point(5, 10), new Point(10, 20)]);
|
||||||
|
|
||||||
|
pixi_extras_Strip_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Rope);
|
||||||
|
expect(obj).to.respondTo('refresh');
|
||||||
|
expect(obj).to.respondTo('updateTransform');
|
||||||
|
expect(obj).to.respondTo('setTexture');
|
||||||
|
|
||||||
|
// TODO: Test properties
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/extras/Spine.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/extras/Spine', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Spine = PIXI.Spine;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Spine).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
18
test/unit/pixi/extras/Strip.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
describe('pixi/extras/Strip', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Strip = PIXI.Strip;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Strip).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/bunny.png');
|
||||||
|
var obj = new Strip(texture, 20, 10000);
|
||||||
|
|
||||||
|
pixi_extras_Strip_confirmNew(obj);
|
||||||
|
});
|
||||||
|
});
|
24
test/unit/pixi/extras/TilingSprite.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
describe('pixi/extras/TilingSprite', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var TilingSprite = PIXI.TilingSprite;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(TilingSprite).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/bunny.png');
|
||||||
|
var obj = new TilingSprite(texture, 6000, 12000);
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(TilingSprite);
|
||||||
|
expect(obj).to.respondTo('setTexture');
|
||||||
|
expect(obj).to.respondTo('onTextureUpdate');
|
||||||
|
|
||||||
|
// TODO: Test properties
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/filters/FilterBlock.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/filters/FilterBlock', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var FilterBlock = PIXI.FilterBlock;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(FilterBlock).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/filters/MaskFilter.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/filters/MaskFilter', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
// var MaskFilter = PIXI.MaskFilter;
|
||||||
|
|
||||||
|
// it('Module exists', function () {
|
||||||
|
// expect(MaskFilter).to.be.a('function');
|
||||||
|
// });
|
||||||
|
});
|
10
test/unit/pixi/loaders/AssetLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/AssetLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var AssetLoader = PIXI.AssetLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(AssetLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/loaders/BitmapFontLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/BitmapFontLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var BitmapFontLoader = PIXI.BitmapFontLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(PIXI.BitmapFontLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/loaders/ImageLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/ImageLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var ImageLoader = PIXI.ImageLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(ImageLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/loaders/JsonLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/JsonLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var JsonLoader = PIXI.JsonLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(JsonLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/loaders/SpineLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/SpineLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var SpineLoader = PIXI.SpineLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(SpineLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/loaders/SpriteSheetLoader.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/loaders/SpriteSheetLoader', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var SpriteSheetLoader = PIXI.SpriteSheetLoader;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(SpriteSheetLoader).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
40
test/unit/pixi/primitives/Graphics.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
describe('pixi/primitives/Graphics', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Graphics = PIXI.Graphics;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Graphics).to.be.a('function');
|
||||||
|
|
||||||
|
expect(Graphics).itself.to.have.property('POLY', 0);
|
||||||
|
expect(Graphics).itself.to.have.property('RECT', 1);
|
||||||
|
expect(Graphics).itself.to.have.property('CIRC', 2);
|
||||||
|
expect(Graphics).itself.to.have.property('ELIP', 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = new Graphics();
|
||||||
|
|
||||||
|
pixi_display_DisplayObjectContainer_confirmNew(obj);
|
||||||
|
|
||||||
|
expect(obj).to.be.an.instanceof(Graphics);
|
||||||
|
expect(obj).to.respondTo('lineStyle');
|
||||||
|
expect(obj).to.respondTo('lineStyle');
|
||||||
|
expect(obj).to.respondTo('moveTo');
|
||||||
|
expect(obj).to.respondTo('lineTo');
|
||||||
|
expect(obj).to.respondTo('beginFill');
|
||||||
|
expect(obj).to.respondTo('endFill');
|
||||||
|
expect(obj).to.respondTo('drawRect');
|
||||||
|
expect(obj).to.respondTo('drawCircle');
|
||||||
|
expect(obj).to.respondTo('drawElipse');
|
||||||
|
expect(obj).to.respondTo('clear');
|
||||||
|
|
||||||
|
expect(obj).to.have.property('renderable', true);
|
||||||
|
expect(obj).to.have.property('fillAlpha', 1);
|
||||||
|
expect(obj).to.have.property('lineWidth', 0);
|
||||||
|
expect(obj).to.have.property('lineColor', 'black');
|
||||||
|
expect(obj).to.have.deep.property('graphicsData.length', 0);
|
||||||
|
expect(obj).to.have.deep.property('currentPath.points.length', 0);
|
||||||
|
});
|
||||||
|
});
|
15
test/unit/pixi/renderers/canvas/CanvasGraphics.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
describe('renders/canvas/CanvasGraphics', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var CanvasGraphics = PIXI.CanvasGraphics;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(CanvasGraphics).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Members exist', function () {
|
||||||
|
expect(CanvasGraphics).itself.to.respondTo('renderGraphics');
|
||||||
|
expect(CanvasGraphics).itself.to.respondTo('renderGraphicsMask');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/renderers/canvas/CanvasRenderer.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('renderers/canvas/CanvasRenderer', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var CanvasRenderer = PIXI.CanvasRenderer;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(CanvasRenderer).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/renderers/webgl/WebGLBatch.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('renderers/webgl/WebGLBatch', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var WebGLBatch = PIXI.WebGLBatch;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(WebGLBatch).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
19
test/unit/pixi/renderers/webgl/WebGLGraphics.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
describe('renderers/wegbl/WebGLGraphics', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var WebGLGraphics = PIXI.WebGLGraphics;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(WebGLGraphics).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Members exist', function () {
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('renderGraphics');
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('updateGraphics');
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('buildRectangle');
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('buildCircle');
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('buildLine');
|
||||||
|
expect(WebGLGraphics).itself.to.respondTo('buildPoly');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/renderers/webgl/WebGLRenderGroup.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('renderers/webgl/WebGLRenderGroup', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var WebGLRenderGroup = PIXI.WebGLRenderGroup;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(WebGLRenderGroup).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/renderers/webgl/WebGLRenderer.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('renderers/webgl/WebGLRenderer', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var WebGLRenderer = PIXI.WebGLRenderer;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(WebGLRenderer).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
13
test/unit/pixi/renderers/webgl/WebGLShaders.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
describe('renderers/webgl/WebGLShaders', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
it('Module members exist', function () {
|
||||||
|
expect(PIXI).to.respondTo('initPrimitiveShader');
|
||||||
|
expect(PIXI).to.respondTo('initDefaultShader');
|
||||||
|
expect(PIXI).to.respondTo('initDefaultStripShader');
|
||||||
|
expect(PIXI).to.respondTo('activateDefaultShader');
|
||||||
|
expect(PIXI).to.respondTo('activatePrimitiveShader');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/text/BitmapText.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/text/BitmapText', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var BitmapText = PIXI.BitmapText;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(BitmapText).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/text/Text.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/text/Text', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Text = PIXI.Text;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Text).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
13
test/unit/pixi/textures/BaseTexture.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
describe('pixi/textures/BaseTexture', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var BaseTexture = PIXI.BaseTexture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(BaseTexture).to.be.a('function');
|
||||||
|
expect(PIXI).to.have.property('BaseTextureCache').and.to.be.an('object');
|
||||||
|
expect(PIXI).to.have.deep.property('texturesToUpdate.length');
|
||||||
|
expect(PIXI).to.have.deep.property('texturesToDestroy.length', 0);
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/textures/RenderTexture.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/textures/RenderTexture', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var RenderTexture = PIXI.RenderTexture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(RenderTexture).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
26
test/unit/pixi/textures/Texture.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
describe('pixi/textures/Texture', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var Texture = PIXI.Texture;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(Texture).to.be.a('function');
|
||||||
|
expect(PIXI).to.have.property('TextureCache').and.to.be.an('object');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Members exist', function () {
|
||||||
|
expect(Texture).itself.to.respondTo('fromImage');
|
||||||
|
expect(Texture).itself.to.respondTo('fromFrame');
|
||||||
|
expect(Texture).itself.to.respondTo('fromCanvas');
|
||||||
|
expect(Texture).itself.to.respondTo('addTextureToCache');
|
||||||
|
expect(Texture).itself.to.respondTo('removeTextureFromCache');
|
||||||
|
|
||||||
|
expect(Texture).itself.to.have.deep.property('frameUpdates.length', 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function (done) {
|
||||||
|
var texture = Texture.fromImage('/base/test/textures/bunny.png');
|
||||||
|
pixi_textures_Texture_confirmNew(texture, done);
|
||||||
|
});
|
||||||
|
});
|
10
test/unit/pixi/utils/Detector.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
describe('pixi/utils/Detector', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var autoDetectRenderer = PIXI.autoDetectRenderer;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(autoDetectRenderer).to.be.a('function');
|
||||||
|
});
|
||||||
|
});
|
96
test/unit/pixi/utils/EventTarget.js
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
describe('pixi/utils/EventTarget', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var EventTarget = PIXI.EventTarget;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(EventTarget).to.be.a('function');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Confirm new instance', function () {
|
||||||
|
var obj = {}; EventTarget.call(obj);
|
||||||
|
pixi_utils_EventTarget_like(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('addEventListener and dispatchEvent works', function (done) {
|
||||||
|
var myData = {},
|
||||||
|
obj = {}; EventTarget.call(obj);
|
||||||
|
|
||||||
|
obj.addEventListener('myevent', function (event) {
|
||||||
|
expect(event).to.be.an('object');
|
||||||
|
expect(event).to.have.property('type', 'myevent');
|
||||||
|
expect(event).to.have.property('data', myData);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
obj.dispatchEvent({type: 'myevent', data: myData});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('removeEventListener works', function (done) {
|
||||||
|
var obj = {}; EventTarget.call(obj);
|
||||||
|
|
||||||
|
function onMyEvent() {
|
||||||
|
done(new Error('addEventListener should not have been called'));
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.addEventListener('myevent', onMyEvent);
|
||||||
|
obj.removeEventListener('myevent', onMyEvent);
|
||||||
|
obj.dispatchEvent({type: 'myevent'});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiple dispatches', function () {
|
||||||
|
var called = 0,
|
||||||
|
obj = {}; EventTarget.call(obj);
|
||||||
|
|
||||||
|
function onMyEvent() {
|
||||||
|
called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.addEventListener('myevent', onMyEvent);
|
||||||
|
obj.dispatchEvent({type: 'myevent'});
|
||||||
|
obj.dispatchEvent({type: 'myevent'});
|
||||||
|
obj.dispatchEvent({type: 'myevent'});
|
||||||
|
obj.dispatchEvent({type: 'myevent'});
|
||||||
|
expect(called).to.equal(4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiple events', function () {
|
||||||
|
var called = 0,
|
||||||
|
obj = {}; EventTarget.call(obj);
|
||||||
|
|
||||||
|
function onMyEvent() {
|
||||||
|
called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.addEventListener('myevent1', onMyEvent);
|
||||||
|
obj.addEventListener('myevent2', onMyEvent);
|
||||||
|
obj.addEventListener('myevent3', onMyEvent);
|
||||||
|
obj.dispatchEvent({type: 'myevent1'});
|
||||||
|
obj.dispatchEvent({type: 'myevent2'});
|
||||||
|
obj.dispatchEvent({type: 'myevent3'});
|
||||||
|
expect(called).to.equal(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('multiple events one removed', function () {
|
||||||
|
var called = 0,
|
||||||
|
obj = {}; EventTarget.call(obj);
|
||||||
|
|
||||||
|
function onMyEvent() {
|
||||||
|
called++;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.addEventListener('myevent1', onMyEvent);
|
||||||
|
obj.addEventListener('myevent2', onMyEvent);
|
||||||
|
obj.addEventListener('myevent3', onMyEvent);
|
||||||
|
obj.dispatchEvent({type: 'myevent1'});
|
||||||
|
obj.dispatchEvent({type: 'myevent2'});
|
||||||
|
obj.dispatchEvent({type: 'myevent3'});
|
||||||
|
obj.removeEventListener('myevent2', onMyEvent);
|
||||||
|
obj.dispatchEvent({type: 'myevent1'});
|
||||||
|
obj.dispatchEvent({type: 'myevent2'});
|
||||||
|
obj.dispatchEvent({type: 'myevent3'});
|
||||||
|
expect(called).to.equal(5);
|
||||||
|
});
|
||||||
|
});
|
14
test/unit/pixi/utils/Polyk.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
describe('pixi/utils/Polyk', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
var PolyK = PIXI.PolyK;
|
||||||
|
|
||||||
|
it('Module exists', function () {
|
||||||
|
expect(PolyK).to.be.an('object');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Members exist', function () {
|
||||||
|
expect(PolyK).to.respondTo('Triangulate');
|
||||||
|
});
|
||||||
|
});
|
17
test/unit/pixi/utils/Utils.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
describe('Utils', function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var expect = chai.expect;
|
||||||
|
|
||||||
|
it('requestAnimationFrame exists', function () {
|
||||||
|
expect(global).to.respondTo('requestAnimationFrame');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('cancelAnimationFrame exists', function () {
|
||||||
|
expect(global).to.respondTo('cancelAnimationFrame');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('requestAnimFrame exists', function () {
|
||||||
|
expect(global).to.respondTo('requestAnimFrame');
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('CanvasRenderer');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('WebGLBatch');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('WebGLRenderer');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('WebGLShaders');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('BaseTexture');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Texture');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Detector');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('EventTarget');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Matrix');
|
|
||||||
});
|
|
|
@ -1,3 +0,0 @@
|
||||||
define(function() {
|
|
||||||
Q.module('Utils');
|
|
||||||
});
|
|