fix(test): adapt night mode tests to async NightFilter refactor - #379
Conversation
BrowserPage::applyNightMode was removed in the night mode refactoring (async EyeProtectionManager + NightFilter + background thread). Update tests to match the new API: 1. ut_browserpage.cpp: UT_BrowserPage_applyNightMode_001 — rewrite to test NightFilter::apply() pure filter logic directly (null input, white→dark inversion, dark→white boost) instead of the removed synchronous applyNightMode method. 2. ut_pagerenderthread.cpp: onDocPageNormalImageTaskFinished_002 and onDocPageBigImageTaskFinished_002 — add setImageObjectRects stub. The refactoring added task.page->setImageObjectRects() before handleRenderFinished() in these slots; without the stub, nullptr task.page caused a segfault that prevented the full suite from completing and coverage from being generated. No production code changes. All 1120 tests pass (0 failures).
Reviewer's GuideThe test suite was adapted to the async NightFilter-based night-mode implementation by replacing calls to the removed BrowserPage API with pure filter assertions and stubbing the new page callback in render-thread tests. No production code changed; all 1,120 tests pass with reported line coverage of 83.80% and function coverage of 98.50%. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/browser/ut_browserpage.cpp" line_range="854-856" />
<code_context>
+ QImage nightImg = NightFilter::apply(whiteImg);
+ EXPECT_FALSE(nightImg.isNull());
+ QRgb pixel = nightImg.pixel(0, 0);
+ EXPECT_LT(qRed(pixel), 128);
+ EXPECT_LT(qGreen(pixel), 128);
+ EXPECT_LT(qBlue(pixel), 128);
+
+ // 深色像素(boostSourceBelow 以下)反色后应提纯白
</code_context>
<issue_to_address>
**nitpick (testing):** The white-image assertions only require each RGB channel to be below 128, so an incorrect implementation that turns white pixels completely black still passes even though the documented filter clamps the inverted lightness to a non-black minimum.
**Triggers:** When the filter regresses to producing black output for white input.
**Suggested fix:** Assert the expected dark-gray range or exact/reference pixel values, including the alpha channel, rather than only checking that the channels are below 128.
</issue_to_address>| EXPECT_LT(qRed(pixel), 128); | ||
| EXPECT_LT(qGreen(pixel), 128); | ||
| EXPECT_LT(qBlue(pixel), 128); |
There was a problem hiding this comment.
nitpick (testing): The white-image assertions only require each RGB channel to be below 128, so an incorrect implementation that turns white pixels completely black still passes even though the documented filter clamps the inverted lightness to a non-black minimum.
Triggers: When the filter regresses to producing black output for white input.
Suggested fix: Assert the expected dark-gray range or exact/reference pixel values, including the alpha channel, rather than only checking that the channels are below 128.
|
/merge |
Summary
Night mode was refactored to an async implementation (
EyeProtectionManager+NightFilter+ background thread), removingBrowserPage::applyNightMode. The existing tests still called the removed API, causing compile failure and preventing the entire test suite from running.Changes
tests/browser/ut_browserpage.cpp—UT_BrowserPage_applyNightMode_001:NightFilter::apply()pure filter logic directly (null input → null output; white image → dark inverted output; dark image → boosted white) instead of the removed synchronousapplyNightModemethod.tests/browser/ut_pagerenderthread.cpp—onDocPageNormalImageTaskFinished_002/onDocPageBigImageTaskFinished_002:setImageObjectRectsstub. The refactoring insertedtask.page->setImageObjectRects()beforehandleRenderFinished()in these slots; without the stub, the nulltask.pagecaused a segfault that killed the test process, preventing.gcdacoverage generation.Test Results
No production code changes.
Summary by Sourcery
Update unit tests for the asynchronous night-mode refactor and stabilize page-render completion test fixtures.
Bug Fixes:
Tests: