|
| 1 | +import canUseFloatOpacityTexture from '../src/RenderingEngine/vtkClasses/canUseFloatOpacityTexture'; |
| 2 | + |
| 3 | +function createContext(supportedExtensions) { |
| 4 | + return { |
| 5 | + getExtension: jest.fn((name) => |
| 6 | + supportedExtensions.includes(name) ? {} : null |
| 7 | + ), |
| 8 | + }; |
| 9 | +} |
| 10 | + |
| 11 | +function createRenderWindow(webgl2) { |
| 12 | + return { |
| 13 | + getWebgl2: jest.fn(() => webgl2), |
| 14 | + }; |
| 15 | +} |
| 16 | + |
| 17 | +describe('canUseFloatOpacityTexture', () => { |
| 18 | + it('rejects a WebGL2 float texture without float-linear filtering', () => { |
| 19 | + const renderWindow = createRenderWindow(true); |
| 20 | + const context = createContext([]); |
| 21 | + |
| 22 | + expect(canUseFloatOpacityTexture(renderWindow, context)).toBe(false); |
| 23 | + }); |
| 24 | + |
| 25 | + it('accepts a WebGL2 float texture with float-linear filtering', () => { |
| 26 | + const renderWindow = createRenderWindow(true); |
| 27 | + const context = createContext(['OES_texture_float_linear']); |
| 28 | + |
| 29 | + expect(canUseFloatOpacityTexture(renderWindow, context)).toBe(true); |
| 30 | + }); |
| 31 | + |
| 32 | + it('accepts WebGL1 only when both float extensions are available', () => { |
| 33 | + const renderWindow = createRenderWindow(false); |
| 34 | + const context = createContext([ |
| 35 | + 'OES_texture_float', |
| 36 | + 'OES_texture_float_linear', |
| 37 | + ]); |
| 38 | + |
| 39 | + expect(canUseFloatOpacityTexture(renderWindow, context)).toBe(true); |
| 40 | + }); |
| 41 | + |
| 42 | + it('rejects WebGL1 when either float extension is unavailable', () => { |
| 43 | + const renderWindow = createRenderWindow(false); |
| 44 | + const context = createContext(['OES_texture_float_linear']); |
| 45 | + |
| 46 | + expect(canUseFloatOpacityTexture(renderWindow, context)).toBe(false); |
| 47 | + }); |
| 48 | +}); |
0 commit comments