Files
iccery-v2-mac/Tests/ICCeryCoreTests/GamutGeometryBuilderTests.swift
gronodandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> 87e4f4fa8e fix: pause SceneKit gamut view and guard out-of-bounds face indices
- GamutSceneView.dismantleNSView now sets scnView.isPlaying = false.
- GamutView pauses the renderer on .onDisappear so the sheet can be
  dismissed without relying solely on dismantleNSView.
- GamutSceneGeometryBuilder drops faces with any vertex index >=
  vertices.count before building the SCNGeometryElement; the edge-line
  builder filters the same way.
- Add GamutGeometryBuilderTests to verify an OOB face does not crash
  and is not included in the geometry element.

Generated with Devin

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-10 01:43:44 +01:00

34 lines
985 B
Swift

import Testing
import SceneKit
import ICCeryCore
@testable import ICCery
/// ``GamutSceneGeometryBuilder`` edge-case tests.
@Suite("Gamut scene geometry builder")
@MainActor
struct GamutGeometryBuilderTests {
@Test("Drops out-of-bounds faces from the element without crashing")
func dropsOutOfBoundsFaces() {
let white = GamutVertex(
lab: LabColor(l: 100, a: 0, b: 0),
rgb: DisplayRGB(r: 1, g: 1, b: 1)
)
let black = GamutVertex(
lab: LabColor(l: 0, a: 0, b: 0),
rgb: DisplayRGB(r: 0, g: 0, b: 0)
)
let mesh = GamutMesh(
vertices: [white, black],
faces: [
GamutTriangle(a: 0, b: 1, c: 0),
GamutTriangle(a: 0, b: 1, c: 99)
]
)
let (_, element) = GamutSceneGeometryBuilder.geometry(for: mesh)
#expect(element.primitiveCount == 1, "Only the in-bounds face should be in the index buffer")
}
}