-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ribir): 🎸 add macro
example_framework
to help write example an…
…d its test
- Loading branch information
Showing
55 changed files
with
368 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
on: | ||
workflow_dispatch: # allows manual triggering | ||
schedule: | ||
- cron: '0 2 * * 2' # runs every tuesday at 00:00 | ||
- cron: "0 2 * * 2" # runs every tuesday at 00:00 | ||
name: "release weekly alpha version" | ||
jobs: | ||
release: | ||
|
@@ -30,10 +30,14 @@ jobs: | |
with: | ||
command: login | ||
args: ${{ secrets.CRATE_RELEASE_TOKEN }} | ||
- name: git config | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Adoo" | ||
- name: Run cargo release | ||
if: ${{ env.NEW_COMMIT_COUNT > 0 }} | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: release | ||
args: alpha --execute --no-confirm | ||
|
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
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,50 @@ | ||
/// Macro help to write an example. This macro accepts a function that returns a | ||
/// widget as the root of the application, you can specify the window size by | ||
/// `wnd_size = { size }`. It will generate codes for you: | ||
/// | ||
/// - the `main` function of startup application | ||
/// - use the `wnd_size` you provide or a default size `400x600` | ||
/// - use the package name in `Cargo.toml` as the window title. | ||
/// - generate an image test for the root widget, to ensure every modification | ||
/// is work for your example. | ||
/// - generate an bench test for the root widget, so we can continue to track | ||
/// the performance of the example. | ||
/// | ||
/// We may add in the future: | ||
/// | ||
/// - report the bundle binary size of this example. | ||
/// - report the startup time of the example. | ||
/// - report the memory and gpu memory used in this example. | ||
/// - report how many frames it can render in one second when vsync-off. | ||
|
||
#[macro_export] | ||
macro_rules! example_framework { | ||
( | ||
$widget_fn: ident $(,)? | ||
) => { | ||
example_framework!($widget_fn, wnd_size = Size::new(400., 600.)); | ||
}; | ||
( | ||
$widget_fn: ident, | ||
wnd_size = $size: expr $(,)? | ||
) => { | ||
#[cfg(test)] | ||
use ribir::core::test_helper::*; | ||
#[cfg(test)] | ||
extern crate test; | ||
#[cfg(test)] | ||
use ribir::material as ribir_material; | ||
#[cfg(test)] | ||
use test::Bencher; | ||
|
||
widget_bench!($widget_fn, wnd_size = $size); | ||
widget_image_test!($widget_fn, wnd_size = $size,); | ||
|
||
fn main() { | ||
let mut app = App::new(material::purple::light()); | ||
let name = env!("CARGO_PKG_NAME"); | ||
app.new_window($widget_fn(), Some($size)).set_title(name); | ||
app.exec() | ||
} | ||
}; | ||
} |
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,4 +1,5 @@ | ||
mod painter_backend_eq_image_test; | ||
pub use painter_backend_eq_image_test::*; | ||
mod example_framework; | ||
mod unit_test_describe; | ||
mod widget_test; |
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
File renamed without changes
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,11 @@ | ||
# Ribir Examples | ||
|
||
All the examples in this folder use the macro `example_framework!` to startup, the examples will generate tests and benchmarks for the example to ensure every modification work for those examples. | ||
|
||
Run examples: | ||
|
||
``` | ||
cargo run -p storybook --features="wgpu" | ||
``` | ||
|
||
Remember add `--features="wgpu"` to use `wgpu` painter-backend to render, we not enable it as default. |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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,21 @@ | ||
[package] | ||
authors.workspace = true | ||
categories.workspace = true | ||
description.workspace = true | ||
documentation.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
name = "counter" | ||
publish = false | ||
version.workspace = true | ||
|
||
[dependencies] | ||
paste.workspace = true | ||
# we disable `default-features`, because we want more control over testing. | ||
ribir = {path = "../../ribir", features = ["material", "widgets"], default-features = false} | ||
ribir_dev_helper = {path = "../../dev-helper"} | ||
|
||
[features] | ||
wgpu = ["ribir/wgpu"] |
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,9 @@ | ||
# Counter | ||
|
||
Exampling how to increase count or decrease count via buttons. | ||
|
||
|
||
You can run with: | ||
``` | ||
cargo run --p counter | ||
``` |
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,8 @@ | ||
#![feature(test)] | ||
|
||
mod counter; | ||
use counter::counter; | ||
use ribir::prelude::*; | ||
use ribir_dev_helper::*; | ||
|
||
example_framework!(counter); |
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,21 @@ | ||
[package] | ||
authors.workspace = true | ||
categories.workspace = true | ||
description.workspace = true | ||
documentation.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
name = "greet" | ||
publish = false | ||
version.workspace = true | ||
|
||
[dependencies] | ||
paste.workspace = true | ||
# we disable `default-features`, because we want more control over testing. | ||
ribir = {path = "../../ribir", features = ["material", "widgets"], default-features = false} | ||
ribir_dev_helper = {path = "../../dev-helper"} | ||
|
||
[features] | ||
wgpu = ["ribir/wgpu"] |
Oops, something went wrong.