forked from CodeEditApp/CodeEditSourceEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisibleRangeProviderTests.swift
More file actions
58 lines (42 loc) · 1.86 KB
/
VisibleRangeProviderTests.swift
File metadata and controls
58 lines (42 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import XCTest
@testable import CodeEditSourceEditor
final class VisibleRangeProviderTests: XCTestCase {
@MainActor
func test_updateOnScroll() {
let (scrollView, textView) = Mock.scrollingTextView()
textView.string = Array(repeating: "\n", count: 400).joined()
textView.layout()
let rangeProvider = VisibleRangeProvider(textView: textView, minimapView: nil)
let originalSet = rangeProvider.visibleSet
scrollView.contentView.scroll(to: NSPoint(x: 0, y: 250))
scrollView.layoutSubtreeIfNeeded()
textView.layout()
XCTAssertNotEqual(originalSet, rangeProvider.visibleSet)
}
@MainActor
func test_updateOnResize() {
let (scrollView, textView) = Mock.scrollingTextView()
textView.string = Array(repeating: "\n", count: 400).joined()
textView.layout()
let rangeProvider = VisibleRangeProvider(textView: textView, minimapView: nil)
let originalSet = rangeProvider.visibleSet
scrollView.setFrameSize(NSSize(width: 250, height: 450))
scrollView.layoutSubtreeIfNeeded()
textView.layout()
XCTAssertNotEqual(originalSet, rangeProvider.visibleSet)
}
// Skipping due to a bug in the textview that returns all indices for the visible rect
// when not in a scroll view
@MainActor
func _test_updateOnResizeNoScrollView() {
let textView = Mock.textView()
textView.frame = NSRect(x: 0, y: 0, width: 100, height: 100)
textView.string = Array(repeating: "\n", count: 400).joined()
textView.layout()
let rangeProvider = VisibleRangeProvider(textView: textView, minimapView: nil)
let originalSet = rangeProvider.visibleSet
textView.setFrameSize(NSSize(width: 350, height: 450))
textView.layout()
XCTAssertNotEqual(originalSet, rangeProvider.visibleSet)
}
}