from ccma.ui.monitors import MonitorBounds, centered_geometry, ensure_visible_geometry, parse_geometry


def test_centered_geometry_supports_monitor_left_of_primary() -> None:
    monitor = MonitorBounds(-1920, 0, 1920, 1080)
    geometry = centered_geometry(620, 330, monitor)
    assert parse_geometry(geometry) == (620, 330, -1270, 375)


def test_saved_geometry_is_clamped_to_selected_monitor() -> None:
    monitor = MonitorBounds(1920, 0, 1920, 1080)
    geometry = ensure_visible_geometry("1500x860-1600+100", monitor)
    assert parse_geometry(geometry) == (1500, 860, 1920, 100)
