@@ -39,6 +39,17 @@ class TextBlockAttributeTests: XCTestCase {
39
39
XCTAssertEqual ( textView. selectedRange, NSRange ( location: 8 , length: 0 ) )
40
40
}
41
41
42
+ func testDoubleTapOnTextBlock( ) {
43
+ let textView = RichTextView ( context: RichTextViewContext ( ) )
44
+ let text = NSMutableAttributedString ( string: " 01234 " , attributes: [ . textBlock: true ] )
45
+ textView. attributedText = text
46
+
47
+ textView. selectedRange = text. fullRange
48
+ let range = NSRange ( location: 0 , length: 1 ) . toTextRange ( textInput: textView)
49
+ textView. selectedTextRange = range
50
+ XCTAssertEqual ( textView. selectedRange, text. fullRange)
51
+ }
52
+
42
53
func testSetsFocusBeforeForNonFocusableText( ) {
43
54
let textView = RichTextView ( context: RichTextViewContext ( ) )
44
55
let text = NSMutableAttributedString ( string: " 0123 " )
@@ -147,7 +158,7 @@ class TextBlockAttributeTests: XCTestCase {
147
158
XCTAssertEqual ( range, NSRange ( location: 12 , length: 7 ) )
148
159
}
149
160
150
- func testUnselectsSelectedTextBlockForward ( ) {
161
+ func testRetainsSelectedTextBlockForward ( ) {
151
162
let textView = RichTextView ( context: RichTextViewContext ( ) )
152
163
let text = NSMutableAttributedString ( string: " This is test string " )
153
164
textView. attributedText = text
@@ -157,10 +168,10 @@ class TextBlockAttributeTests: XCTestCase {
157
168
textView. selectedTextRange = NSRange ( location: 9 , length: 3 ) . toTextRange ( textInput: textView) // "est"
158
169
let range = textView. selectedRange
159
170
160
- XCTAssertEqual ( range, NSRange ( location: 12 , length: 0 ) )
171
+ XCTAssertEqual ( range, NSRange ( location: 8 , length: 4 ) )
161
172
}
162
173
163
- func testUnselectsSelectedTextBlockReverse ( ) {
174
+ func testRetainsSelectedTextBlockReverse ( ) {
164
175
let textView = RichTextView ( context: RichTextViewContext ( ) )
165
176
let text = NSMutableAttributedString ( string: " This is test string " )
166
177
textView. attributedText = text
@@ -170,7 +181,7 @@ class TextBlockAttributeTests: XCTestCase {
170
181
textView. selectedTextRange = NSRange ( location: 8 , length: 3 ) . toTextRange ( textInput: textView) // "tes"
171
182
let range = textView. selectedRange
172
183
173
- XCTAssertEqual ( range, NSRange ( location: 8 , length: 0 ) )
184
+ XCTAssertEqual ( range, NSRange ( location: 8 , length: 4 ) )
174
185
}
175
186
176
187
func testUnselectsTextSelectedWithTextBlockReverse( ) {
0 commit comments