Skip to content

Commit

Permalink
test: add tests for cubemap "gap" option
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodNeck committed Apr 27, 2021
1 parent 89e1b32 commit 5d22a11
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h2>Support variety cubemap format</h2>
projectionType: "cubemap",
image: "../../img/test_cube_3x2_RLUDFB.jpg",
cubemapConfig: {
gap: 1
gap: 3
}
});

Expand Down
Binary file added test/manual/img/PanoViewer/test_cube_gap_0_1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/manual/img/PanoViewer/test_cube_gap_0_2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/manual/img/PanoViewer/test_cube_gap_2_1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/manual/img/PanoViewer/test_cube_gap_2_2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/manual/img/test_cube_3x2_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions test/unit/PanoImageRenderer/PanoImageRenderer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {compare, createPanoImageRenderer, renderAndCompareSequentially, isVideoL
import WebGLUtils from "../../../src/PanoImageRenderer/WebGLUtils";
import TestHelper from "../YawPitchControl/testHelper";
import {PROJECTION_TYPE} from "../../../src/PanoViewer/consts";
import PanoViewer from "../../../src/PanoViewer/PanoViewer";

const RendererOnIE11 = RendererInjector(
{
Expand Down Expand Up @@ -675,6 +676,69 @@ describe("PanoImageRenderer", () => {
expect(result.success).to.be.equal(true);
});

IT("cubemap 3x2 - gap", async () => {
// Given
const sourceImg = new Image();

sourceImg.src = "./images/test_cube_3x2_small.png";

const inst_gap0 = createPanoImageRenderer(sourceImg, false, "cubemap", { gap: 0, order: "RLUDFB" });
const inst_gap2 = createPanoImageRenderer(sourceImg, false, "cubemap", { gap: 2, order: "RLUDFB" });

await Promise.all([
new Promise(res => inst_gap0.on("imageLoaded", res)),
new Promise(res => inst_gap2.on("imageLoaded", res))
]);

// When
await inst_gap0.bindTexture();
await inst_gap2.bindTexture();

// Then
const result_gap0 = await renderAndCompareSequentially(
inst_gap0, [[135, -45, 30, `./images/PanoViewer/test_cube_gap_0${suffix}`, threshold]]
);

const result_gap2 = await renderAndCompareSequentially(
inst_gap2, [[135, -45, 30, `./images/PanoViewer/test_cube_gap_2${suffix}`, threshold]]
);

expect(result_gap0.success).to.be.equal(true);
expect(result_gap2.success).to.be.equal(true);
});

IT("cubestrip 3x2 - gap", async () => {
// Given
const sourceImg = new Image();

sourceImg.src = "./images/test_cube_3x2_small.png";
"RLUDFB"

const inst_gap0 = createPanoImageRenderer(sourceImg, false, "cubestrip", { gap: 0 });
const inst_gap2 = createPanoImageRenderer(sourceImg, false, "cubestrip", { gap: 2 });

await Promise.all([
new Promise(res => inst_gap0.on("imageLoaded", res)),
new Promise(res => inst_gap2.on("imageLoaded", res))
]);

// When
await inst_gap0.bindTexture();
await inst_gap2.bindTexture();

// Then
const result_gap0 = await renderAndCompareSequentially(
inst_gap0, [[135, -45, 30, `./images/PanoViewer/test_cube_gap_0${suffix}`, threshold]]
);

const result_gap2 = await renderAndCompareSequentially(
inst_gap2, [[135, -45, 30, `./images/PanoViewer/test_cube_gap_2${suffix}`, threshold]]
);

expect(result_gap0.success).to.be.equal(true);
expect(result_gap2.success).to.be.equal(true);
});

// This test will fail on iOS safari, because video will not start load without use interaction.
IT("cubestrip 3x2: video", async () => {
// Given
Expand Down

0 comments on commit 5d22a11

Please sign in to comment.