Panics · P11 Motion: a buffer behind the value draws none
This commit is contained in:
1 parent
4c86e831bb
commit
c9f492d0b4
3 files changed
+11
-14
No files matched your search
@@ -75,14 +75,10 @@ impl ProgressBar {
|
||||
}
|
||||
}
|
||||
|
||||
/// What has loaded ahead of the value, drawn fainter.
|
||||
/// What has loaded ahead of the value, drawn fainter; none when it lies behind, as after a seek.
|
||||
pub fn buffer(mut self, buffer: f32) -> Self {
|
||||
let value = self.value.expect("an indeterminate bar has no buffer");
|
||||
assert!(
|
||||
checked(buffer, "buffer") >= value,
|
||||
"buffer {buffer} is behind {value}"
|
||||
);
|
||||
self.buffer = Some(buffer);
|
||||
self.buffer = (checked(buffer, "buffer") > value).then_some(buffer);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -287,11 +283,17 @@ impl RenderOnce for ProgressRing {
|
||||
mod tests {
|
||||
use gpui::div;
|
||||
|
||||
use super::ProgressRing;
|
||||
use super::{ProgressBar, ProgressRing};
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "a percent or content inside, not both")]
|
||||
fn a_ring_holds_a_percent_or_content_not_both() {
|
||||
let _ = ProgressRing::new("ring", 0.5).inside(div()).percent();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_buffer_ahead_shows_and_one_behind_does_not() {
|
||||
assert_eq!(ProgressBar::new("bar", 0.4).buffer(0.7).buffer, Some(0.7));
|
||||
assert_eq!(ProgressBar::new("bar", 0.6).buffer(0.4).buffer, None);
|
||||
}
|
||||
}
|
||||
@@ -98,12 +98,6 @@ fn a_lazy_row_builds_once_it_scrolls_into_view(cx: &mut TestAppContext) {
|
||||
assert!(built.get() >= 1, "the row was built");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "is behind")]
|
||||
fn a_buffer_behind_the_value_is_refused() {
|
||||
let _ = ProgressBar::new("bar", 0.6).buffer(0.4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "not 0..=1")]
|
||||
fn a_value_past_whole_is_refused() {
|
||||
|
||||
+2
-1
@@ -25,7 +25,7 @@ Each item reads every site in its folders, fixes what the rules name, updates ca
|
||||
- [x] P08 Menus — `src/menus`
|
||||
- [x] P09 Overlays — `src/overlays`
|
||||
- [x] P10 Feedback — `src/feedback`
|
||||
- [ ] P11 Loading & Motion — `src/motion`
|
||||
- [x] P11 Loading & Motion — `src/motion`
|
||||
- [ ] P12 Data Display — `src/data_display`
|
||||
- [ ] P13 Lists & Trees — `src/lists`
|
||||
- [ ] P14 Tables — `src/tables`
|
||||
@@ -75,3 +75,4 @@ One line per item: what changed, what stayed and why, review rounds.
|
||||
- P08: no change. Kept: a bar's menus and a pie's slices (one value each); the panel's level lookup, which `settle` fits to the menu before every draw. Review: 1 round.
|
||||
- P09: a `Lightbox` or `Tour` past its last item logs and closes, handing focus back. Kept: dialog Enter without `focus_first` and popover face builders on an owner's opener (static builder misuse). Review: 1 round.
|
||||
- P10: no change. Kept: a toast's stay above zero (one value). Review: 1 round.
|
||||
- P11: a buffer at or behind the value draws none; `slide` was fixed in P05. Kept: values in 0..=1, segment and skeleton counts (one value each), builder misuse, reorder's permutation. Review: 1 round.
|
||||
Reference in new issue
Block a user