mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Merge pull request #7689 from hyperlogic/tony/jasmine-avatar-unit-tests
Added avatar unit tests
This commit is contained in:
commit
5ae1e70197
3 changed files with 3570 additions and 0 deletions
53
examples/libraries/jasmine/hifi-boot.js
Normal file
53
examples/libraries/jasmine/hifi-boot.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
(function() {
|
||||
function ConsoleReporter(options) {
|
||||
this.jasmineStarted = function (obj) {
|
||||
print("jasmineStarted: numSpecs = " + obj.totalSpecsDefined);
|
||||
};
|
||||
this.jasmineDone = function (obj) {
|
||||
print("jasmineDone");
|
||||
};
|
||||
this.suiteStarted = function(obj) {
|
||||
print("suiteStarted: \"" + obj.fullName + "\"");
|
||||
};
|
||||
this.suiteDone = function(obj) {
|
||||
print("suiteDone: \"" + obj.fullName + "\" " + obj.status);
|
||||
};
|
||||
this.specStarted = function(obj) {
|
||||
print("specStarted: \"" + obj.fullName + "\"");
|
||||
};
|
||||
this.specDone = function(obj) {
|
||||
print("specDone: \"" + obj.fullName + "\" " + obj.status);
|
||||
|
||||
var i, l = obj.failedExpectations.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
print(" " + obj.failedExpectations[i].message);
|
||||
}
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
setTimeout = Script.setTimeout;
|
||||
setInterval = Script.setInterval;
|
||||
clearTimeout = Script.clearTimeout;
|
||||
clearInterval = Script.clearInterval;
|
||||
|
||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
env.addReporter(new ConsoleReporter());
|
||||
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
extend(this, jasmineInterface);
|
||||
|
||||
function extend(destination, source) {
|
||||
for (var property in source) {
|
||||
destination[property] = source[property];
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
||||
}());
|
||||
|
3458
examples/libraries/jasmine/jasmine.js
Normal file
3458
examples/libraries/jasmine/jasmine.js
Normal file
File diff suppressed because it is too large
Load diff
59
examples/tests/avatarUnitTests.js
Normal file
59
examples/tests/avatarUnitTests.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
Script.include("../libraries/jasmine/jasmine.js");
|
||||
Script.include("../libraries/jasmine/hifi-boot.js");
|
||||
|
||||
// Art3mis
|
||||
var DEFAULT_AVATAR_URL = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/contents/e76946cc-c272-4adf-9bb6-02cde0a4b57d/8fd984ea6fe1495147a3303f87fa6e23.fst?1460131758";
|
||||
|
||||
var ORIGIN = {x: 0, y: 0, z: 0};
|
||||
var ONE_HUNDRED = {x: 100, y: 100, z: 100};
|
||||
var ROT_IDENT = {x: 0, y: 0, z: 0, w: 1};
|
||||
|
||||
describe("MyAvatar", function () {
|
||||
|
||||
// reload the avatar from scratch before each test.
|
||||
beforeEach(function (done) {
|
||||
MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
|
||||
|
||||
// wait until we are finished loading
|
||||
var id = Script.setInterval(function () {
|
||||
if (MyAvatar.jointNames.length == 72) {
|
||||
// assume we are finished loading.
|
||||
Script.clearInterval(id);
|
||||
MyAvatar.position = ORIGIN;
|
||||
MyAvatar.orientation = ROT_IDENT;
|
||||
// give the avatar 1/2 a second to settle on the ground in the idle pose.
|
||||
Script.setTimeout(function () {
|
||||
done();
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// makes the assumption that there is solid ground somewhat underneath the avatar.
|
||||
it("position and orientation getters", function () {
|
||||
var pos = MyAvatar.position;
|
||||
|
||||
expect(Math.abs(pos.x)).toBeLessThan(0.1);
|
||||
expect(Math.abs(pos.y)).toBeLessThan(1.0);
|
||||
expect(Math.abs(pos.z)).toBeLessThan(0.1);
|
||||
|
||||
var rot = MyAvatar.orientation;
|
||||
expect(Math.abs(rot.x)).toBeLessThan(0.01);
|
||||
expect(Math.abs(rot.y)).toBeLessThan(0.01);
|
||||
expect(Math.abs(rot.z)).toBeLessThan(0.01);
|
||||
expect(Math.abs(1 - rot.w)).toBeLessThan(0.01);
|
||||
});
|
||||
|
||||
it("position and orientation setters", function (done) {
|
||||
MyAvatar.position = ONE_HUNDRED;
|
||||
Script.setTimeout(function () {
|
||||
expect(Vec3.length(Vec3.subtract(MyAvatar.position, ONE_HUNDRED))).toBeLessThan(0.1);
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jasmine.getEnv().execute();
|
||||
|
Loading…
Reference in a new issue