@@ -8,11 +8,15 @@ import {ScatterplotLayer} from '@deck.gl/layers';
88import { MapboxOverlay } from '@deck.gl/mapbox' ;
99import { _GlobeView as GlobeView , MapView , Widget } from '@deck.gl/core' ;
1010import type { WidgetPlacement } from '@deck.gl/core' ;
11+ import { WebGLDevice } from '@luma.gl/webgl' ;
1112
1213import { objectEqual } from './mapbox-layer.spec' ;
1314import MockMapboxMap from './mapbox-gl-mock/map' ;
1415import { DEFAULT_PARAMETERS } from './fixtures' ;
1516
17+ // Create an isolated device for overlaid mode tests to prevent GL context corruption
18+ const overlaidTestDevice = new WebGLDevice ( { createCanvasContext : { width : 1 , height : 1 } } ) ;
19+
1620// Simple test widget for testing MapboxOverlay widget support
1721class TestWidget extends Widget < { placement ?: WidgetPlacement ; viewId ?: string | null } > {
1822 static defaultProps = {
@@ -58,6 +62,7 @@ test('MapboxOverlay#overlaid', t => {
5862 zoom : 14
5963 } ) ;
6064 const overlay = new MapboxOverlay ( {
65+ device : overlaidTestDevice ,
6166 layers : [ new ScatterplotLayer ( ) ]
6267 } ) ;
6368
@@ -120,7 +125,9 @@ test('MapboxOverlay#overlaidNoIntitalLayers', t => {
120125 center : { lng : - 122.45 , lat : 37.78 } ,
121126 zoom : 14
122127 } ) ;
123- const overlay = new MapboxOverlay ( { } ) ;
128+ const overlay = new MapboxOverlay ( {
129+ device : overlaidTestDevice
130+ } ) ;
124131
125132 map . addControl ( overlay ) ;
126133
@@ -510,6 +517,7 @@ test('MapboxOverlay#widgets - regular widgets render in deck container', t => {
510517
511518 const widget = new TestWidget ( { id : 'regular-widget' , placement : 'top-right' } ) ;
512519 const overlay = new MapboxOverlay ( {
520+ device : overlaidTestDevice ,
513521 layers : [ new ScatterplotLayer ( ) ] ,
514522 widgets : [ widget ]
515523 } ) ;
@@ -533,6 +541,7 @@ test('MapboxOverlay#widgets - viewId:mapbox widgets wrapped as IControl', t => {
533541
534542 const widget = new TestWidget ( { id : 'mapbox-widget' , viewId : 'mapbox' , placement : 'top-right' } ) ;
535543 const overlay = new MapboxOverlay ( {
544+ device : overlaidTestDevice ,
536545 layers : [ new ScatterplotLayer ( ) ] ,
537546 widgets : [ widget ]
538547 } ) ;
@@ -566,6 +575,7 @@ test('MapboxOverlay#widgets - mixed widgets', t => {
566575 } ) ;
567576
568577 const overlay = new MapboxOverlay ( {
578+ device : overlaidTestDevice ,
569579 layers : [ new ScatterplotLayer ( ) ] ,
570580 widgets : [ regularWidget , mapboxWidget1 , mapboxWidget2 ]
571581 } ) ;
@@ -593,6 +603,7 @@ test('MapboxOverlay#widgets - setProps updates widget controls', t => {
593603
594604 const widget1 = new TestWidget ( { id : 'widget1' , viewId : 'mapbox' , placement : 'top-right' } ) ;
595605 const overlay = new MapboxOverlay ( {
606+ device : overlaidTestDevice ,
596607 layers : [ new ScatterplotLayer ( ) ] ,
597608 widgets : [ widget1 ]
598609 } ) ;
0 commit comments