mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 20:23:35 +00:00
parent
48514991d2
commit
5e58726ffd
@ -470,3 +470,26 @@ impl View for StackView {
|
|||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use views::TextView;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn move_layer_works() {
|
||||||
|
let mut stack = StackView::new()
|
||||||
|
.layer(TextView::new("1"))
|
||||||
|
.layer(TextView::new("2"))
|
||||||
|
.layer(TextView::new("3"));
|
||||||
|
|
||||||
|
stack.move_layer(LayerPosition::FromFront(0), LayerPosition::FromBack(0));
|
||||||
|
stack.move_layer(LayerPosition::FromBack(0), LayerPosition::FromFront(0));
|
||||||
|
stack.move_layer(LayerPosition::FromFront(1), LayerPosition::FromFront(0));
|
||||||
|
|
||||||
|
let layer = stack.pop_layer().unwrap();
|
||||||
|
let box_view = layer.as_any().downcast_ref::<Box<AnyView>>().unwrap();
|
||||||
|
let text_view = (**box_view).as_any().downcast_ref::<TextView>().unwrap();
|
||||||
|
assert_eq!(text_view.get_content().source(), "2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user