-
-
Notifications
You must be signed in to change notification settings - Fork 833
Fix LibreOffice braille scrolling #19204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1ccefec
Improve libre office
LeonarddeR 222f602
Fixup
LeonarddeR 985c408
Copyright
LeonarddeR 87a9e26
Handle deprecation
LeonarddeR be125e1
Changelog
LeonarddeR 8067cc8
Pre-commit auto-fix
pre-commit-ci[bot] 5070783
Update tests/unit/objectProvider.py
LeonarddeR ba5e1cd
Fix copyright headers
LeonarddeR 92baa92
More headers
LeonarddeR 7cf68d4
Fix typing
LeonarddeR 7b9e783
Merge remote-tracking branch 'origin/master' into libreFix
LeonarddeR 1627408
When movement past end is not allowed, ensure that movement ends at t…
LeonarddeR 34a9fc1
Use alternative approach
LeonarddeR 5a86c61
Expand tests
LeonarddeR b0bd48b
Apply suggestions from code review
LeonarddeR c1fe871
Add a changelog entry
LeonarddeR 7e5ddca
Merge remote-tracking branch 'origin/master' into libreFix
LeonarddeR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # A part of NonVisual Desktop Access (NVDA) | ||
|
LeonarddeR marked this conversation as resolved.
|
||
| # Copyright (C) 2025 NV Access Limited, Leonard de Ruijter | ||
| # This file may be used under the terms of the GNU General Public License, version 2 or later, as modified by the NVDA license. | ||
| # For full terms and any additional permissions, see the NVDA license file: https://github.com/nvaccess/nvda/blob/master/copying.txt | ||
|
|
||
| """Unit tests for the compoundDocuments module.""" | ||
|
|
||
| import unittest | ||
|
|
||
| import compoundDocuments | ||
| import controlTypes | ||
| import textInfos | ||
| from .objectProvider import PlaceholderNVDAObject | ||
| from .textProvider import BasicTextInfo, BasicTextProvider | ||
|
|
||
|
|
||
| class BasicCompoundTextLeafTextInfo(BasicTextInfo, compoundDocuments.CompoundTextLeafTextInfo): ... | ||
|
|
||
|
|
||
| class BasicCompoundTextLeaf(BasicTextProvider): | ||
| TextInfo = BasicCompoundTextLeafTextInfo | ||
| windowHandle = 0 | ||
| states = {controlTypes.State.FOCUSABLE} | ||
| flowsFrom = None | ||
| flowsTo = None | ||
|
|
||
|
|
||
| class CompoundTreePlaceholderObject(PlaceholderNVDAObject): | ||
| """A placeholder NVDAObject for testing CompoundTextInfo implementations. | ||
| This class represents a tree structure of text providers. | ||
| Note that it also mutates the text providers to link them in a flow.""" | ||
|
|
||
| def __init__(self, objs: list[BasicCompoundTextLeaf], **kwargs): | ||
| super().__init__(**kwargs) | ||
| assert len(objs) > 0, "At least one text provider must be provided" | ||
| self.children = objs | ||
| self.firstChild = objs[0] | ||
| self.lastChild = objs[-1] | ||
| lastProcessedObj = None | ||
| for obj in objs: | ||
| if lastProcessedObj is not None: | ||
| lastProcessedObj.flowsTo = obj | ||
| obj.flowsFrom = lastProcessedObj | ||
| lastProcessedObj = obj | ||
|
|
||
|
|
||
| class TestTreeCompoundTextInfo(unittest.TestCase): | ||
| """Tests for the TreeCompoundTextInfo class.""" | ||
|
|
||
| def setUp(self) -> None: | ||
| objs = [ | ||
| BasicCompoundTextLeaf(text="one\r\n"), | ||
| BasicCompoundTextLeaf(text="two\r\n"), | ||
| BasicCompoundTextLeaf(text="three"), | ||
| ] | ||
| self.objs = objs | ||
| self.rootObj = CompoundTreePlaceholderObject(objs=objs) | ||
| self.document = compoundDocuments.CompoundDocument(self.rootObj) | ||
| self.fullText = "one\r\ntwo\r\nthree" | ||
|
|
||
| def test_innerInfos(self): | ||
| """Test that the text infos are created correctly.""" | ||
| info: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_ALL) | ||
| innerInfos = list(info._getTextInfos()) | ||
| self.assertEqual(len(innerInfos), 3) | ||
| for obj, info in zip(self.objs, innerInfos): | ||
| self.assertEqual(obj, info.obj) | ||
|
|
||
| def test_text(self): | ||
| """Test that the combined text is correct.""" | ||
| info: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_ALL) | ||
| self.assertEqual(info.text, self.fullText) | ||
|
|
||
| def test_characterMovement(self): | ||
| """Test character movement across the compound text info.""" | ||
| info: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_FIRST) | ||
| expected = [*"one\r\n", "", *"two\r\n", "", *"three"] | ||
| for i in range(len(expected) + 1): | ||
| c = expected[i] if i < len(expected) else "" | ||
| with self.subTest(i=i, c=c): | ||
| info.collapse() | ||
| movement = min(i, 1) | ||
| self.assertEqual(info.move(textInfos.UNIT_CHARACTER, movement), movement) | ||
| info.expand(textInfos.UNIT_CHARACTER) | ||
| self.assertEqual(info.text, c) | ||
| last: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_LAST) | ||
| # Allow moving past end | ||
| self.assertGreater(info.compareEndPoints(last, "endToEnd"), 0) | ||
|
|
||
| def test_wordMovement(self): | ||
| """Test word movement across the compound text info.""" | ||
| info: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_FIRST) | ||
| expected = ["one\r\n", "", "two\r\n", "", "three"] | ||
| for i in range(len(expected) + 1): | ||
| w = expected[i] if i < len(expected) else "" | ||
| with self.subTest(i=i, w=w): | ||
| info.collapse() | ||
| movement = min(i, 1) | ||
| self.assertEqual(info.move(textInfos.UNIT_WORD, movement), movement) | ||
| info.expand(textInfos.UNIT_WORD) | ||
| self.assertEqual(info.text, w) | ||
| last: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_LAST) | ||
| # Allow moving past end | ||
| self.assertGreater(info.compareEndPoints(last, "endToEnd"), 0) | ||
|
|
||
| def test_lineMovement(self): | ||
| """Test line movement across the compound text info.""" | ||
| info: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_FIRST) | ||
| expected = ["one\r\n", "two\r\n", "three"] | ||
| for i in range(len(expected) + 1): | ||
| if i < len(expected): | ||
| line = expected[i] | ||
|
seanbudd marked this conversation as resolved.
|
||
| with self.subTest(i=i, line=line): | ||
| info.collapse() | ||
| movement = min(i, 1) | ||
| self.assertEqual(info.move(textInfos.UNIT_LINE, movement), movement) | ||
| info.expand(textInfos.UNIT_LINE) | ||
| self.assertEqual(info.text, line) | ||
| last: compoundDocuments.TreeCompoundTextInfo = self.document.makeTextInfo(textInfos.POSITION_LAST) | ||
| # Allow moving past end | ||
| self.assertGreater(info.compareEndPoints(last, "endToEnd"), 0) | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.