Fix StackView tests

This commit is contained in:
Alexandre Bury 2018-06-26 15:19:00 -07:00
parent 927afafe88
commit 88fb6e7c54
2 changed files with 9 additions and 17 deletions

View File

@ -45,7 +45,11 @@ fn make_percentage(value: usize, (min, max): (usize, usize)) -> String {
}
let (percentage, extra) = ratio(value - min, max - min, 100);
let percentage = if extra > 4 { percentage + 1 } else { percentage };
let percentage = if extra > 4 {
percentage + 1
} else {
percentage
};
format!("{} %", percentage)
}

View File

@ -677,40 +677,28 @@ mod tests {
.get(LayerPosition::FromFront(0))
.unwrap()
.as_any()
.downcast_ref::<ViewBox>()
.unwrap()
.with_view(|v| v.as_any().is::<TextView>())
.unwrap()
.is::<TextView>()
);
assert!(
stack
.get(LayerPosition::FromBack(0))
.unwrap()
.as_any()
.downcast_ref::<ViewBox>()
.unwrap()
.with_view(|v| v.as_any().is::<TextView>())
.unwrap()
.is::<TextView>()
);
assert!(
stack
.get_mut(LayerPosition::FromFront(0))
.unwrap()
.as_any_mut()
.downcast_mut::<ViewBox>()
.unwrap()
.with_view_mut(|v| v.as_any_mut().is::<TextView>())
.unwrap()
.is::<TextView>()
);
assert!(
stack
.get_mut(LayerPosition::FromBack(0))
.unwrap()
.as_any_mut()
.downcast_mut::<ViewBox>()
.unwrap()
.with_view_mut(|v| v.as_any_mut().is::<TextView>())
.unwrap()
.is::<TextView>()
);
}
}