diff --git a/modules/test-utils/src/snapshot-test-runner.ts b/modules/test-utils/src/snapshot-test-runner.ts index 1d015d1e7d8..ed88900b883 100644 --- a/modules/test-utils/src/snapshot-test-runner.ts +++ b/modules/test-utils/src/snapshot-test-runner.ts @@ -33,6 +33,7 @@ type ImageDiffOptions = { tolerance?: number; // 0.1, includeAA?: boolean; // false, includeEmpty?: boolean; // true + platform?: string; }; type DiffImageResult = { @@ -140,8 +141,20 @@ export class SnapshotTestRunner extends TestRunner< }; // Take screenshot and compare const result = await window.browserTestDriver_captureAndDiffScreen(diffOptions); + + // If failed, try if we have a platform specific golden image + let resultOverride; + const platform = this.testOptions.imageDiffOptions?.platform?.toLowerCase(); + if (!result.success) { + diffOptions.goldenImage = diffOptions.goldenImage.replace( + 'golden-images/', + `golden-images/platform-overrides/${platform}/` + ); + resultOverride = await window.browserTestDriver_captureAndDiffScreen(diffOptions); + } + // invoke user callback - if (result.success) { + if (result.success || resultOverride.success) { this.pass(result); } else { this.fail(result); diff --git a/test/render/constants.js b/test/render/constants.ts similarity index 100% rename from test/render/constants.js rename to test/render/constants.ts diff --git a/test/render/golden-images/platform-overrides/mac/arc-lnglat.png b/test/render/golden-images/platform-overrides/mac/arc-lnglat.png new file mode 100644 index 00000000000..b0cf8d564c9 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/arc-lnglat.png differ diff --git a/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-flatshading.png b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-flatshading.png new file mode 100644 index 00000000000..ada102bf06e Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-flatshading.png differ diff --git a/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-vertices.png b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-vertices.png new file mode 100644 index 00000000000..0cb2f0173f4 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe-vertices.png differ diff --git a/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe.png b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe.png new file mode 100644 index 00000000000..85603620a87 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/column-lnglat-extruded-wireframe.png differ diff --git a/test/render/golden-images/platform-overrides/mac/contour-infoviz.png b/test/render/golden-images/platform-overrides/mac/contour-infoviz.png new file mode 100644 index 00000000000..648a5297a18 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/contour-infoviz.png differ diff --git a/test/render/golden-images/platform-overrides/mac/contour-lnglat.png b/test/render/golden-images/platform-overrides/mac/contour-lnglat.png new file mode 100644 index 00000000000..b8bd77afaf2 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/contour-lnglat.png differ diff --git a/test/render/golden-images/platform-overrides/mac/grid-lnglat-side.png b/test/render/golden-images/platform-overrides/mac/grid-lnglat-side.png new file mode 100644 index 00000000000..a80a8f65123 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/grid-lnglat-side.png differ diff --git a/test/render/golden-images/platform-overrides/mac/icon-lnglat-facing-up.png b/test/render/golden-images/platform-overrides/mac/icon-lnglat-facing-up.png new file mode 100644 index 00000000000..da691a5beaf Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/icon-lnglat-facing-up.png differ diff --git a/test/render/golden-images/platform-overrides/mac/path-globe.png b/test/render/golden-images/platform-overrides/mac/path-globe.png new file mode 100644 index 00000000000..384cf6a62a0 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/path-globe.png differ diff --git a/test/render/golden-images/platform-overrides/mac/polygon-pattern-mask.png b/test/render/golden-images/platform-overrides/mac/polygon-pattern-mask.png new file mode 100644 index 00000000000..9f0a723dd30 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/polygon-pattern-mask.png differ diff --git a/test/render/golden-images/platform-overrides/mac/polygon-pattern.png b/test/render/golden-images/platform-overrides/mac/polygon-pattern.png new file mode 100644 index 00000000000..69d1d1a2b26 Binary files /dev/null and b/test/render/golden-images/platform-overrides/mac/polygon-pattern.png differ diff --git a/test/render/index.js b/test/render/index.js index be9f722a799..d43163e3fdc 100644 --- a/test/render/index.js +++ b/test/render/index.js @@ -19,7 +19,7 @@ // THE SOFTWARE. import test from 'tape'; import TEST_CASES from './test-cases'; -import {WIDTH, HEIGHT} from './constants'; +import {WIDTH, HEIGHT, OS} from './constants'; import {SnapshotTestRunner} from '@deck.gl/test-utils'; import './jupyter-widget'; @@ -40,6 +40,7 @@ test('Render Test', t => { timeout: 10000, imageDiffOptions: { + platform: OS, threshold: 0.99, includeEmpty: false // uncomment to save screenshot to disk