rule_check_indicator_test

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Test suite for RuleCheckIndicator class. Tests comprehensive rule-based placement validation including:

  • Indicator validity state changes based on collision rules
  • Visual settings updates (texture, modulate) on validity changes
  • Signal emission when validity state changes
  • Rule addition/removal after indicator initialization
  • Force validation updates and per-frame evaluation
  • Collision detection and contact point calculations
  • Integration with GridTargetingState and collision systems
  • Debug logging and environment variable configuration
  • Tile position calculations and visual sprite management Tests ensure proper integration between rules, collision detection, and visual feedback.

Source File: /addons/grid_building/test/rules/indicators/rule_check_indicator_test.gd

Extends: GdUnitTestSuite

Properties

  • Property: indicator: [RuleCheckIndicator](./rule-check-indicator/)
  • Property: test_layers: int = 1 # Bitmask
  • Property: offset_logo: PackedScene = GBTestConstants.SCENE_RECT_15_TILES - Logo offset away from the center for testing - using Godot icon as test texture
  • Property: runner: GdUnitSceneRunner

Private Properties

  • Property: _env: [AllSystemsTestEnvironment](./all-systems-test-environment/) (private) - Environment and container for tests
  • Property: _container: [GBCompositionContainer](./gb-composition-container/) (private)

Public Methods

diag

1
diag(message: String) -> String

indicator_state_diag

1
2
3
4
indicator_state_diag(
    ind: RuleCheckIndicator,
    header: String = ""
) -> String

Flags: static

Build a full indicator state diagnostic via RuleCheckIndicatorLogic helper


create_rule_targeting_state

1
create_rule_targeting_state() -> GridTargetingState

Helper method to get properly initialized GridTargetingState from environment


before

1
before() -> void

before_test

1
before_test() -> void

after_test

1
after_test() -> void

after

1
after() -> void

test_setup_indicator_defaults

1
test_setup_indicator_defaults() -> void

test_indicator_validity_switches_on_dynamic_collision

1
test_indicator_validity_switches_on_dynamic_collision() -> void

Integration test: indicator switches valid → fail → valid as collision body is added/removed


test_validity_sprite_texture_switches_on_validity_change

1
test_validity_sprite_texture_switches_on_validity_change() -> void

Test: validity_sprite texture changes when indicator validity changes


test_indicator_starts_valid_with_no_rules

1
test_indicator_starts_valid_with_no_rules() -> void

Test that indicators start in valid state when no rules are present


test_valid_changed_signal_emitted_on_state_change

1
2
3
4
5
test_valid_changed_signal_emitted_on_state_change(
    rule_spec: Dictionary,
    expected_value: bool,
    _test_parameters := [[ {"pass_on_collision": false, "mask": 1}, false]]
) -> void

Test that the valid_changed signal is emitted when validity state changes


test_visual_settings_update_on_validity_change

1
test_visual_settings_update_on_validity_change() -> void

Test that visual settings are properly updated when validity changes


test_force_validation_update

1
2
3
4
5
test_force_validation_update(
    rule_spec: Dictionary,
    expected_valid: bool,
    _test_parameters := [[ {"pass_on_collision": false, "mask": 1}, false]]
) -> void

Test that force_validation_update properly updates the indicator state


test_rules_added_after_ready

1
test_rules_added_after_ready() -> void

Test that indicators properly handle rules being added after _ready


test_rules_removed

1
test_rules_removed() -> void

Test that indicators properly handle rules being removed


test_ready_debug_log_format_no_rules

1
test_ready_debug_log_format_no_rules() -> void

Test improved debug log format when no rules present at _ready


test_per_frame_validation_env_flag

1
test_per_frame_validation_env_flag() -> void

Test per-frame evaluation toggled by environment variable


test_instance_collisions

1
2
3
4
5
test_instance_collisions(
    p_test_scene: PackedScene,
    p_expected_collisions: int,
    _test_parameters := [[offset_logo, 1]]
) -> void

Count the number of collisions when instancing a p_test_scene at the origin 0,0 and seeing if it matches the expected number


test__update_visuals

1
test__update_visuals() -> void

test_get_tile_position_default

1
test_get_tile_position_default() -> void

Test the default return of get_tile_positon


create_test_body

1
create_test_body() -> StaticBody2D

Creates a test collision body for testing rule validation

IMPORTANT POSITIONING NOTES:

  • The collision body is created at position (0, 0) by default
  • Tests MUST position the collision body to overlap with the indicator
  • Tests call: collision_body.global_position = indicator.global_position
  • This ensures the collision body and indicator are in the same location
  • Without proper positioning, collision detection will fail and tests will pass incorrectly

Example usage in tests: Example (GDScript): var collision_body = create_test_body() add_child(collision_body) collision_body.global_position = indicator.global_position # CRITICAL: Position for collision


find_first_physics_body

1
find_first_physics_body(root: Node) -> PhysicsBody2D

Helper: find the first PhysicsBody2D inside a scene root (or root itself)


Private Methods

_create_minimal_indicator

1
_create_minimal_indicator(collision_mask: int = test_layers) -> RuleCheckIndicator

Flags: private

Creates a minimal RuleCheckIndicator with shape and dependencies resolved.



Grid Building v5.0.8 | Generated 24/05/2026