Skip to content

Add ScreenScaler tests#109

Open
mors119 wants to merge 2 commits into
utilForever:mainfrom
mors119:feature/add-screen-scaler-test
Open

Add ScreenScaler tests#109
mors119 wants to merge 2 commits into
utilForever:mainfrom
mors119:feature/add-screen-scaler-test

Conversation

@mors119
Copy link
Copy Markdown

@mors119 mors119 commented May 27, 2026

What

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

This PR adds test coverage for:

  • glyph texture coordinate calculations
  • logical/physical resize handling
  • gutter distribution behavior
  • smooth resize calculations
  • available render area calculations
  • resize state tracking

Why

Resize and gutter calculations are relatively isolated but are easy to accidentally break during rendering or window-management refactors.

These tests help protect rendering coordinate behavior and make future resize-related changes safer and easier to validate.

Closes #108

Checklist

Required

  • cargo check --all passes
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions passes
  • cargo test --all passes
  • I linked the related issue (for example: Closes #123)

Functional Validation

  • Behavior related to this change was verified locally (if applicable)
  • Rendering/backend behavior was verified when runtime code changed (if applicable)
  • Algorithm behavior (pathfinding/FOV/noise/random) was verified when affected (if applicable)
  • I added or updated tests for changed behavior (if applicable)

Configuration & Docs

  • User-facing docs were updated (README.md, ARCHITECTURE.md, or relevant manual pages, if applicable)
  • New dependencies/configuration are documented (if applicable)
  • No sensitive values or credentials were introduced

If Applicable

  • Security impact considered (run cargo audit locally if needed)
  • Breaking behavior changes are clearly described in this PR

Summary by CodeRabbit

  • Bug Fixes

    • Improved smooth-resize behavior to prevent leftover gutter offsets during consecutive size changes.
  • Tests

    • Added comprehensive tests for scaling, glyph positioning, gutter splitting, coordinate mapping, smooth resizing, size-change handling, and reset behavior to ensure reliable display and resizing across configurations.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2479a974-c05e-4924-b5a2-485f7cc8904e

📥 Commits

Reviewing files that changed from the base of the PR and between e10e7b6 and cc4c7dc.

📒 Files selected for processing (1)
  • bracket-terminal/src/hal/scaler.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • bracket-terminal/src/hal/scaler.rs

📝 Walkthrough

Walkthrough

Adds a test module to scaler.rs, an f32 comparison helper, multiple unit tests for FontScaler::glyph_position and ScreenScaler gutter/size behaviors, and resets smooth_gutter_x/y to zero before recomputing in change_physical_size_smooth.

Changes

FontScaler and ScreenScaler test coverage

Layer / File(s) Summary
Test module infrastructure and assertion helper
bracket-terminal/src/hal/scaler.rs
#[cfg(test)] module and assert_f32_eq helper for stable f32 comparisons.
FontScaler glyph position tests
bracket-terminal/src/hal/scaler.rs
Tests validate FontScaler::glyph_position for glyph index 0 and index 16 (second row) texture coordinates.
ScreenScaler gutter distribution tests
bracket-terminal/src/hal/scaler.rs
Verifies even vs odd desired_gutter splits (left/right, top/bottom) and resulting available_width/available_height.
new_window_size & change_logical_size
bracket-terminal/src/hal/scaler.rs
new_window_size applies desired gutter to window size; change_logical_size updates physical size using scale and recomputes gutters.
change_physical_size & change_physical_size_smooth
bracket-terminal/src/hal/scaler.rs
change_physical_size updates dimensions; change_physical_size_smooth now zeroes smooth_gutter_x/smooth_gutter_y before recomputing and is tested for vertical gutter behavior and overwriting prior smooth values.
Resized flag, corner mapping, and step calc
bracket-terminal/src/hal/scaler.rs
Tests get_resized_and_reset resets resized; top_left_pixel/bottom_right_pixel map to (-1.0,-1.0)/(1.0,1.0); calc_step returns expected step sizes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I nibble at pixels and floaty delight,
I zero the gutters to make things just right,
From glyphs to corners the tests all agree,
Smooth resizing now hops true and free! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add ScreenScaler tests' clearly and directly summarizes the main change: adding unit tests to the ScreenScaler module.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mors119
Copy link
Copy Markdown
Author

mors119 commented May 27, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bracket-terminal/src/hal/scaler.rs`:
- Around line 372-380: The test smooth_resize_resets_previous_gutter_values
fails because ScreenScaler::change_physical_size_smooth only updates one axis'
gutter and never clears the other, leaving stale state (e.g., smooth_gutter_x)
from a prior call; modify change_physical_size_smooth to reset both
smooth_gutter_x and smooth_gutter_y (or at minimum clear the opposite axis)
before applying the new per-axis gutter values so previous smooth gutters cannot
persist across calls, ensuring the test (and the field smooth_gutter_x) is
cleared as expected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61518d10-f0d5-45d3-9985-45ad92a4a553

📥 Commits

Reviewing files that changed from the base of the PR and between fe7bf77 and e10e7b6.

📒 Files selected for processing (1)
  • bracket-terminal/src/hal/scaler.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format all Rust code using cargo fmt --all
Fix all cargo clippy warnings — the CI enforces -D warnings
Add tests for new functionality in the relevant module; for split domains, prefer colocated tests.rs

Files:

  • bracket-terminal/src/hal/scaler.rs
🔇 Additional comments (1)
bracket-terminal/src/hal/scaler.rs (1)

250-369: LGTM!

Also applies to: 382-415

Comment thread bracket-terminal/src/hal/scaler.rs Outdated
@mors119
Copy link
Copy Markdown
Author

mors119 commented May 27, 2026

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai rate limit to show your current review rate limit status.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
  • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
  • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai emit path instructions to emit generated path-specific review instructions for this repository.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@mors119
Copy link
Copy Markdown
Author

mors119 commented May 27, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ScreenScaler test coverage

1 participant