Lines
100 %
Functions
Branches
use super::{MAX_HEIGHT, MIN_HEIGHT, Placement, Span, placement, roomy};
const PHONE: Span = Span {
top: 0.0,
bottom: 400.0,
};
fn input_at(top: f64) -> Span {
Span {
top,
bottom: top + 30.0,
}
#[test]
fn an_input_near_the_top_opens_below_capped_at_the_maximum() {
let at = placement(input_at(20.0), PHONE, 500.0);
assert_eq!(
at,
Placement {
above: false,
max_height: MAX_HEIGHT
);
fn an_input_near_the_bottom_opens_above_within_the_room() {
let at = placement(input_at(330.0), PHONE, 500.0);
assert!(at.above);
assert_eq!(at.max_height, MAX_HEIGHT);
let short = Span {
bottom: 300.0,
let tight = placement(input_at(150.0), short, 500.0);
assert!(tight.above);
assert_eq!(tight.max_height, 142.0);
fn a_short_list_stays_below_while_it_fits() {
let at = placement(input_at(300.0), PHONE, 60.0);
assert!(!at.above);
assert_eq!(at.max_height, MIN_HEIGHT);
fn the_visual_viewport_offset_counts() {
let keyboard = Span {
top: 300.0,
bottom: 650.0,
let at = placement(input_at(560.0), keyboard, 500.0);
assert_eq!(at.max_height, 200.0);
assert!(at.max_height <= 560.0 - keyboard.top);
fn the_cap_never_drops_below_three_items() {
let squeezed = Span {
bottom: 150.0,
assert!(!roomy(input_at(60.0), squeezed));
placement(input_at(60.0), squeezed, 500.0).max_height,
MIN_HEIGHT
assert!(roomy(input_at(20.0), PHONE));