Add test coverage for the Unified Diff display - #2830
Merged
vogella merged 1 commit intoJul 29, 2026
Conversation
Contributor
vogella
force-pushed
the
unified-diff-test-coverage
branch
from
July 28, 2026 15:34
8072a45 to
12af42a
Compare
Extract the offset and line geometry helpers behind the unified diff code
minings into a new internal UnifiedDiffText class so they can be tested,
and cover them together with the diff modes in org.eclipse.team.tests.core.
Also fixes the line counting in UnifiedDiffLineHeaderCodeMining#draw, which
used String#split("\n") and therefore placed the detailed diff highlight one
line too high when a diff started at a line start.
vogella
force-pushed
the
unified-diff-test-coverage
branch
from
July 28, 2026 18:11
12af42a to
410530c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unified diff feature has roughly 190 lines of test code for about 3000 lines of implementation, and the trickiest parts (the offset and line geometry behind the code minings) were unreachable from a test because they lived as private helpers inside the SWT drawing code. This moves those pure functions into a new internal
UnifiedDiffTextclass and covers them, together with the diff modes, fromorg.eclipse.team.tests.core.The integration tests pin the contracts that actually matter:
REPLACE_MODEmust turn the document into the compared source, which is where the cumulative offset delta across several diffs is easy to get wrong; the overlay and revert modes must leave the document untouched; reopening must replace the previous diffs instead of stacking them; and closing the editor must clear the manager's static per-viewer map. On the unit side the merged style ranges are checked to tile the syntax colouring exactly, sinceStyledText#setStyleRangesthrows on overlapping ranges.One behaviour change comes along with the extraction. The two line counts in
UnifiedDiffLineHeaderCodeMining#drawusedString#split("\n"), which drops trailing empty strings, so a detailed diff starting exactly at a line start was highlighted one line too high. They now use the extractedcountLines.The tests run under the
ui-testtarget oftest.xmlviaAllTeamUITests, where both classes are registered.