Skip to content

Commit

Permalink
Use the SimpleLinkService when running "annotations" reference tests
Browse files Browse the repository at this point in the history
Rather than (basically) duplicating the `SimpleLinkService` in `test/driver.js`, with potential test failuires if you forget to update the test mock, it seems much nicer to just re-use the viewer component.

Note that `SimpleLinkService` is already bundled into the `build/components/pdf_viewer.js` file. Hence we only need to expose it similar to the other viewer components in that file, and make sure that the `gulp components` command runs as part of the test-setup.
  • Loading branch information
Snuffleupagus committed Sep 12, 2017
1 parent f2618eb commit 1ebbdc2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
12 changes: 6 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,34 +1085,34 @@ gulp.task('publish', ['generic'], function (done) {
});
});

gulp.task('test', ['generic'], function () {
gulp.task('test', ['generic', 'components'], function () {
return streamqueue({ objectMode: true, },
createTestSource('unit'), createTestSource('browser'));
});

gulp.task('bottest', ['generic'], function () {
gulp.task('bottest', ['generic', 'components'], function () {
return streamqueue({ objectMode: true, },
createTestSource('unit'), createTestSource('font'),
createTestSource('browser (no reftest)'));
});

gulp.task('browsertest', ['generic'], function () {
gulp.task('browsertest', ['generic', 'components'], function () {
return createTestSource('browser');
});

gulp.task('unittest', ['generic'], function () {
gulp.task('unittest', ['generic', 'components'], function () {
return createTestSource('unit');
});

gulp.task('fonttest', function () {
return createTestSource('font');
});

gulp.task('makeref', ['generic'], function (done) {
gulp.task('makeref', ['generic', 'components'], function (done) {
makeRef(done);
});

gulp.task('botmakeref', ['generic'], function (done) {
gulp.task('botmakeref', ['generic', 'components'], function (done) {
makeRef(done, true);
});

Expand Down
37 changes: 1 addition & 36 deletions test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,6 @@ var PDF_TO_CSS_UNITS = 96.0 / 72.0;

var StatTimer = pdfjsDistBuildPdf.StatTimer;

/**
* @class
*/
var LinkServiceMock = (function LinkServiceMockClosure() {
function LinkServiceMock() {}

LinkServiceMock.prototype = {
get page() {
return 0;
},

set page(value) {},

navigateTo(dest) {},

getDestinationHash(dest) {
return '#';
},

getAnchorUrl(hash) {
return '#';
},

setHash(hash) {},

executeNamedAction(action) {},

onFileAttachmentAnnotation(params) {},

cachePageRef(pageNum, pageRef) {},
};

return LinkServiceMock;
})();

/**
* @class
*/
Expand Down Expand Up @@ -230,7 +195,7 @@ var rasterizeAnnotationLayer = (function rasterizeAnnotationLayerClosure() {
div,
annotations,
page,
linkService: new LinkServiceMock(),
linkService: new PDFJS.SimpleLinkService(),
renderInteractiveForms,
};
PDFJS.AnnotationLayer.render(parameters);
Expand Down
1 change: 1 addition & 0 deletions test/test_slave.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<title>PDF.js test slave</title>
<meta charset="utf-8">
<script src="../build/generic/build/pdf.js"></script>
<script src="../build/components/pdf_viewer.js"></script>
<script src="driver.js"></script>
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions web/pdf_viewer.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var PDFJS = pdfjsLib.PDFJS;
PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;
PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;
PDFJS.PDFLinkService = pdfjsWebPDFLinkService.PDFLinkService;
PDFJS.SimpleLinkService = pdfjsWebPDFLinkService.SimpleLinkService;
PDFJS.TextLayerBuilder = pdfjsWebTextLayerBuilder.TextLayerBuilder;
PDFJS.DefaultTextLayerFactory =
pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;
Expand Down

0 comments on commit 1ebbdc2

Please sign in to comment.