Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / tests / editor / project_settings_tests.luc

## Window › Project settings…: the dialog edits a draft of the project's units
## and time; Cancel forgets it, Apply makes it the project's as one undo step.
from app import Luce3D
import units

pub func project_settings_tests() -> unit!:
    let editor = Luce3D()
    let w = editor.workspace
    let dialog = editor.panels.project_settings
    # The units moved out of the File menu: no command but this one sets them.
    for command in editor.panels.actions.all:
        assert(not (command.id() in ["units_mm", "units_in"]))
    editor.panels.actions.project_settings.trigger()
    assert(dialog.is_open())
    editor.app.layout(1400.0, 900.0)
    # Floating and centered over the window.
    let card = dialog.dialog.layout().bounds()
    assert(card.width > 0.0 and card.height > 0.0)
    assert(card.x > 0.0 and card.x + card.width < 1400.0 and card.y > 0.0 and card.y + card.height < 900.0)
    assert(card.x + card.width * 0.5 > 690.0 and card.x + card.width * 0.5 < 710.0)
    # Cancel forgets the draft.
    dialog.draft.units = "in"
    dialog.draft.fps = 30.0
    dialog.cancel()
    assert(not dialog.is_open() and w.network.units == "mm" and w.network.fps == 24.0)
    # Apply makes it the project's, as one undo step.
    dialog.open()
    assert(dialog.draft.units == "mm" and dialog.draft.fps == 24.0 and dialog.draft.start == 1.0 and dialog.draft.end == 240.0)
    dialog.draft.units = "in"
    dialog.draft.fps = 30.0
    dialog.draft.start = 10.0
    dialog.draft.end = 100.0
    dialog.apply()
    let g = w.network
    assert(not dialog.is_open() and g.units == "in" and g.fps == 30.0 and g.start == 10.0 and g.end == 100.0)
    assert(units.document_unit(w).suffix.trim() == "in")
    w.undo()
    assert(w.network.units == "mm" and w.network.fps == 24.0 and w.network.start == 1.0 and w.network.end == 240.0)
    w.redo()
    assert(w.network.units == "in" and w.network.fps == 30.0 and w.network.end == 100.0)
    # Applying what the project already has changes nothing (no undo step).
    dialog.open()
    dialog.apply()
    w.undo()
    assert(w.network.units == "mm")
    editor.close()
    print("PASS Project settings: Window menu, a centered dialog, draft, Cancel, Apply as one undo step, no unit commands in File")