use crate::fixed::Fixed;
use crate::it::test_client::TestClientExt;
use crate::it::test_error::TestResult;
use crate::it::testrun::TestRun;
use crate::tree::NodeBase;
use crate::tree::TreeTimeline::LiveTL;
use std::rc::Rc;
testcase!();
async fn test(run: Rc<TestRun>) -> TestResult {
let ds = run.create_default_setup().await?;
let client = run.create_client()?;
let seat = client.get_default_seat().await?;
let enter = seat.pointer.enter.expect()?;
let win1 = client.create_window().await?;
win1.map2().await?;
let (x, y) = win1
.surface
.server
.node_absolute_position(LiveTL)
.position();
ds.move_to(x, y);
run.state.idle().await;
client.sync().await;
let enter_serial = enter.last()?.serial;
let warp_x = Fixed::from_int(200);
let warp_y = Fixed::from_int(150);
client.warp_pointer(&win1.surface, &seat.pointer, warp_x, warp_y, enter_serial);
client.sync().await;
run.state.idle().await;
let (cursor_x, cursor_y) = ds.seat.pointer_cursor().position();
let expected_x = Fixed::from_int(x) + warp_x;
let expected_y = Fixed::from_int(y) + warp_y;
tassert_eq!(cursor_x, expected_x);
tassert_eq!(cursor_y, expected_y);
Ok(())
}