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

Add unit-tests for the onPassword/onProgress callbacks of the API #6540

Merged
merged 1 commit into from
Oct 21, 2015
Merged

Add unit-tests for the onPassword/onProgress callbacks of the API #6540

merged 1 commit into from
Oct 21, 2015

Conversation

Snuffleupagus
Copy link
Collaborator

The standard viewer implicitly depends on the onPassword and onProgress callbacks, in order to open password protected PDF files, respectively to report file loading progress. We currently have no unit-tests for this functionality, which seems unfortunate; hence this patch.

Please note: Rather than adding more unit-tests to api_spec.js, I slightly extended/reworked two existing tests. Specifically for the password test, this does not really change what we actually test, just how the test is done.

var promise = PDFJS.getDocument(basicApiUrl);
waitsForPromiseResolved(promise, function(data) {
expect(data instanceof PDFDocumentProxy).toEqual(true);
var getDocumentPromise = PDFJS.getDocument(basicApiUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

(no action requred by worth mentioning: getDocument returns loadingTask, which contains the promise; we probably need to review the code base to refactor variable names)

@yurydelendik
Copy link
Contributor

Looks good. See if it's easy to address getDocumentPromise naming thing now.

The standard viewer implicitly depends on the `onPassword` and `onProgress` callbacks, in order to open password protected PDF files, respectively to report file loading progress. We currently have no unit-tests for this functionality, which seems unfortunate; hence this patch.

*Please note:* Rather than adding more unit-tests to `api_spec.js`, I slightly extended/reworked two existing tests. Specifically for the password test, this *does not* really change what we actually test, just how the test is done.
@Snuffleupagus
Copy link
Collaborator Author

I've changed this patch to use loadingTask instead of getDocumentPromise.
(The part about more general reviewing/refactoring of variable names in the code-base seemed better suited for a follow-up patch though.)

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.22.172.223:8877/de8ab3fb32c19d8/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/76575b7081eab24/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/76575b7081eab24/output.txt

Total script time: 0.75 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/de8ab3fb32c19d8/output.txt

Total script time: 0.94 mins

  • Unit Tests: Passed

yurydelendik added a commit that referenced this pull request Oct 21, 2015
…Progress-unittests

Add unit-tests for the `onPassword/onProgress` callbacks of the API
@yurydelendik yurydelendik merged commit f12d692 into mozilla:master Oct 21, 2015
@yurydelendik
Copy link
Contributor

Thank you for the patch.

@Snuffleupagus Snuffleupagus deleted the getDocument-onPassword-onProgress-unittests branch October 21, 2015 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants