Skip to content

Commit b2200c9

Browse files
committed
Update test snapshots for play state fix
1 parent fcc6726 commit b2200c9

22 files changed

+185
-88
lines changed

crates/store/re_entity_db/src/entity_db.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ impl EntityDb {
451451
self.storage_engine().store().timelines()
452452
}
453453

454-
455454
pub fn has_any_data_on_timeline(&self, timeline: &TimelineName) -> bool {
456455
self.time_histogram_per_timeline
457456
.get(timeline)

crates/viewer/re_view_time_series/src/view_class.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ impl ViewClass for TimeSeriesView {
196196
system_registry.register_fallback_provider(
197197
TimeAxis::descriptor_view_range().component,
198198
|ctx| {
199-
let time_histogram_per_timeline = ctx.viewer_ctx().recording().time_histogram_per_timeline();
199+
let time_histogram_per_timeline =
200+
ctx.viewer_ctx().recording().time_histogram_per_timeline();
200201
let (timeline_min, timeline_max) = time_histogram_per_timeline
201202
.get(ctx.viewer_ctx().time_ctrl.timeline().name())
202203
.and_then(|hist| {

crates/viewer/re_viewer_context/src/time_control.rs

Lines changed: 145 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,11 @@ impl TimeControl {
531531
&& new_play_state != self.play_state()
532532
{
533533
if let Some(time_histogram_per_timeline) = time_histogram_per_timeline {
534-
self.set_play_state(time_histogram_per_timeline, new_play_state, Some(blueprint_ctx));
534+
self.set_play_state(
535+
time_histogram_per_timeline,
536+
new_play_state,
537+
Some(blueprint_ctx),
538+
);
535539
} else {
536540
// Even without histogram data, we need to set the play state flags
537541
let empty_histogram = TimeHistogramPerTimeline::default();
@@ -552,7 +556,11 @@ impl TimeControl {
552556
);
553557
} else {
554558
let empty_histogram = TimeHistogramPerTimeline::default();
555-
self.set_play_state(&empty_histogram, PlayState::Playing, Some(blueprint_ctx));
559+
self.set_play_state(
560+
&empty_histogram,
561+
PlayState::Playing,
562+
Some(blueprint_ctx),
563+
);
556564
}
557565
}
558566

@@ -833,8 +841,12 @@ impl TimeControl {
833841
);
834842

835843
for command in commands {
836-
let needs_repaint =
837-
self.handle_time_command(blueprint_ctx, time_histogram_per_timeline, timelines, command);
844+
let needs_repaint = self.handle_time_command(
845+
blueprint_ctx,
846+
time_histogram_per_timeline,
847+
timelines,
848+
command,
849+
);
838850

839851
if needs_repaint == NeedsRepaint::Yes {
840852
response.needs_repaint = NeedsRepaint::Yes;
@@ -1259,9 +1271,17 @@ impl TimeControl {
12591271
}
12601272

12611273
if self.following {
1262-
self.set_play_state(time_histogram_per_timeline, PlayState::Following, blueprint_ctx);
1274+
self.set_play_state(
1275+
time_histogram_per_timeline,
1276+
PlayState::Following,
1277+
blueprint_ctx,
1278+
);
12631279
} else {
1264-
self.set_play_state(time_histogram_per_timeline, PlayState::Playing, blueprint_ctx);
1280+
self.set_play_state(
1281+
time_histogram_per_timeline,
1282+
PlayState::Playing,
1283+
blueprint_ctx,
1284+
);
12651285
}
12661286
}
12671287
}
@@ -1456,14 +1476,16 @@ impl TimeControl {
14561476
&self,
14571477
time_histogram_per_timeline: &TimeHistogramPerTimeline,
14581478
) -> Option<AbsoluteTimeRange> {
1459-
time_histogram_per_timeline.get(self.timeline().name()).map(|hist| {
1460-
let data_range = range(hist);
1461-
let max_valid_range_for = self.max_valid_range_for(*self.timeline().name());
1462-
AbsoluteTimeRange::new(
1463-
data_range.min.max(max_valid_range_for.min),
1464-
data_range.max.min(max_valid_range_for.max),
1465-
)
1466-
})
1479+
time_histogram_per_timeline
1480+
.get(self.timeline().name())
1481+
.map(|hist| {
1482+
let data_range = range(hist);
1483+
let max_valid_range_for = self.max_valid_range_for(*self.timeline().name());
1484+
AbsoluteTimeRange::new(
1485+
data_range.min.max(max_valid_range_for.min),
1486+
data_range.max.min(max_valid_range_for.max),
1487+
)
1488+
})
14671489
}
14681490

14691491
/// The selected slice of time that is called the "loop selection".
@@ -1537,16 +1559,14 @@ fn default_timeline(
15371559
let most_events = time_histogram_per_timeline
15381560
.iter()
15391561
.filter_map(|(name, hist)| {
1540-
timelines.get(name).map(|timeline| {
1541-
(timeline, hist.total_count())
1542-
})
1562+
timelines
1563+
.get(name)
1564+
.map(|timeline| (timeline, hist.total_count()))
15431565
})
15441566
.max_by(|(a_timeline, a_count), (b_timeline, b_count)| {
15451567
a_count
15461568
.cmp(b_count)
1547-
.then_with(|| {
1548-
timeline_priority(a_timeline).cmp(&timeline_priority(b_timeline))
1549-
})
1569+
.then_with(|| timeline_priority(a_timeline).cmp(&timeline_priority(b_timeline)))
15501570
});
15511571

15521572
if let Some((timeline, _)) = most_events {
@@ -1623,7 +1643,13 @@ fn step_back_time_looped(
16231643
mod tests {
16241644
use super::*;
16251645

1626-
fn create_test_data(timelines: &[Timeline], counts: &[u64]) -> (TimeHistogramPerTimeline, std::collections::BTreeMap<TimelineName, Timeline>) {
1646+
fn create_test_data(
1647+
timelines: &[Timeline],
1648+
counts: &[u64],
1649+
) -> (
1650+
TimeHistogramPerTimeline,
1651+
std::collections::BTreeMap<TimelineName, Timeline>,
1652+
) {
16271653
let mut hist_per_timeline = TimeHistogramPerTimeline::default();
16281654
let mut timeline_map = std::collections::BTreeMap::new();
16291655

@@ -1661,23 +1687,43 @@ mod tests {
16611687
assert_eq!(default_timeline(&hist_both, &timelines_both), log_time);
16621688

16631689
// Custom timeline should win over both log_time and log_tick when counts are equal
1664-
let (hist_custom0, timelines_custom0) = create_test_data(&[log_time, log_tick, custom_timeline0], &[42, 42, 42]);
1665-
assert_eq!(default_timeline(&hist_custom0, &timelines_custom0), custom_timeline0);
1690+
let (hist_custom0, timelines_custom0) =
1691+
create_test_data(&[log_time, log_tick, custom_timeline0], &[42, 42, 42]);
1692+
assert_eq!(
1693+
default_timeline(&hist_custom0, &timelines_custom0),
1694+
custom_timeline0
1695+
);
16661696

16671697
// Order shouldn't matter
1668-
let (hist_custom0_rev, timelines_custom0_rev) = create_test_data(&[custom_timeline0, log_time, log_tick], &[42, 42, 42]);
1669-
assert_eq!(default_timeline(&hist_custom0_rev, &timelines_custom0_rev), custom_timeline0);
1698+
let (hist_custom0_rev, timelines_custom0_rev) =
1699+
create_test_data(&[custom_timeline0, log_time, log_tick], &[42, 42, 42]);
1700+
assert_eq!(
1701+
default_timeline(&hist_custom0_rev, &timelines_custom0_rev),
1702+
custom_timeline0
1703+
);
16701704

1671-
let (hist_custom0_mid, timelines_custom0_mid) = create_test_data(&[log_time, custom_timeline0, log_tick], &[42, 42, 42]);
1672-
assert_eq!(default_timeline(&hist_custom0_mid, &timelines_custom0_mid), custom_timeline0);
1705+
let (hist_custom0_mid, timelines_custom0_mid) =
1706+
create_test_data(&[log_time, custom_timeline0, log_tick], &[42, 42, 42]);
1707+
assert_eq!(
1708+
default_timeline(&hist_custom0_mid, &timelines_custom0_mid),
1709+
custom_timeline0
1710+
);
16731711

16741712
// Custom timelines with different counts - higher count wins
1675-
let (hist_custom1, timelines_custom1) = create_test_data(&[custom_timeline0, custom_timeline1], &[42, 43]);
1676-
assert_eq!(default_timeline(&hist_custom1, &timelines_custom1), custom_timeline1);
1713+
let (hist_custom1, timelines_custom1) =
1714+
create_test_data(&[custom_timeline0, custom_timeline1], &[42, 43]);
1715+
assert_eq!(
1716+
default_timeline(&hist_custom1, &timelines_custom1),
1717+
custom_timeline1
1718+
);
16771719

16781720
// Single custom timeline
1679-
let (hist_single_custom, timelines_single_custom) = create_test_data(&[custom_timeline0], &[42]);
1680-
assert_eq!(default_timeline(&hist_single_custom, &timelines_single_custom), custom_timeline0);
1721+
let (hist_single_custom, timelines_single_custom) =
1722+
create_test_data(&[custom_timeline0], &[42]);
1723+
assert_eq!(
1724+
default_timeline(&hist_single_custom, &timelines_single_custom),
1725+
custom_timeline0
1726+
);
16811727
}
16821728

16831729
#[test]
@@ -1690,16 +1736,28 @@ mod tests {
16901736
hist.increment(30, 1);
16911737

16921738
// Step forward from before first key
1693-
assert_eq!(step_fwd_time(TimeReal::from(5), &hist), TimeInt::new_temporal(10));
1739+
assert_eq!(
1740+
step_fwd_time(TimeReal::from(5), &hist),
1741+
TimeInt::new_temporal(10)
1742+
);
16941743

16951744
// Step forward from middle
1696-
assert_eq!(step_fwd_time(TimeReal::from(15), &hist), TimeInt::new_temporal(20));
1745+
assert_eq!(
1746+
step_fwd_time(TimeReal::from(15), &hist),
1747+
TimeInt::new_temporal(20)
1748+
);
16971749

16981750
// Step forward from last key (wraps around)
1699-
assert_eq!(step_fwd_time(TimeReal::from(30), &hist), TimeInt::new_temporal(10));
1751+
assert_eq!(
1752+
step_fwd_time(TimeReal::from(30), &hist),
1753+
TimeInt::new_temporal(10)
1754+
);
17001755

17011756
// Step forward from after last key (wraps around)
1702-
assert_eq!(step_fwd_time(TimeReal::from(35), &hist), TimeInt::new_temporal(10));
1757+
assert_eq!(
1758+
step_fwd_time(TimeReal::from(35), &hist),
1759+
TimeInt::new_temporal(10)
1760+
);
17031761

17041762
// Empty histogram
17051763
let empty_hist = TimeHistogram::default();
@@ -1716,20 +1774,35 @@ mod tests {
17161774
hist.increment(30, 1);
17171775

17181776
// Step back from after last key
1719-
assert_eq!(step_back_time(TimeReal::from(35), &hist), TimeInt::new_temporal(30));
1777+
assert_eq!(
1778+
step_back_time(TimeReal::from(35), &hist),
1779+
TimeInt::new_temporal(30)
1780+
);
17201781

17211782
// Step back from middle
1722-
assert_eq!(step_back_time(TimeReal::from(25), &hist), TimeInt::new_temporal(20));
1783+
assert_eq!(
1784+
step_back_time(TimeReal::from(25), &hist),
1785+
TimeInt::new_temporal(20)
1786+
);
17231787

17241788
// Step back from first key (wraps around)
1725-
assert_eq!(step_back_time(TimeReal::from(10), &hist), TimeInt::new_temporal(30));
1789+
assert_eq!(
1790+
step_back_time(TimeReal::from(10), &hist),
1791+
TimeInt::new_temporal(30)
1792+
);
17261793

17271794
// Step back from before first key (wraps around)
1728-
assert_eq!(step_back_time(TimeReal::from(5), &hist), TimeInt::new_temporal(30));
1795+
assert_eq!(
1796+
step_back_time(TimeReal::from(5), &hist),
1797+
TimeInt::new_temporal(30)
1798+
);
17291799

17301800
// Empty histogram
17311801
let empty_hist = TimeHistogram::default();
1732-
assert_eq!(step_back_time(TimeReal::from(10), &empty_hist), TimeInt::MIN);
1802+
assert_eq!(
1803+
step_back_time(TimeReal::from(10), &empty_hist),
1804+
TimeInt::MIN
1805+
);
17331806
}
17341807

17351808
#[test]
@@ -1744,16 +1817,28 @@ mod tests {
17441817
let loop_range = AbsoluteTimeRangeF::new(15.0, 25.0);
17451818

17461819
// Before loop range - should jump to start
1747-
assert_eq!(step_fwd_time_looped(TimeReal::from(5), &hist, &loop_range), TimeReal::from(15.0));
1820+
assert_eq!(
1821+
step_fwd_time_looped(TimeReal::from(5), &hist, &loop_range),
1822+
TimeReal::from(15.0)
1823+
);
17481824

17491825
// In loop range - should step to next key
1750-
assert_eq!(step_fwd_time_looped(TimeReal::from(15), &hist, &loop_range), TimeReal::from(20));
1826+
assert_eq!(
1827+
step_fwd_time_looped(TimeReal::from(15), &hist, &loop_range),
1828+
TimeReal::from(20)
1829+
);
17511830

17521831
// At end of loop range - should wrap to start
1753-
assert_eq!(step_fwd_time_looped(TimeReal::from(25), &hist, &loop_range), TimeReal::from(15.0));
1832+
assert_eq!(
1833+
step_fwd_time_looped(TimeReal::from(25), &hist, &loop_range),
1834+
TimeReal::from(15.0)
1835+
);
17541836

17551837
// After loop range - should jump to start
1756-
assert_eq!(step_fwd_time_looped(TimeReal::from(35), &hist, &loop_range), TimeReal::from(15.0));
1838+
assert_eq!(
1839+
step_fwd_time_looped(TimeReal::from(35), &hist, &loop_range),
1840+
TimeReal::from(15.0)
1841+
);
17571842
}
17581843

17591844
#[test]
@@ -1768,16 +1853,28 @@ mod tests {
17681853
let loop_range = AbsoluteTimeRangeF::new(15.0, 25.0);
17691854

17701855
// Before loop range - should jump to end
1771-
assert_eq!(step_back_time_looped(TimeReal::from(5), &hist, &loop_range), TimeReal::from(25.0));
1856+
assert_eq!(
1857+
step_back_time_looped(TimeReal::from(5), &hist, &loop_range),
1858+
TimeReal::from(25.0)
1859+
);
17721860

17731861
// In loop range - should step to previous key
1774-
assert_eq!(step_back_time_looped(TimeReal::from(25), &hist, &loop_range), TimeReal::from(20));
1862+
assert_eq!(
1863+
step_back_time_looped(TimeReal::from(25), &hist, &loop_range),
1864+
TimeReal::from(20)
1865+
);
17751866

17761867
// At start of loop range - should wrap to end
1777-
assert_eq!(step_back_time_looped(TimeReal::from(15), &hist, &loop_range), TimeReal::from(25.0));
1868+
assert_eq!(
1869+
step_back_time_looped(TimeReal::from(15), &hist, &loop_range),
1870+
TimeReal::from(25.0)
1871+
);
17781872

17791873
// After loop range - should jump to end
1780-
assert_eq!(step_back_time_looped(TimeReal::from(35), &hist, &loop_range), TimeReal::from(25.0));
1874+
assert_eq!(
1875+
step_back_time_looped(TimeReal::from(35), &hist, &loop_range),
1876+
TimeReal::from(25.0)
1877+
);
17811878
}
17821879

17831880
#[test]
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)