Skip to content

Commit 585cbbd

Browse files
committed
Merge main project fix && add testing automation
1 parent a243d01 commit 585cbbd

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

.github/workflows/wasm.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: WASM Target
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- name: Install WASM tool chain
11+
run: rustup target add wasm32-unknown-unknown
12+
- name: Install wasm-pack
13+
run: cargo install wasm-pack
14+
- name: Install fireox
15+
run: sudo apt-get install firefox
16+
- name: Run WASM test cases
17+
run: wasm-pack test --headless --firefox

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ version = "0.3.32"
2121
features = ['Document', 'DomRect', 'Element', 'HtmlElement', 'Node', 'Window', 'HtmlCanvasElement', 'CanvasRenderingContext2d']
2222

2323
[dev-dependencies]
24-
plotters = { path = "../plotters" }
25-
wasm-bindgen-test = "0.3.5"
24+
plotters = "^0.3.0"
25+
wasm-bindgen-test = "^0.3.17"

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,24 @@ This is a part of plotters project. For more details, please check the following
66
- Check the main repo at [Plotters repo](https://github.com/38/plotters.git)
77
- For detailed documentation about this crate, check [plotters-backend on docs.rs](https://docs.rs/plotters-backend/)
88
- You can also visit Plotters [Homepage](https://plotters-rs.github.io)
9+
10+
## Testing
11+
12+
This crate needs to be tested in a browser environment. In order to test, you should install `wasm-pack` first.
13+
14+
```bash
15+
cargo install wasm-pack
16+
```
17+
18+
To run the test case with wasm-pack. You need choose what browser you want to run the test cases. You should also be able
19+
to use `--chrome` or `--safari` as well.
20+
21+
```bash
22+
wasm-pack test --firefox
23+
```
24+
25+
Also you should be able to run it headlessly by adding the headless param to the testing command.
26+
27+
```bash
28+
wasm-pack test --firefox --headless
29+
```

src/canvas.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl CanvasBackend {
6565
/// Sets the stroke style and line width in the underlying context.
6666
fn set_line_style(&mut self, style: &impl BackendStyle) {
6767
self.context
68-
.set_stroke_style(&make_canvas_color(style.as_color()));
68+
.set_stroke_style(&make_canvas_color(style.color()));
6969
self.context.set_line_width(style.stroke_width() as f64);
7070
}
7171
}
@@ -346,7 +346,7 @@ mod test {
346346
let mut chart = ChartBuilder::on(&root)
347347
.caption("This is a test", ("sans-serif", 20))
348348
.set_all_label_area_size(40)
349-
.build_ranged(0..10, 0..10)
349+
.build_cartesian_2d(0..10, 0..10)
350350
.unwrap();
351351

352352
chart
@@ -381,7 +381,7 @@ mod test {
381381
let mut chart = ChartBuilder::on(&root)
382382
.caption("All anchor point positions", ("sans-serif", 20))
383383
.set_all_label_area_size(40)
384-
.build_ranged(0..100, 0..50)
384+
.build_cartesian_2d(0..100, 0..50)
385385
.unwrap();
386386

387387
chart
@@ -464,7 +464,7 @@ mod test {
464464
let mut chart = ChartBuilder::on(&root)
465465
.caption("All series label positions", ("sans-serif", 20))
466466
.set_all_label_area_size(40)
467-
.build_ranged(0..50, 0..50)
467+
.build_cartesian_2d(0..50, 0..50)
468468
.unwrap();
469469

470470
chart

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
The Plotters HTML5 Canvas backend.
3-
4-
This backend allows Plotters operates the HTML5 Canvas when targeted to Webassembly.
2+
The Plotters HTML5 Canvas backend.
3+
4+
This backend allows Plotters operates the HTML5 Canvas when targeted to Webassembly.
55
66
See the documentation for [CanvasBackend](struct.CanvasBackend.html) for more details.
77
*/

0 commit comments

Comments
 (0)