package layout import ( "testing" "git.eeqj.de/sneak/hdmistat/internal/fbdraw" ) func TestBasicDrawing(t *testing.T) { // Create a small grid for testing grid := fbdraw.NewCharGrid(40, 10) draw := NewDraw(grid) // Clear the screen draw.Clear() // Draw some text draw.Color(Color("white")).Text(5, 2, "Hello") draw.TextCenter(0, 4, "Centered") // Create a sub-grid with border subGrid := draw.Grid(1, 1, 38, 8) subGrid.Border(Color("gray50")) // Basic checks if grid.Width != 40 { t.Errorf("Expected width 40, got %d", grid.Width) } if grid.Height != 10 { t.Errorf("Expected height 10, got %d", grid.Height) } // Check that some text was written (not all cells are empty) hasContent := false for y := 0; y < grid.Height; y++ { for x := 0; x < grid.Width; x++ { if grid.Cells[y][x].Rune != ' ' { hasContent = true break } } } if !hasContent { t.Error("Expected some content in the grid, but all cells are empty") } // Print the grid for visual inspection t.Logf("Rendered grid:\n%s", grid) } func TestHelloWorldScenario(t *testing.T) { // Simulate the hello world scenario grid := fbdraw.NewCharGrid(80, 25) draw := NewDraw(grid) draw.Clear() centerY := grid.Height / 2 draw.Color(Color("cyan")).Bold() draw.TextCenter(0, centerY-2, "Hello World") draw.Color(Color("white")).Plain() draw.TextCenter(0, centerY, "12:34:56") draw.Color(Color("gray60")) draw.TextCenter(0, centerY+2, "Uptime: 1:23") borderGrid := draw.Grid(2, 2, grid.Width-4, grid.Height-4) borderGrid.Border(Color("gray30")) // Check that the grid has the expected content gridStr := grid.String() t.Logf("Hello World grid:\n%s", gridStr) // Very basic check - just ensure it's not empty if len(gridStr) == 0 { t.Error("Grid string is empty") } }