-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flex): add support of set flex wrap and test case walk through
- Loading branch information
1 parent
2293ff6
commit 8759e92
Showing
5 changed files
with
119 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
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,87 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
extern crate taitank_safe; | ||
use taitank_safe::*; | ||
|
||
#[test] | ||
fn wrap_column() { | ||
let mut root = node_create(); | ||
set_flex_wrap(&mut root, FlexWrapNode::FlexWrap); | ||
set_height(&mut root, 100.0); | ||
|
||
let mut root_child0 = node_create(); | ||
set_width(&mut root_child0, 30.0); | ||
set_height(&mut root_child0, 30.0); | ||
insert_child(&mut root, &mut root_child0, 0); | ||
|
||
let mut root_child1 = node_create(); | ||
set_width(&mut root_child1, 30.0); | ||
set_height(&mut root_child1, 30.0); | ||
insert_child(&mut root, &mut root_child1, 1); | ||
|
||
let mut root_child2 = node_create(); | ||
set_width(&mut root_child2, 30.0); | ||
set_height(&mut root_child2, 30.0); | ||
insert_child(&mut root, &mut root_child2, 2); | ||
|
||
let mut root_child3 = node_create(); | ||
set_width(&mut root_child3, 30.0); | ||
set_height(&mut root_child3, 30.0); | ||
insert_child(&mut root, &mut root_child3, 3); | ||
|
||
layout!(&mut root); | ||
|
||
assert_eq!(0.0, get_left(&mut root)); | ||
assert_eq!(0.0, get_top(&mut root)); | ||
assert_eq!(60.0, get_width(&mut root)); | ||
assert_eq!(100.0, get_height(&mut root)); | ||
|
||
assert_eq!(0.0, get_left(&mut root_child0)); | ||
assert_eq!(0.0, get_top(&mut root_child0)); | ||
assert_eq!(30.0, get_width(&mut root_child0)); | ||
assert_eq!(30.0, get_height(&mut root_child0)); | ||
|
||
assert_eq!(0.0, get_left(&mut root_child1)); | ||
assert_eq!(30.0, get_top(&mut root_child1)); | ||
assert_eq!(30.0, get_width(&mut root_child1)); | ||
assert_eq!(30.0, get_height(&mut root_child1)); | ||
|
||
assert_eq!(0.0, get_left(&mut root_child2)); | ||
assert_eq!(60.0, get_top(&mut root_child2)); | ||
assert_eq!(30.0, get_width(&mut root_child2)); | ||
assert_eq!(30.0, get_height(&mut root_child2)); | ||
|
||
assert_eq!(30.0, get_left(&mut root_child3)); | ||
assert_eq!(0.0, get_top(&mut root_child3)); | ||
assert_eq!(30.0, get_width(&mut root_child3)); | ||
assert_eq!(30.0, get_height(&mut root_child3)); | ||
|
||
layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); | ||
|
||
assert_eq!(0.0, get_left(&mut root)); | ||
assert_eq!(0.0, get_top(&mut root)); | ||
assert_eq!(60.0, get_width(&mut root)); | ||
assert_eq!(100.0, get_height(&mut root)); | ||
|
||
assert_eq!(30.0, get_left(&mut root_child0)); | ||
assert_eq!(0.0, get_top(&mut root_child0)); | ||
assert_eq!(30.0, get_width(&mut root_child0)); | ||
assert_eq!(30.0, get_height(&mut root_child0)); | ||
|
||
assert_eq!(30.0, get_left(&mut root_child1)); | ||
assert_eq!(30.0, get_top(&mut root_child1)); | ||
assert_eq!(30.0, get_width(&mut root_child1)); | ||
assert_eq!(30.0, get_height(&mut root_child1)); | ||
|
||
assert_eq!(30.0, get_left(&mut root_child2)); | ||
assert_eq!(60.0, get_top(&mut root_child2)); | ||
assert_eq!(30.0, get_width(&mut root_child2)); | ||
assert_eq!(30.0, get_height(&mut root_child2)); | ||
|
||
assert_eq!(0.0, get_left(&mut root_child3)); | ||
assert_eq!(0.0, get_top(&mut root_child3)); | ||
assert_eq!(30.0, get_width(&mut root_child3)); | ||
assert_eq!(30.0, get_height(&mut root_child3)); | ||
|
||
} | ||
} |