`Proxy` is the task queue as well as the way an application sends its own events, so `ProxyQueue` is gone. `schedule_redraw` becomes `request_redraw_if_needed`, which says what the comment beside it was saying. `assert_corners!` replaces the region helper, so `tests/common` goes with it, and the scroll test now states both corners rather than one number.
27 lines
818 B
Rust
27 lines
818 B
Rust
//! Scrolling moves content and stops at its ends.
|
|
|
|
use iris::harness::{Harness, assert_corners};
|
|
use iris::prelude::*;
|
|
|
|
#[test]
|
|
fn a_wheel_scrolls_the_content_and_stops_at_its_end() {
|
|
let mut h = Harness::new((400, 200));
|
|
// Twice the window's height, so there is 200 to scroll.
|
|
let top = rect(Color::RED).height(200).add(&mut h.rsc);
|
|
let bottom = rect(Color::BLUE).height(200).add(&mut h.rsc);
|
|
h.set_root((top, bottom).span(Dir::DOWN).scrollable());
|
|
h.move_to((200, 100));
|
|
|
|
// `Scroll` starts snapped to the end.
|
|
assert_corners!(h, top, (0, -200), (400, 0));
|
|
|
|
// The handler scales a wheel line by 50.
|
|
h.scroll((0, 1));
|
|
h.frame();
|
|
assert_corners!(h, top, (0, -150), (400, 50));
|
|
|
|
h.scroll((0, 10));
|
|
h.frame();
|
|
assert_corners!(h, top, (0, 0), (400, 200));
|
|
}
|