forked from gfx-rs/wgpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Connor Fitzgerald <[email protected]>
- Loading branch information
Showing
17 changed files
with
322 additions
and
149 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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Test that `create_surface_*()` accurately reports those errors we can provoke. | ||
/// This test applies to those cfgs that have a `create_surface_from_canvas` method, which | ||
/// include WebGL and WebGPU, but *not* Emscripten GLES. | ||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] | ||
#[wasm_bindgen_test::wasm_bindgen_test] | ||
fn canvas_get_context_returned_null() { | ||
// Not using initialize_test() because that goes straight to creating the canvas for us. | ||
let instance = wgpu_test::initialize_instance(); | ||
// Create canvas and cleanup on drop | ||
let canvas_g = wgpu_test::SurfaceGuard { | ||
canvas: wgpu_test::create_html_canvas(), | ||
}; | ||
// Using a context id that is not "webgl2" or "webgpu" will render the canvas unusable by wgpu. | ||
canvas_g.canvas.get_context("2d").unwrap(); | ||
|
||
#[allow(clippy::redundant_clone)] // false positive — can't and shouldn't move out. | ||
let error = instance | ||
.create_surface_from_canvas(canvas_g.canvas.clone()) | ||
.unwrap_err(); | ||
|
||
assert!( | ||
error | ||
.to_string() | ||
.contains("canvas.getContext() returned null"), | ||
"{error}" | ||
); | ||
} |
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
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
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
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
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
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
Oops, something went wrong.