Skip to content

Improve unit test coverage from master - #221

Merged
fernandotonon merged 2 commits into
masterfrom
codex/coverage-over-80
Mar 26, 2026
Merged

Improve unit test coverage from master#221
fernandotonon merged 2 commits into
masterfrom
codex/coverage-over-80

Conversation

@fernandotonon

@fernandotonon fernandotonon commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Summary:

  • add the stabilized PropertiesPanelController and ThemeManager coverage work from the earlier coverage branch
  • fix the related UnitTests build and test stability issues needed for CI
  • add more MaterialComboDelegate coverage for editor signaling and material-column behavior

Verification:

  • built UnitTests locally with QT_QPA_PLATFORM=offscreen
  • full local execution is limited by Ogre and Mesa sandbox access, so GitHub CI is the authoritative run for these suites

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for material dropdown delegate functionality, including editor initialization, signal handling, model data persistence, and style option validation.

@coderabbitai

coderabbitai Bot commented Mar 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@fernandotonon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b85c3d25-8ced-4da0-aa88-3ea11e342cf4

📥 Commits

Reviewing files that changed from the base of the PR and between a6627e0 and 9d5b2ac.

📒 Files selected for processing (2)
  • src/MaterialPresetLibrary_test.cpp
  • src/SceneTreeModel_test.cpp
📝 Walkthrough

Walkthrough

Three new test cases were added to MaterialComboDelegate_test.cpp to verify editor creation, model data writing, and style option initialization. Tests validate that the delegate creates non-editable, frameless combo boxes, correctly signals on data changes, and manages display text appropriately.

Changes

Cohort / File(s) Summary
Test Coverage Expansion
src/MaterialComboDelegate_test.cpp
Added three test cases: editor creation with signal wiring validation via QSignalSpy, model data persistence verification, and style option initialization checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Three tests were born, both small and true,
To check that combo boxes work as they do,
No frames, no edits, just signals that shine,
The delegate now dances along every line!

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description deviates from the required template structure with no Features or Bugfixes sections; it uses custom formatting instead. Restructure the description to follow the template exactly, including Summary, Technical Details, Features, and Bugfixes sections with proper formatting.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Improve unit test coverage from master' is generic and lacks specificity about the key changes. Provide a more specific title that highlights the main focus, such as 'Add MaterialComboDelegate and PropertiesPanelController test coverage' or 'Increase unit test coverage for MaterialComboDelegate and ThemeManager'.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/coverage-over-80

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.

@fernandotonon
fernandotonon force-pushed the codex/coverage-over-80 branch from fe6d94d to a6627e0 Compare March 26, 2026 06:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/PropertiesPanelController_test.cpp (1)

174-176: Consider documenting the large rotation tolerance.

The 20-degree tolerance for Euler angle verification is significant. While the comment explains quaternion round-trip instability, it would help future maintainers to understand if this is a known limitation or if tighter bounds could be achieved.

📝 Optional: Add more context to the comment
-    // TransformOperator exposes Euler angles derived from Ogre quaternions.
-    // The round-trip is not stable enough here for tight per-axis equality.
+    // TransformOperator exposes Euler angles derived from Ogre quaternions.
+    // The round-trip is not stable due to gimbal lock and quaternion-to-Euler
+    // ambiguity near certain orientations. A 20° tolerance accommodates this.
     EXPECT_NEAR(controller->rotX(), 15.0f, 20.0f);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/PropertiesPanelController_test.cpp` around lines 174 - 176, Document the
large 20-degree tolerance used in the Euler angle assertions
(EXPECT_NEAR(controller->rotX(), 15.0f, 20.0f), EXPECT_NEAR(controller->rotY(),
25.0f, 20.0f), EXPECT_NEAR(controller->rotZ(), 35.0f, 20.0f)) by adding a
concise comment above these lines that explains this is an accepted/known
limitation due to quaternion↔Euler round-trip instability (and whether it is
expected to be fixed later or is an inherent limitation), and optionally note
that tighter bounds may be possible if tests change to compare quaternions
directly or use a canonicalization step.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/MaterialComboDelegate_test.cpp`:
- Around line 149-152: The test is flaky when comboBox->count() == 1 because
setCurrentIndex(0) won't change the index and won't emit signals; modify the
test to force an actual index change: if comboBox->count() > 1 call
comboBox->setCurrentIndex(1) as before, otherwise insert a temporary item with
comboBox->insertItem(0, "tmp"), call comboBox->setCurrentIndex(1) to trigger
currentIndexChanged, then remove the temporary item with
comboBox->removeItem(0); keep assertions on commitSpy.count() and
closeSpy.count() unchanged.

---

Nitpick comments:
In `@src/PropertiesPanelController_test.cpp`:
- Around line 174-176: Document the large 20-degree tolerance used in the Euler
angle assertions (EXPECT_NEAR(controller->rotX(), 15.0f, 20.0f),
EXPECT_NEAR(controller->rotY(), 25.0f, 20.0f), EXPECT_NEAR(controller->rotZ(),
35.0f, 20.0f)) by adding a concise comment above these lines that explains this
is an accepted/known limitation due to quaternion↔Euler round-trip instability
(and whether it is expected to be fixed later or is an inherent limitation), and
optionally note that tighter bounds may be possible if tests change to compare
quaternions directly or use a canonicalization step.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa994681-4e01-4849-8fb1-92d7217a0b54

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5aee8 and fe6d94d.

📒 Files selected for processing (6)
  • CMakeLists.txt
  • src/EditorViewport.cpp
  • src/MaterialComboDelegate_test.cpp
  • src/PropertiesPanelController_test.cpp
  • src/ThemeManager_test.cpp
  • tests/CMakeLists.txt

Comment on lines +149 to +152
comboBox->setCurrentIndex(comboBox->count() > 1 ? 1 : 0);

EXPECT_EQ(commitSpy.count(), 1);
EXPECT_EQ(closeSpy.count(), 1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential flaky test when combo has only one material.

If comboBox->count() is 1, line 149 evaluates to setCurrentIndex(0). Since QComboBox initializes with currentIndex of 0 when items exist, this won't trigger currentIndexChanged, causing the assertions on lines 151-152 to fail.

🔧 Proposed fix to ensure index change
-    comboBox->setCurrentIndex(comboBox->count() > 1 ? 1 : 0);
+    ASSERT_GE(comboBox->count(), 2) << "Need at least 2 materials for signal test";
+    comboBox->setCurrentIndex(1);

Alternatively, if you want to handle single-material scenarios:

+    if (comboBox->count() < 2) {
+        GTEST_SKIP() << "Skipping signal test: need at least 2 materials";
+    }
     comboBox->setCurrentIndex(1);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
comboBox->setCurrentIndex(comboBox->count() > 1 ? 1 : 0);
EXPECT_EQ(commitSpy.count(), 1);
EXPECT_EQ(closeSpy.count(), 1);
ASSERT_GE(comboBox->count(), 2) << "Need at least 2 materials for signal test";
comboBox->setCurrentIndex(1);
EXPECT_EQ(commitSpy.count(), 1);
EXPECT_EQ(closeSpy.count(), 1);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/MaterialComboDelegate_test.cpp` around lines 149 - 152, The test is flaky
when comboBox->count() == 1 because setCurrentIndex(0) won't change the index
and won't emit signals; modify the test to force an actual index change: if
comboBox->count() > 1 call comboBox->setCurrentIndex(1) as before, otherwise
insert a temporary item with comboBox->insertItem(0, "tmp"), call
comboBox->setCurrentIndex(1) to trigger currentIndexChanged, then remove the
temporary item with comboBox->removeItem(0); keep assertions on
commitSpy.count() and closeSpy.count() unchanged.

@sonarqubecloud

Copy link
Copy Markdown

@fernandotonon
fernandotonon merged commit bf78c18 into master Mar 26, 2026
18 checks passed
@fernandotonon
fernandotonon deleted the codex/coverage-over-80 branch March 26, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant