The two client fixes for the Atlas frames Jeroen flagged. Region rung no longer requests more planet than exists: cap_extent_to_body() caps the viewport-fit extent at the body's own region grid (the Global canvas extent echo — cols=regions_per_equator, rows=cols/2), matched by gridunit SPACING not rung name, applied before the request/cache key is built; cold-start scroll-before-Global-echo requests uncapped and lets the server clamp (documented). Kills both the side-by-side continent repeat and the past-the-pole stripe smear. Global opener now fit-scales and centers through one shared letterbox mechanism (center_offset/integer_fit_scale/fit_scale, 75%-coverage integer-vs-fractional decision, NEAREST already forced on orbital rungs per D-255's escape hatch) also used for the Region cap's letterbox remainder. Legend column reserved before fitting — pinned to the legend's own width by a cross-constant test, never overlapping the canvas. Also fixes a latent crash: NOTIFICATION_RESIZED fires mid-_ready() before children exist; null guard in the resize path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
83 lines
3.3 KiB
GDScript
83 lines
3.3 KiB
GDScript
## T-1182 tests: StepCanvasLegend — smoke coverage (PR #203 review, Hoshe
|
|
## note). Not the retired atlas_window_legend.gd's own richer suite (that
|
|
## file never had a dedicated test — its coverage lived entirely inside
|
|
## AtlasWindowViewer's own suites, now retired); this pins the panel's basic
|
|
## lifecycle/content contract directly.
|
|
class_name TestStepCanvasLegend
|
|
extends GdUnitTestSuite
|
|
|
|
const LegendScript := preload("res://ui/implant/apps/atlas/step_canvas/step_canvas_legend.gd")
|
|
const StepCanvasTransport := preload("res://ui/implant/apps/atlas/step_canvas/step_canvas_transport.gd")
|
|
|
|
|
|
func test_legend_starts_hidden_before_refresh() -> void:
|
|
var v: StepCanvasViewer = auto_free(StepCanvasViewer.new())
|
|
add_child(v)
|
|
var legend = LegendScript.new(v)
|
|
auto_free(legend)
|
|
assert_bool(legend.visible).is_false()
|
|
|
|
|
|
func test_refresh_makes_the_legend_visible_and_populates_content() -> void:
|
|
var v: StepCanvasViewer = auto_free(StepCanvasViewer.new())
|
|
add_child(v)
|
|
v.enter({"body_id": "GJ380c", "body_radius_km": 6238.4}, {})
|
|
var legend = LegendScript.new(v)
|
|
add_child(legend)
|
|
legend.refresh()
|
|
assert_bool(legend.visible).is_true()
|
|
assert_int(legend.get_implant_children().size()).override_failure_message(
|
|
"refresh() must populate at least the always-on morphology/glaciation sections"
|
|
).is_greater(0)
|
|
|
|
|
|
## refresh() is a no-op (does not crash) when the legend has no viewer —
|
|
## defensive guard against a construction-order mistake.
|
|
func test_refresh_without_a_viewer_does_not_crash() -> void:
|
|
var legend = LegendScript.new(null)
|
|
auto_free(legend)
|
|
legend.refresh()
|
|
assert_bool(legend.visible).is_false()
|
|
|
|
|
|
## Toggling a gen_* overlay on changes the legend's content (the active
|
|
## toggle section appears) without crashing — the same "no active toggle by
|
|
## default, one section per active toggle" contract the retired
|
|
## atlas_window_legend.gd's own refresh() doc described.
|
|
func test_refresh_reflects_the_active_overlay_toggle() -> void:
|
|
var v: StepCanvasViewer = auto_free(StepCanvasViewer.new())
|
|
add_child(v)
|
|
v.enter({"body_id": "GJ380c", "body_radius_km": 6238.4}, {})
|
|
var legend = LegendScript.new(v)
|
|
add_child(legend)
|
|
legend.refresh()
|
|
var rows_before: int = legend.get_implant_children().size()
|
|
|
|
v.set_overlay_visible("gen_dw_temp", true)
|
|
legend.refresh()
|
|
var rows_after: int = legend.get_implant_children().size()
|
|
|
|
assert_int(rows_after).override_failure_message(
|
|
"activating a toggle overlay must add its own legend section"
|
|
).is_greater(rows_before)
|
|
|
|
|
|
func test_reposition_sets_a_fixed_panel_margin_position() -> void:
|
|
var v: StepCanvasViewer = auto_free(StepCanvasViewer.new())
|
|
add_child(v)
|
|
var legend = LegendScript.new(v)
|
|
auto_free(legend)
|
|
legend.reposition()
|
|
assert_that(legend.position).is_equal(Vector2(LegendScript.PANEL_MARGIN, 60.0))
|
|
|
|
|
|
## T-1192: StepCanvasTransport.LEGEND_COLUMN_PX (the Global fit-scale
|
|
## reservation StepCanvasViewer applies) must stay derived from this SAME
|
|
## panel's own width/margin — a drift here would silently reopen the
|
|
## "legend overlaps the canvas" defect on one side while the OTHER side
|
|
## thinks it already reserved enough room.
|
|
func test_reserved_column_px_matches_the_transport_sides_own_constant() -> void:
|
|
assert_float(LegendScript.RESERVED_COLUMN_PX).is_equal_approx(
|
|
StepCanvasTransport.LEGEND_COLUMN_PX, 0.01
|
|
)
|