Modernize the font-tests

This patch first of all enables linting of the files in the `test/font/` folder, and secondly it also re-factors all test files to use native `import`/`export` statements. Finally, all tests are now loaded correctly, rather than being included as scripts through the `font_test.html` file.
This commit is contained in:
Jonas Jenwald 2020-10-26 12:12:40 +01:00
parent 71a14be8e7
commit 6967b9dd96
8 changed files with 120 additions and 94 deletions

View File

@ -13,5 +13,4 @@ test/tmp/
test/features/
test/pdfs/
test/resources/
test/font/*_spec.js
*~/

View File

@ -1,10 +1,14 @@
'use strict';
import { decodeFontData, ttx, verifyTtxOutput } from "./fontutils.js";
describe('font1', function() {
var font1_1 = decodeFontData('T1RUTwAJAIAAAwAQQ0ZGIP/t0rAAAACcAAADKU9TLzJDxycMAAADyAAAAGBjbWFwwFIBcgAABCgAAABUaGVhZKsnTJ4AAAR8AAAANmhoZWEDHvxTAAAEtAAAACRobXR4AAAAAAAABNgAAAA4bWF4cAAOUAAAAAUQAAAABm5hbWX8Fq+xAAAFGAAAAfhwb3N0AAMAAAAABxAAAAAgAQAEAgABAQEMS0hQRkxFK01UU1kAAQEBOfgeAPgfAfggAvghA/gXBIv+Tvqn+bAFHQAAAMgPHQAAAL0QHQAAANsRHQAAACcdAAADARL4IAwWAAcBAQgUGx5TV19yYWRpY2FsY2lyY2xlY29weXJ0c2ltaWxhcjEuMUNvcHlyaWdodCAoQykgMTk5MiwgMTk5MyBUaGUgVGVYcGxvcmF0b3JzIENvcnBvcmF0aW9uTVRTWU1hdGhUaW1lAAAAAAkAAg0YQ0RmZ3AAAKYAqAGIAYkADAAeAFwAXgGHAAoCAAEAAwAWAFoAtgDxARcBNgGKAd4CDiAO93W9Ad/4+AP5TPd1Fb38+FkHDvfslp/3PtH3Pp8B9xjR9zDQ9zDRFPz4P/eAFfd193UFRQb7UvtS+1L3UgVFBvd1+3X7dvt1BdIG91L3UvdS+1IF0gYO+MT7ZbP5vLMBw7P5vLMD+kT3fxX3iPtc91z7iPuI+1z7XPuI+4j3XPtc94j3iPdc91z3iB78UPwoFft0+0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IAAQAAAAAABAALACoAAQAAAAAABQAMADUAAQAAAAAABgAAAEEAAQAAAAAABwAHAEEAAQAAAAAACAAHAEgAAQAAAAAACQAHAE8AAwABBAkAAAAgAFYAAwABBAkAAQAWAHYAAwABBAkAAgAOAIwAAwABBAkAAwAQAJoAAwABBAkABAAWAKoAAwABBAkABQAYAMAAAwABBAkABgAAANgAAwABBAkABwAOANgAAwABBAkACAAOAOYAAwABBAkACQAOAPRPcmlnaW5hbCBsaWNlbmNlS0hQRkxFK01UU1lVbmtub3dudW5pcXVlSURLSFBGTEUrTVRTWVZlcnNpb24gMC4xMVVua25vd25Vbmtub3duVW5rbm93bgBPAHIAaQBnAGkAbgBhAGwAIABsAGkAYwBlAG4AYwBlAEsASABQAEYATABFACsATQBUAFMAWQBVAG4AawBuAG8AdwBuAHUAbgBpAHEAdQBlAEkARABLAEgAUABGAEwARQArAE0AVABTAFkAVgBlAHIAcwBpAG8AbgAgADAALgAxADEAVQBuAGsAbgBvAHcAbgBVAG4AawBuAG8AdwBuAFUAbgBrAG4AbwB3AG4AAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==');
describe('test harness testing', function() {
it('returns output', function(done) {
ttx(font1_1, function(output) {
describe("font1", function () {
var font1_1 = decodeFontData(
// eslint-disable-next-line max-len
"T1RUTwAJAIAAAwAQQ0ZGIP/t0rAAAACcAAADKU9TLzJDxycMAAADyAAAAGBjbWFwwFIBcgAABCgAAABUaGVhZKsnTJ4AAAR8AAAANmhoZWEDHvxTAAAEtAAAACRobXR4AAAAAAAABNgAAAA4bWF4cAAOUAAAAAUQAAAABm5hbWX8Fq+xAAAFGAAAAfhwb3N0AAMAAAAABxAAAAAgAQAEAgABAQEMS0hQRkxFK01UU1kAAQEBOfgeAPgfAfggAvghA/gXBIv+Tvqn+bAFHQAAAMgPHQAAAL0QHQAAANsRHQAAACcdAAADARL4IAwWAAcBAQgUGx5TV19yYWRpY2FsY2lyY2xlY29weXJ0c2ltaWxhcjEu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AQAAAAwABABIAAAACgAIAAIAAgBEAGcAcOAH//8AAABDAGYAcOAA////wv+h/5kAAAABAAAAAAAAAAQAAAABAAEAAgACAAMAAwAEAAQAAQAAAAAQAAAAAABfDzz1AAAD6AAAAACeC34nAAAAAJ4LficAAPxGD/8DHAAAABEAAAAAAAAAAAABAAADHPxGAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAOAAAAAAAUAPYAAQAAAAAAAAAQAAAAAQAAAAAAAQALABAAAQAAAAAAAgAHABsAAQAAAAAAAwAIACIAAQAAAAAABAALACoAAQAAAAAABQAMADUAAQAAAAAABgAAAEEAAQAAAAAABwAHAEEAAQAAAAAACAAHAEgAAQAAAAAACQAHAE8AAwABBAkAAAAgAFYAAwABBAkAAQAWAHYAAwABBAkAAgAOAIwAAwABBAkAAwAQAJoAAwABBAkABAAWAKoAAwABBAkABQAYAMAAAwABBAkABgAAANgAAwABBAkABwAOANgAAwABBAkACAAOAOYAAwABBAkACQAOAPRPcmlnaW5hbCBsaWNlbmNlS0hQRkxFK01UU1lVbmtub3dudW5pcXVlSURLSFBGTEUrTVRTWVZlcnNpb24gMC4xMVVua25vd25Vbmtub3duVW5rbm93bgBPAHIAaQBnAGkAbgBhAGwAIABsAGkAYwBlAG4AYwBlAEsASABQAEYATABFACsATQBUAFMAWQBVAG4AawBuAG8AdwBuAHUAbgBpAHEAdQBlAEkARABLAEgAUABGAEwARQArAE0AVABTAFkAVgBlAHIAcwBpAG8AbgAgADAALgAxADEAVQBuAGsAbgBvAHcAbgBVAG4AawBuAG8AdwBuAFUAbgBrAG4AbwB3AG4AAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
);
describe("test harness testing", function () {
it("returns output", function (done) {
ttx(font1_1, function (output) {
verifyTtxOutput(output);
expect(/<ttFont /.test(output)).toEqual(true);
expect(/<\/ttFont>/.test(output)).toEqual(true);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,14 +11,6 @@
<script src="../../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="../unit/testreporter.js"></script>
<script src="jasmine-boot.js"></script>
<script src="fontutils.js"></script>
<!-- include spec files here... -->
<script src="font_core_spec.js"></script>
<script src="font_os2_spec.js"></script>
<script src="font_post_spec.js"></script>
<script src="font_fpgm_spec.js"></script>
</head>
<body>
</body>

View File

@ -14,12 +14,9 @@
* limitations under the License.
*/
"use strict";
var base64alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// eslint-disable-next-line no-unused-vars
function decodeFontData(base64) {
var result = [];
@ -68,7 +65,6 @@ function encodeFontData(data) {
return buffer;
}
// eslint-disable-next-line no-unused-vars
function ttx(data, callback) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/ttx");
@ -89,10 +85,11 @@ function ttx(data, callback) {
xhr.send(encodedData);
}
// eslint-disable-next-line no-unused-vars
function verifyTtxOutput(output) {
var m = /^<error>(.*?)<\/error>/.exec(output);
if (m) {
throw m[1];
}
}
export { decodeFontData, encodeFontData, ttx, verifyTtxOutput };

View File

@ -40,26 +40,19 @@
"use strict";
function initializePDFJS(callback) {
Promise.all([
SystemJS.import("pdfjs/core/fonts.js"),
SystemJS.import("pdfjs/core/stream.js"),
SystemJS.import("pdfjs/core/primitives.js"),
SystemJS.import("pdfjs/core/cmap.js"),
]).then(function (modules) {
var fonts = modules[0],
stream = modules[1],
primitives = modules[2],
cmap = modules[3];
// Expose some of the PDFJS members to global scope for tests.
window.Font = fonts.Font;
window.ToUnicodeMap = fonts.ToUnicodeMap;
window.Stream = stream.Stream;
window.Name = primitives.Name;
window.CMapFactory = cmap.CMapFactory;
async function initializePDFJS(callback) {
await Promise.all(
[
"pdfjs-test/font/font_core_spec.js",
"pdfjs-test/font/font_os2_spec.js",
"pdfjs-test/font/font_post_spec.js",
"pdfjs-test/font/font_fpgm_spec.js",
].map(function (moduleName) {
return SystemJS.import(moduleName);
})
);
callback();
});
}
(function () {