"""
Test manuale per il DiffViewer.
Crea due file temporanei con contenuti diversi e apre il diff viewer.
"""
import tempfile
import os
from pathlib import Path

# Crea file temporanei
with tempfile.TemporaryDirectory() as tmpdir:
    # File A (baseline)
    file_a = Path(tmpdir) / "test_a.py"
    file_a.write_text("""def hello():
    print("Hello, World!")
    return 42

def goodbye():
    print("Goodbye!")
    
class MyClass:
    def __init__(self):
        self.value = 10
    
    def method1(self):
        return self.value * 2
""")
    
    # File B (current) - con modifiche
    file_b = Path(tmpdir) / "test_b.py"
    file_b.write_text("""def hello():
    # Nuovo commento
    print("Hello, World!")
    print("Extra line")
    return 42

def goodbye():
    print("Goodbye, my friend!")

def new_function():
    return "new"
    
class MyClass:
    def __init__(self):
        self.value = 10
        self.name = "test"
    
    def method1(self):
        # Metodo modificato
        return self.value * 3
""")
    
    print(f"File A: {file_a}")
    print(f"File B: {file_b}")
    
    # Test del DiffViewer
    import tkinter as tk
    from pyucc.gui.diff_viewer import show_diff_viewer
    
    root = tk.Tk()
    root.withdraw()  # Nascondi la finestra principale
    
    # Apri il diff viewer
    viewer = show_diff_viewer(root, str(file_a), str(file_b), 
                              title_a="Baseline", title_b="Current")
    
    # Avvia il loop di eventi
    root.mainloop()
