-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5f057a
commit 70cf790
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/unit/src/rendering/renderers/webGl/shared/RenderingContext2d.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
import { assertEquals } from "std/testing/asserts.ts"; | ||
|
||
export class RenderingContext2d { | ||
/** | ||
* @param {CanvasImageSource} image | ||
* @param {number} dx | ||
* @param {number} dy | ||
*/ | ||
drawImage(image, dx, dy) {} | ||
|
||
clearRect() {} | ||
} | ||
|
||
/** @type {RenderingContext2d[]} */ | ||
let created2dRenderingContexts = []; | ||
|
||
/** | ||
* @param {{width: number, height: number}} canvas | ||
*/ | ||
export function create2dRenderingContext(canvas) { | ||
const context = new RenderingContext2d(); | ||
created2dRenderingContexts.push(context); | ||
return context; | ||
} | ||
|
||
export function assertHasSingle2dRenderingContext() { | ||
assertEquals(created2dRenderingContexts.length, 1, 'Expected to have exactly one canvas with getContext("2d")'); | ||
return created2dRenderingContexts[0]; | ||
} | ||
|
||
export function clearCreated2dRenderingContexts() { | ||
created2dRenderingContexts = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters