Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate b3dm new #16

Merged
merged 8 commits into from
Nov 1, 2016
Merged

Validate b3dm new #16

merged 8 commits into from
Nov 1, 2016

Conversation

JudyWeng
Copy link
Contributor

continuing from #14

@JudyWeng JudyWeng changed the base branch from master to validator-master October 19, 2016 22:19
@lilleyse lilleyse mentioned this pull request Oct 20, 2016
it('validated is a b3dm tile', function(done) {
expect(validateB3dm('./specs/data/Tileset/parent.b3dm')).toBe(true);
expect(validateB3dm(createB3dmTile())).toBe(true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these lines, I'm geting the "Asyc callback was not invoked within timeout specified by jasmne.DEFAULT_TIMEOUT_INTERVEL" error.

I get that I never explicitly called a callback I guess, but realistically, all I needed to do is verify that it is true or false so I tried to follow:
http://jasmine.github.io/2.2/introduction.html

I'm not sure what to put in then() or what to promisify to get a promise (I'm still trying to fully understand promises and promisify).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the done parameter for each spec, this is only needed when the test is asynchronous.

@JudyWeng
Copy link
Contributor Author

I removed the done parameter and just ran the tests. Everything passed. Please let me know if you notice anything that still needs to be changed.

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All minor style issues. Otherwise it all looks great! Sorry about not getting to this sooner.

* {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/TileFormats/Batched3DModel}, False if not.
*/
function validateB3dm(content) {
if(!Cesium.defined(content)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add var defined = Cesium.defined at the top instead.

Also add one space between the if and (, just to keep consistency, here and below.

}

return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline.

var validateB3dm = require('../../lib/validateB3dm');

describe('validateB3dm', function() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace.

});

function createB3dmTile() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace here too, and for the other functions.


var header = new Buffer(24);

header.write('b3bm', 0); // magic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to xxxx or something a little more obvious, for a while I was trying to figure out why this test was passing, before I realized.

header.writeUInt32LE(0, 20); // batchLength

return header;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a duplicate of the function above.

expect(validateB3dm(createInvalidVersion())).toBe(false);
});

it('validated not b3dm tile, wrong byteLength', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test descriptions are a bit awkward. Instead try:

returns true if the b3dm tile is valid, returns false if the b3dm has invalid magic, etc.

@lilleyse
Copy link
Contributor

That's my last comment for this. I'll start opening some new issues for the other tile types.

@lilleyse
Copy link
Contributor

lilleyse commented Nov 1, 2016

Looks good @JudyWeng!

Also in the future make sure to leave a comment after updating so I know the PR is ready.

@lilleyse lilleyse merged commit 17946f8 into validator-master Nov 1, 2016
@lilleyse lilleyse deleted the validate-b3dm-new branch November 1, 2016 17:32
var byteLength = content.readUInt32LE(8);

if (magic !== 'b3dm') {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we just want to return a boolean? Wouldn't we want the user to have a precise error message for which field is the issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm yes and we are doing something similar for validating the tileset #15. @JudyWeng can you open a new PR that fixes this here?

Something simple like:

    if (magic !== 'b3dm') {
        return {
            result : false,
            message : 'Invalid magic'
        };
    }

Also edit the jsDoc so it returns an Object instead of a Boolean. You can look at the code in #15 as an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants