in src/app.rs [582:613]
fn test_toggle_graphs() {
let mut app = App::new();
// Initially, UI should be in table mode
assert_eq!(app.mode, Mode::Table);
// After calling show_graphs, UI should be in graph mode
app.show_graphs();
assert_eq!(app.mode, Mode::Graph);
// Set max_cpu, max_eps, and max_runtime to non-zero values
app.max_cpu = 10.0;
app.max_eps = 5;
app.max_runtime = 100;
app.data_buf.lock().unwrap().push_back(PeriodMeasure {
cpu_time_percent: 10.0,
events_per_sec: 5,
average_runtime_ns: 100,
});
// After calling show_table, UI should be in table mode again
app.show_table();
assert_eq!(app.mode, Mode::Table);
// max_cpu, max_eps, and max_runtime should be reset to 0
assert_eq!(app.max_cpu, 0.0);
assert_eq!(app.max_eps, 0);
assert_eq!(app.max_runtime, 0);
// and data_buf should be empty again
assert!(app.data_buf.lock().unwrap().is_empty());
}