Skip to content

Commit

Permalink
clean-up to the displayedArea_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-Safadi committed Apr 29, 2018
1 parent 81d94b0 commit d6b5171
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions test/internal/displayedArea_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('displayedArea', function () {
this.image = {
imageId: 'testImageDisplayed',
minPixelValue: 0,
maxPixelValue: 16777216, // Int24.Max
maxPixelValue: 255,
slope: 1.0,
intercept: 0,
windowCenter: 127,
Expand Down Expand Up @@ -83,23 +83,27 @@ describe('displayedArea', function () {
},
rowPixelSpacing: 1,
columnPixelSpacing: 1,
presentationSizeMode: 'TRUE SIZE'
presentationSizeMode: 'NONE'
}
};
});

it('displayedArea: should display the area specified in the viewport TRUE SIZE ', function (done) {

// Arrange
const canvasWidth = (this.getRect().width).toString();
const canvasHeight = (this.getRect().height).toString();

this.element = document.createElement('div');
this.element.style.width = `${canvasWidth}px`;
this.element.style.height = `${canvasHeight}px`;

document.body.appendChild(this.element); // Needed for the div to actually have a width.
// Needed for the div to actually have a width.
document.body.appendChild(this.element);

enable(this.element);

this.viewPort.displayedArea.presentationSizeMode = 'TRUE SIZE'

displayImage(this.element, this.image, this.viewPort);

this.element.addEventListener('cornerstoneimagerendered', () => {
Expand All @@ -120,15 +124,16 @@ describe('displayedArea', function () {
});

it('displayedArea: should display the area specified in the viewport FIT to the Canvas Size', function (done) {

// Arrange
const canvasWidth = (this.getRect().width * 2).toString();
const canvasHeight = (this.getRect().height * 2).toString();

this.element = document.createElement('div');
this.element.style.width = `${canvasWidth}px`;
this.element.style.height = `${canvasHeight}px`;

document.body.appendChild(this.element); // Needed for the div to actually have a width.
// Needed for the div to actually have a width.
document.body.appendChild(this.element);

enable(this.element);

Expand All @@ -144,7 +149,7 @@ describe('displayedArea', function () {

// Assert
assert.isAbove(data[0], 10, 'Top/left Pixel Red component must be greater than 10 due to interpolation');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be 255');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be greater than 10 due to interpolation');

done();
});
Expand All @@ -154,15 +159,16 @@ describe('displayedArea', function () {
});

it('displayedArea: should display the area specified in the viewport TRUE SIZE with irregular image size', function (done) {

// Arrange
const canvasWidth = (this.getRect().width).toString();
const canvasHeight = (this.getRect().height * 2).toString();

this.element = document.createElement('div');
this.element.style.width = `${canvasWidth}px`;
this.element.style.height = `${canvasHeight}px`;

document.body.appendChild(this.element); // Needed for the div to actually have a width.
// Needed for the div to actually have a width.
document.body.appendChild(this.element);

enable(this.element);

Expand All @@ -180,7 +186,7 @@ describe('displayedArea', function () {

// Assert
assert.isAbove(data[0], 10, 'Top/left Pixel Red component must be greater than 10 due to interpolation');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be 255');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be greater than 10 due to interpolation');

done();
});
Expand All @@ -190,15 +196,16 @@ describe('displayedArea', function () {
});

it('displayedArea: should display the area specified in the viewport MAGNIFIED', function (done) {

// Arrange
const canvasWidth = (this.getRect().width * 2).toString();
const canvasHeight = (this.getRect().height * 2).toString();

this.element = document.createElement('div');
this.element.style.width = `${canvasWidth}px`;
this.element.style.height = `${canvasHeight}px`;

document.body.appendChild(this.element); // Needed for the div to actually have a width.
// Needed for the div to actually have a width.
document.body.appendChild(this.element);

enable(this.element);

Expand All @@ -217,7 +224,7 @@ describe('displayedArea', function () {

// Assert
assert.isAbove(data[0], 10, 'Top/left Pixel Red component must be greater than 10 due to interpolation');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be 255');
assert.isAbove(data[data.length - 4], 10, 'Bottom/Right Pixel Red component must be greater than 10 due to interpolation');

done();
});
Expand Down

0 comments on commit d6b5171

Please sign in to comment.