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

Remove unncessary CanvasFactory/CMapReaderFactory/FileReaderFactory duplication in unit-tests #12837

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

Given that the API will now, after PR #12039, automatically pick the correct factories to use depending on the environment (browser vs. Node.js), we can utilize that in the unit-tests as well. This way we don't have to manually repeat the same initialization code in multiple unit-tests.
Note: The official PDF.js API is defined in src/pdf.js, hence the new exports in src/display/api.js will not affect that.

Also, updates the unit-test FileReaderFactory helpers similarily.

Drive-by change: Fix the CMapReaderFactory usage in the annotation unit-tests, since the cache should only contain raw data and not a Promise. While this obviously works as-is, having unit-tests that "abuse" the intended data format can easily lead to unnecessary failures if changes are made to the relevant src/core/ code.

…ory` duplication in unit-tests

Given that the API will now, after PR 12039, automatically pick the correct factories to use depending on the environment (browser vs. Node.js), we can utilize that in the unit-tests as well. This way we don't have to manually repeat the same initialization code in *multiple* unit-tests.
*Note:* The *official* PDF.js API is defined in `src/pdf.js`, hence the new exports in `src/display/api.js` will not affect that.

Also, updates the unit-test `FileReaderFactory` helpers similarily.

*Drive-by change:* Fix the `CMapReaderFactory` usage in the annotation unit-tests, since the cache should only contain raw data and not a Promise. While this obviously works as-is, having unit-tests that "abuse" the intended data format can easily lead to unnecessary failures if changes are made to the relevant `src/core/` code.
@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

pdfjsbot commented Jan 8, 2021

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/2b3e23a62ecb660/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 8, 2021

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/9c11f00b522bc61/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 8, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/2b3e23a62ecb660/output.txt

Total script time: 3.59 mins

  • Unit Tests: FAILED

@pdfjsbot
Copy link

pdfjsbot commented Jan 8, 2021

From: Bot.io (Windows)


Success

Full output at http://3.101.106.178:8877/9c11f00b522bc61/output.txt

Total script time: 4.86 mins

  • Unit Tests: Passed

@timvandermeij timvandermeij merged commit 5fed652 into mozilla:master Jan 8, 2021
@timvandermeij
Copy link
Contributor

Nice deduplication!

@Snuffleupagus Snuffleupagus deleted the unit-test-factories branch January 8, 2021 21:42
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