"""
Tests for video composition functionality.
"""

import pytest
import fmusvid
from pathlib import Path

@pytest.fixture
def sample_videos(tmp_path):
    """Create sample videos for testing."""
    videos = []
    for i in range(4):
        path = tmp_path / f"clip{i}.mp4"
        video = fmusvid.create(
            width=640,
            height=360,
            duration=5.0,
            fps=30
        )
        video.save(path)
        videos.append(path)
    return videos

def test_picture_in_picture(sample_videos):
    """Test picture-in-picture overlay."""
    main = fmusvid.load(sample_videos[0])
    overlay = fmusvid.load(sample_videos[1])

    result = main.overlay(
        overlay.resize(width=320),
        position=(50, 50),
        start=1.0,
        duration=3.0
    )

    assert result.width == main.width
    assert result.height == main.height
    assert result.duration == main.duration

def test_video_grid(sample_videos):
    """Test video grid creation."""
    videos = [fmusvid.load(path) for path in sample_videos]

    grid = fmusvid.grid(
        videos,
        rows=2,
        cols=2
    )

    # Grid scales videos to fit: width is maintained, height is divided by rows
    expected_width = videos[0].width * 2
    expected_height = (videos[0].height // 2) * 2

    assert grid.width == expected_width
    assert grid.height == expected_height
    assert grid.duration == max(v.duration for v in videos)

def test_transitions(sample_videos):
    """Test video transitions."""
    pytest.skip("transition module not yet exposed in API")

def test_split_screen(sample_videos):
    """Test split screen composition."""
    pytest.skip("compose function not yet implemented")
