Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Window and Windows structs easier to test with #6106

Closed
alice-i-cecile opened this issue Sep 26, 2022 · 2 comments
Closed

Make Window and Windows structs easier to test with #6106

alice-i-cecile opened this issue Sep 26, 2022 · 2 comments
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Testing A change that impacts how we test Bevy or how users test their apps

Comments

@alice-i-cecile
Copy link
Member

Writing tests for these types is quite challenging.

We should have:

  1. Constant constructors wherever possible.
  2. Doc tests demonstrating simple testing practices (likely using the Default struct update syntax for WindowDescriptor.
  3. A const fn new method on Windows that accepts a single Window.
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy O-Windows Specific to the Windows desktop operating system C-Testing A change that impacts how we test Bevy or how users test their apps and removed D-Trivial Nice and easy! A great choice to get started with Bevy labels Sep 26, 2022
@alice-i-cecile
Copy link
Member Author

The sticking point is the RawWindowHandle type: we cannot reasonably construct this in tests. IMO this should be optional in order to enable headless testing of various utility methods.

@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in and removed O-Windows Specific to the Windows desktop operating system labels Sep 26, 2022
@targrub
Copy link
Contributor

targrub commented Sep 26, 2022

I'm taking a look at tackling this.

@bors bors bot closed this as completed in 964b047 Oct 17, 2022
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 19, 2022
…Option`. (bevyengine#6114)

# Objective

- Trying to make it possible to do write tests that don't require a raw window handle.
- Fixes bevyengine#6106.

## Solution

- Make the interface and type changes.  Avoid accessing `None`.
---

## Changelog

- Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option<RawWindowHandleWrapper>`.
- Revised accessor function `Window::raw_window_handle()` to return `Option<RawWindowHandleWrapper>`.
- Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example).

## Migration Guide

`Window::raw_window_handle()` now returns `Option<RawWindowHandleWrapper>`.


Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
…Option`. (bevyengine#6114)

# Objective

- Trying to make it possible to do write tests that don't require a raw window handle.
- Fixes bevyengine#6106.

## Solution

- Make the interface and type changes.  Avoid accessing `None`.
---

## Changelog

- Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option<RawWindowHandleWrapper>`.
- Revised accessor function `Window::raw_window_handle()` to return `Option<RawWindowHandleWrapper>`.
- Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example).

## Migration Guide

`Window::raw_window_handle()` now returns `Option<RawWindowHandleWrapper>`.


Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
Pietrek14 pushed a commit to Pietrek14/bevy that referenced this issue Dec 17, 2022
…Option`. (bevyengine#6114)

# Objective

- Trying to make it possible to do write tests that don't require a raw window handle.
- Fixes bevyengine#6106.

## Solution

- Make the interface and type changes.  Avoid accessing `None`.
---

## Changelog

- Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option<RawWindowHandleWrapper>`.
- Revised accessor function `Window::raw_window_handle()` to return `Option<RawWindowHandleWrapper>`.
- Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example).

## Migration Guide

`Window::raw_window_handle()` now returns `Option<RawWindowHandleWrapper>`.


Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…Option`. (bevyengine#6114)

# Objective

- Trying to make it possible to do write tests that don't require a raw window handle.
- Fixes bevyengine#6106.

## Solution

- Make the interface and type changes.  Avoid accessing `None`.
---

## Changelog

- Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option<RawWindowHandleWrapper>`.
- Revised accessor function `Window::raw_window_handle()` to return `Option<RawWindowHandleWrapper>`.
- Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example).

## Migration Guide

`Window::raw_window_handle()` now returns `Option<RawWindowHandleWrapper>`.


Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
Subserial pushed a commit to Subserial/bevy_winit_hook that referenced this issue Jan 24, 2024
…Option`. (#6114)

# Objective

- Trying to make it possible to do write tests that don't require a raw window handle.
- Fixes bevyengine/bevy#6106.

## Solution

- Make the interface and type changes.  Avoid accessing `None`.
---

## Changelog

- Converted `raw_window_handle` field in both `Window` and `ExtractedWindow` to `Option<RawWindowHandleWrapper>`.
- Revised accessor function `Window::raw_window_handle()` to return `Option<RawWindowHandleWrapper>`.
- Skip conditions in loops that would require a raw window handle (to create a `Surface`, for example).

## Migration Guide

`Window::raw_window_handle()` now returns `Option<RawWindowHandleWrapper>`.


Co-authored-by: targrub <62773321+targrub@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Testing A change that impacts how we test Bevy or how users test their apps
Projects
None yet
2 participants