Lines
100 %
Functions
Branches
//! A click on any cell of the `▐↓▌` mark of a form select field opens its list.
use super::caret_tests::{form_mut, select_field, with_field};
use super::click_tests::{now, presets, press};
use super::*;
use crate::test_support::{area_of, redraw};
use tvui::HISTORY_CELLS;
fn mark() -> Target {
Target::Mark {
field: 0,
cell: None,
}
fn click_cell(app: &mut App, dx: u16) {
redraw(app);
let area = area_of(app, mark());
let position = Position::new(area.x + dx, area.y);
press(
app,
position,
MouseEventKind::Down(MouseButton::Left),
now(),
);
#[test]
fn a_click_on_each_cell_of_the_mark_opens_the_unfocused_select() {
for dx in 0..HISTORY_CELLS {
for app in presets() {
let mut app = with_field(app, select_field());
form_mut(&mut app).focus = 1;
click_cell(&mut app, dx);
let form = form_mut(&mut app);
assert_eq!(form.focus, 0, "cell {dx}");
assert!(
form.focused_select().is_some_and(|select| select.open),
"cell {dx}"
fn the_cell_before_the_mark_only_focuses_the_select() {
redraw(&mut app);
let area = area_of(&app, mark());
let position = Position::new(area.x - 1, area.y);
&mut app,
assert_eq!(form.focus, 0);
assert!(form.focused_select().is_some_and(|select| !select.open));
fn a_click_past_the_mark_does_not_open_the_select() {
let mut app = with_field(crate::test_support::app(), select_field());
let position = Position::new(area.right(), area.y);
form_mut(&mut app)
.focused_select()
.is_none_or(|select| !select.open)