e48d4bbe88
- Introduced a new benchmark save script to create a stress test scenario with extreme values for simulation performance. - Added a full UI benchmark script to measure frame rates and performance metrics during UI interactions. - Implemented tests for coarse generations to ensure population transitions are handled correctly. - Created tests for extra parameters to validate the loading and application of configuration settings. - Developed simulation optimization tests to verify the efficiency of population drift and rounding mechanisms. - Added split optimization tests to ensure accurate allocation and rounding behavior in population management. - Included startup parameter tests to confirm the correct initialization of global parameters before scene readiness. - Enhanced the audit rounding ledger to compare selective and full rounding results for consistency.
95 lines
5.0 KiB
GDScript
95 lines
5.0 KiB
GDScript
extends SceneTree
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
|
|
|
var checks: int = 0
|
|
var failures: int = 0
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
|
|
func check(value: bool, message: String) -> void:
|
|
checks = E.add(checks, 1)
|
|
if (not value):
|
|
failures = E.add(failures, 1)
|
|
push_error(message)
|
|
|
|
func run() -> void:
|
|
var scene = load("res://world/world.tscn").instantiate()
|
|
var stage = scene.get_node("Stage")
|
|
stage.owniverse.free()
|
|
stage.set_script(load("res://tests/fixtures/ui_stage.gd"))
|
|
root.add_child(scene)
|
|
await process_frame
|
|
await process_frame
|
|
check(stage.effects_player.stream == null, "Startup does not play a UI sound")
|
|
stage.stage_page_scroller.scroll_horizontal = stage.PAGE_WIDTH
|
|
await process_frame
|
|
stage.owniverse.state.amount.H = 1000
|
|
stage.owniverse.state.amount.RD = 2
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
stage.set_owniverse_item_value()
|
|
var hydrogen = stage.owniverse_items.H
|
|
var dwarf = stage.owniverse_items.RD
|
|
check(E.eq(hydrogen.description.text, "1 000"), "Pending quantities reach controls")
|
|
check(E.eq(dwarf.description.text, "2"), "Other page receives its current quantity")
|
|
check(stage.owniverse.presentation.pending_amounts.is_empty(), "Published queue is consumed by Stage")
|
|
stage.owniverse.presentation.deferred_updates = true
|
|
stage.owniverse.state.amount.H = 2000
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
check((stage.owniverse.presentation.dirty and stage.owniverse.presentation.pending_amounts.is_empty()), "Deferred refresh marks dirty without republishing")
|
|
stage.set_owniverse_item_value()
|
|
check(E.eq(hydrogen.description.text, "1 000"), "Labels retain last published quantity")
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog, true)
|
|
stage.set_owniverse_item_value()
|
|
check((E.eq(hydrogen.description.text, "2 000") and (not stage.owniverse.presentation.dirty)), "Forced refresh publishes latest state")
|
|
stage.owniverse.presentation.deferred_updates = false
|
|
stage.item_activated(hydrogen)
|
|
stage.set_owniverse_item_value()
|
|
check(E.eq(hydrogen.description.text, root.get_node("Global").format_number(stage.owniverse.state.amount.H)), "Player production publishes the new quantity")
|
|
check(E.gt(stage.owniverse.state.amount.H, 2000), "Production action actually executed")
|
|
dwarf.visible = true
|
|
stage.stage_page_scroller.scroll_horizontal = E.multiply(2, stage.PAGE_WIDTH)
|
|
await process_frame
|
|
stage._refresh_universe_ui()
|
|
check(E.eq(dwarf.description.text, "2"), "Newly visible page receives cached latest values")
|
|
stage.owniverse.state.time.year = E.of("1234.5")
|
|
stage._refresh_universe_ui()
|
|
check(E.eq(stage.date_time.text, "1 234.5"), "Time displays tenths with thousands separator")
|
|
stage.effects_player.set_enabled(true)
|
|
stage.owniverse.speed = 1
|
|
stage._change_speed(1)
|
|
check(stage.effects_player.stream == stage.effects_player._effects.time_plus, "Increasing speed plays its effect")
|
|
stage._change_speed(-1)
|
|
check(stage.effects_player.stream == stage.effects_player._effects.time_minus, "Decreasing speed plays its effect")
|
|
stage._on_topmenu_button_pressed("MainMenu")
|
|
check(stage.effects_player.stream == stage.effects_player._effects.window_open, "Opening a window plays its effect")
|
|
stage._on_topmenu_button_pressed("World")
|
|
check(stage.effects_player.stream == stage.effects_player._effects.window_close, "Closing a window plays its effect")
|
|
stage.indicator_elapsed = 1.0
|
|
stage.active_actions_elapsed = 1.0
|
|
stage.tick_ui(0.0)
|
|
var refreshes: int = stage.actions_refreshes
|
|
stage.date_time.text = "unchanged"
|
|
stage.active_actions_elapsed = 1.0
|
|
stage.tick_ui(0.0)
|
|
check(stage.actions_refreshes == refreshes, "Idle UI does not recalculate production limits")
|
|
check(stage.date_time.text == "unchanged", "Idle UI does not reformat the clock")
|
|
stage.owniverse.state.amount.H = 3456
|
|
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
|
stage.tick_ui(0.0)
|
|
check(hydrogen.description.text == "3 456", "A manual publication updates idle UI")
|
|
check(stage.actions_refreshes == refreshes + 1, "A publication invalidates production limits")
|
|
stage.active_actions_dirty = true
|
|
stage.tick_ui(0.0)
|
|
check(stage.actions_refreshes == refreshes + 2, "Selection invalidation refreshes limits immediately")
|
|
var old_pointer: float = stage.world_indicators.pointers.Agg.position.x
|
|
stage.owniverse.environment.modify_world_parameter("Agg", 1)
|
|
stage.indicator_elapsed = 1.0
|
|
stage.tick_ui(0.0)
|
|
check(stage.world_indicators.pointers.Agg.position.x != old_pointer, "World parameter actions invalidate indicators")
|
|
for entity in stage.owniverse.catalog.entities.values(): entity.free()
|
|
stage.owniverse.free()
|
|
scene.free()
|
|
print(("UI updates: %d checks, %d failures" % [checks, failures]))
|
|
quit((0 if E.eq(failures, 0) else 1))
|