Skip to content

Improve ScreenScaler test coverage #108

@mors119

Description

@mors119

Summary

Add focused regression tests for ScreenScaler and FontScaler resize-related calculations.

Problem to solve

ScreenScaler contains several pieces of rendering-related coordinate and resize logic:

  • logical ↔ physical size conversion
  • gutter distribution
  • smooth resize calculations
  • aspect ratio preservation
  • available render area calculations

These calculations are easy to accidentally break during future rendering or resize refactors.

Currently, there is limited protection against graphical regressions caused by small coordinate or sizing changes.

This affects:

  • maintainers refactoring resize or window handling logic
  • contributors modifying rendering calculations
  • downstream rendering behavior that depends on stable gutter and scaling rules

Proposed solution

Add targeted unit tests for the following behaviors:

  • FontScaler::glyph_position

    • validate glyph texture coordinate calculations
  • ScreenScaler::new_window_size

    • verify gutter-adjusted window sizing behavior
  • change_logical_size

    • verify logical → physical size scaling
  • change_physical_size

    • verify resize recalculation behavior
  • change_physical_size_smooth

    • verify smooth gutter calculations and aspect ratio preservation
  • gutter distribution behavior

    • validate even gutter splitting
    • validate odd gutter remainder distribution
  • available render size calculations

    • verify available_width and available_height
  • aspect ratio behavior

    • verify resize logic preserves intended render proportions

Alternatives considered

Rely on manual graphical verification during resize-related changes.

This avoids additional test code, but makes regressions harder to detect and increases the risk of subtle rendering bugs.

Add higher-level rendering integration tests.

This could provide broader coverage, but would be more complex and less deterministic than focused unit tests for coordinate calculations.

Additional context

ScreenScaler is relatively isolated from the rest of the rendering pipeline, making it a good target for stable regression tests.

Strengthening coverage here would make future resize and rendering refactors safer and easier to reason about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions