use crate::ifs::wl_seat::BTN_LEFT;
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 win1 = client.create_window().await?;
win1.map2().await?;
let win2 = client.create_window().await?;
win2.map2().await?;
let seat = client.get_default_seat().await?;
let button = seat.pointer.button.expect()?;
let (x, y) = win1.tl.server.node_absolute_position(LiveTL).center();
ds.move_to(x, y);
let click = ds.mouse.click(BTN_LEFT);
client.sync().await;
let dev = client.get_data_device(&seat.seat);
let src = client.create_data_source();
src.set_actions(1);
dev.start_drag(&src, &win1.surface, None, button.next()?.serial);
client.sync().await;
let enter = seat.pointer.enter.expect()?;
let (x, y) = win2.tl.server.node_absolute_position(LiveTL).center();
ds.move_to(x, y);
client.sync().await;
tassert!(enter.next().is_err());
drop(click);
client.sync().await;
client.sync().await;
tassert_eq!(enter.next()?.surface, win2.surface.id);
Ok(())
}