Skip to content

Commit d692ca6

Browse files
committed
Tests Compile, Still Need To Fix Overridden Heights
1 parent 2ef1f12 commit d692ca6

File tree

4 files changed

+70
-45
lines changed

4 files changed

+70
-45
lines changed

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManager+Layout.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ extension TextLayoutManager {
179179
range: position.range,
180180
stringRef: textStorage,
181181
markedRanges: markedTextManager.markedRanges(in: position.range),
182-
breakStrategy: lineBreakStrategy,
183182
attachments: attachments.get(startingIn: position.range)
184183
)
185184
} else {

Sources/CodeEditTextView/TextLayoutManager/TextLayoutManagerRenderDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public protocol TextLayoutManagerRenderDelegate: AnyObject {
1818
range: NSRange,
1919
stringRef: NSTextStorage,
2020
markedRanges: MarkedRanges?,
21-
breakStrategy: LineBreakStrategy,
2221
attachments: [TextAttachmentBox]
2322
)
2423

@@ -36,7 +35,6 @@ public extension TextLayoutManagerRenderDelegate {
3635
range: NSRange,
3736
stringRef: NSTextStorage,
3837
markedRanges: MarkedRanges?,
39-
breakStrategy: LineBreakStrategy,
4038
attachments: [TextAttachmentBox]
4139
) {
4240
textLine.prepareForDisplay(

Tests/CodeEditTextViewTests/LayoutManager/OverridingLayoutManagerRenderingTests.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ class MockRenderDelegate: TextLayoutManagerRenderDelegate {
88
_ displayData: TextLine.DisplayData,
99
_ range: NSRange,
1010
_ stringRef: NSTextStorage,
11-
_ markedRanges: MarkedRanges?,
12-
_ breakStrategy: LineBreakStrategy
11+
_ markedRanges: MarkedRanges?
1312
) -> Void)?
1413

1514
var estimatedLineHeightOverride: (() -> CGFloat)?
@@ -19,22 +18,19 @@ class MockRenderDelegate: TextLayoutManagerRenderDelegate {
1918
displayData: TextLine.DisplayData,
2019
range: NSRange,
2120
stringRef: NSTextStorage,
22-
markedRanges: MarkedRanges?,
23-
breakStrategy: LineBreakStrategy
21+
markedRanges: MarkedRanges?
2422
) {
2523
prepareForDisplay?(
2624
textLine,
2725
displayData,
2826
range,
2927
stringRef,
30-
markedRanges,
31-
breakStrategy
28+
markedRanges
3229
) ?? textLine.prepareForDisplay(
3330
displayData: displayData,
3431
range: range,
3532
stringRef: stringRef,
3633
markedRanges: markedRanges,
37-
breakStrategy: breakStrategy,
3834
attachments: []
3935
)
4036
}
@@ -63,13 +59,12 @@ struct OverridingLayoutManagerRenderingTests {
6359

6460
@Test
6561
func overriddenLineHeight() {
66-
mockDelegate.prepareForDisplay = { textLine, displayData, range, stringRef, markedRanges, breakStrategy in
62+
mockDelegate.prepareForDisplay = { textLine, displayData, range, stringRef, markedRanges in
6763
textLine.prepareForDisplay(
6864
displayData: displayData,
6965
range: range,
7066
stringRef: stringRef,
7167
markedRanges: markedRanges,
72-
breakStrategy: breakStrategy,
7368
attachments: []
7469
)
7570
// Update all text fragments to be height = 2.0

Tests/CodeEditTextViewTests/TypesetterTests.swift

Lines changed: 66 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ final class DemoTextAttachment: TextAttachment {
1919
class TypesetterTests: XCTestCase {
2020
// NOTE: makes chars that are ~6.18 pts wide
2121
let attributes: [NSAttributedString.Key: Any] = [.font: NSFont.monospacedSystemFont(ofSize: 10, weight: .regular)]
22-
let limitedLineWidthDisplayData = TextLine.DisplayData(
23-
maxWidth: 150,
24-
lineHeightMultiplier: 1.0,
25-
estimatedLineHeight: 20.0
26-
)
27-
let unlimitedLineWidthDisplayData = TextLine.DisplayData(
28-
maxWidth: .infinity,
29-
lineHeightMultiplier: 1.0,
30-
estimatedLineHeight: 20.0
31-
)
32-
3322
var typesetter: Typesetter!
3423

3524
override func setUp() {
@@ -41,8 +30,12 @@ class TypesetterTests: XCTestCase {
4130
typesetter.typeset(
4231
NSAttributedString(string: "testline\n"),
4332
documentRange: NSRange(location: 0, length: 9),
44-
displayData: unlimitedLineWidthDisplayData,
45-
breakStrategy: .word,
33+
displayData: TextLine.DisplayData(
34+
maxWidth: .infinity,
35+
lineHeightMultiplier: 1.0,
36+
estimatedLineHeight: 20.0,
37+
breakStrategy: .word
38+
),
4639
markedRanges: nil
4740
)
4841

@@ -51,8 +44,12 @@ class TypesetterTests: XCTestCase {
5144
typesetter.typeset(
5245
NSAttributedString(string: "testline\n"),
5346
documentRange: NSRange(location: 0, length: 9),
54-
displayData: unlimitedLineWidthDisplayData,
55-
breakStrategy: .character,
47+
displayData: TextLine.DisplayData(
48+
maxWidth: .infinity,
49+
lineHeightMultiplier: 1.0,
50+
estimatedLineHeight: 20.0,
51+
breakStrategy: .character
52+
),
5653
markedRanges: nil
5754
)
5855

@@ -63,8 +60,12 @@ class TypesetterTests: XCTestCase {
6360
typesetter.typeset(
6461
NSAttributedString(string: "testline\r"),
6562
documentRange: NSRange(location: 0, length: 9),
66-
displayData: unlimitedLineWidthDisplayData,
67-
breakStrategy: .word,
63+
displayData: TextLine.DisplayData(
64+
maxWidth: .infinity,
65+
lineHeightMultiplier: 1.0,
66+
estimatedLineHeight: 20.0,
67+
breakStrategy: .word
68+
),
6869
markedRanges: nil
6970
)
7071

@@ -73,8 +74,12 @@ class TypesetterTests: XCTestCase {
7374
typesetter.typeset(
7475
NSAttributedString(string: "testline\r"),
7576
documentRange: NSRange(location: 0, length: 9),
76-
displayData: unlimitedLineWidthDisplayData,
77-
breakStrategy: .character,
77+
displayData: TextLine.DisplayData(
78+
maxWidth: .infinity,
79+
lineHeightMultiplier: 1.0,
80+
estimatedLineHeight: 20.0,
81+
breakStrategy: .character
82+
),
7883
markedRanges: nil
7984
)
8085

@@ -85,8 +90,12 @@ class TypesetterTests: XCTestCase {
8590
typesetter.typeset(
8691
NSAttributedString(string: "testline\r\n"),
8792
documentRange: NSRange(location: 0, length: 10),
88-
displayData: unlimitedLineWidthDisplayData,
89-
breakStrategy: .word,
93+
displayData: TextLine.DisplayData(
94+
maxWidth: .infinity,
95+
lineHeightMultiplier: 1.0,
96+
estimatedLineHeight: 20.0,
97+
breakStrategy: .word
98+
),
9099
markedRanges: nil
91100
)
92101

@@ -95,8 +104,12 @@ class TypesetterTests: XCTestCase {
95104
typesetter.typeset(
96105
NSAttributedString(string: "testline\r\n"),
97106
documentRange: NSRange(location: 0, length: 10),
98-
displayData: unlimitedLineWidthDisplayData,
99-
breakStrategy: .character,
107+
displayData: TextLine.DisplayData(
108+
maxWidth: .infinity,
109+
lineHeightMultiplier: 1.0,
110+
estimatedLineHeight: 20.0,
111+
breakStrategy: .character
112+
),
100113
markedRanges: nil
101114
)
102115

@@ -108,8 +121,12 @@ class TypesetterTests: XCTestCase {
108121
typesetter.typeset(
109122
NSAttributedString(string: String(repeating: "A", count: 1000), attributes: attributes),
110123
documentRange: NSRange(location: 0, length: 1000),
111-
displayData: limitedLineWidthDisplayData, // 150 px
112-
breakStrategy: .character,
124+
displayData: TextLine.DisplayData(
125+
maxWidth: 150,
126+
lineHeightMultiplier: 1.0,
127+
estimatedLineHeight: 20.0,
128+
breakStrategy: .character
129+
),
113130
markedRanges: nil,
114131
attachments: []
115132
)
@@ -132,8 +149,12 @@ class TypesetterTests: XCTestCase {
132149
typesetter.typeset(
133150
NSAttributedString(string: "ABC"),
134151
documentRange: NSRange(location: 0, length: 3),
135-
displayData: unlimitedLineWidthDisplayData,
136-
breakStrategy: .character,
152+
displayData: TextLine.DisplayData(
153+
maxWidth: .infinity,
154+
lineHeightMultiplier: 1.0,
155+
estimatedLineHeight: 20.0,
156+
breakStrategy: .character
157+
),
137158
markedRanges: nil,
138159
attachments: [TextAttachmentBox(range: NSRange(location: 1, length: 1), attachment: attachment)]
139160
)
@@ -158,8 +179,12 @@ class TypesetterTests: XCTestCase {
158179
typesetter.typeset(
159180
NSAttributedString(string: "ABC"),
160181
documentRange: NSRange(location: 0, length: 3),
161-
displayData: unlimitedLineWidthDisplayData,
162-
breakStrategy: .character,
182+
displayData: TextLine.DisplayData(
183+
maxWidth: .infinity,
184+
lineHeightMultiplier: 1.0,
185+
estimatedLineHeight: 20.0,
186+
breakStrategy: .character
187+
),
163188
markedRanges: nil,
164189
attachments: [TextAttachmentBox(range: NSRange(location: 0, length: 3), attachment: attachment)]
165190
)
@@ -184,8 +209,12 @@ class TypesetterTests: XCTestCase {
184209
typesetter.typeset(
185210
NSAttributedString(string: "ABC123", attributes: attributes),
186211
documentRange: NSRange(location: 0, length: 6),
187-
displayData: limitedLineWidthDisplayData, // 150 px
188-
breakStrategy: .character,
212+
displayData: TextLine.DisplayData(
213+
maxWidth: 150,
214+
lineHeightMultiplier: 1.0,
215+
estimatedLineHeight: 20.0,
216+
breakStrategy: .character
217+
),
189218
markedRanges: nil,
190219
attachments: [.init(range: NSRange(location: 1, length: 1), attachment: attachment)]
191220
)
@@ -211,8 +240,12 @@ class TypesetterTests: XCTestCase {
211240
typesetter.typeset(
212241
NSAttributedString(string: "ABC123", attributes: attributes),
213242
documentRange: NSRange(location: 0, length: 6),
214-
displayData: limitedLineWidthDisplayData, // 150 px
215-
breakStrategy: .character,
243+
displayData: TextLine.DisplayData(
244+
maxWidth: 150,
245+
lineHeightMultiplier: 1.0,
246+
estimatedLineHeight: 20.0,
247+
breakStrategy: .character
248+
),
216249
markedRanges: nil,
217250
attachments: [.init(range: NSRange(location: 1, length: 1), attachment: attachment)]
218251
)

0 commit comments

Comments
 (0)