diff --git a/Proton.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Proton.xcworkspace/xcshareddata/swiftpm/Package.resolved index eb9b3e29..d8e292dd 100644 --- a/Proton.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Proton.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -2,12 +2,21 @@ "object": { "pins": [ { - "package": "SnapshotTesting", + "package": "swift-snapshot-testing", "repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing.git", "state": { "branch": null, - "revision": "114882386a815f4a2e6d8f2f7ee4857acd372438", - "version": "1.7.2" + "revision": "42a086182681cf661f5c47c9b7dc3931de18c6d7", + "version": "1.17.6" + } + }, + { + "package": "swift-syntax", + "repositoryURL": "https://github.com/swiftlang/swift-syntax", + "state": { + "branch": null, + "revision": "0687f71944021d616d34d922343dcef086855920", + "version": "600.0.1" } } ] diff --git a/Proton/Sources/ObjC/PRTextStorage.m b/Proton/Sources/ObjC/PRTextStorage.m index 4a14f55e..1a4d3952 100644 --- a/Proton/Sources/ObjC/PRTextStorage.m +++ b/Proton/Sources/ObjC/PRTextStorage.m @@ -168,7 +168,7 @@ - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str { NSInteger delta = str.length - range.length; [_storage replaceCharactersInRange:range withString:str]; [_storage fixAttributesInRange:NSMakeRange(0, _storage.length)]; - [self edited:NSTextStorageEditedCharacters & NSTextStorageEditedAttributes range:range changeInLength:delta]; + [self edited:NSTextStorageEditedCharacters | NSTextStorageEditedAttributes range:range changeInLength:delta]; [self endEditing]; } diff --git a/Proton/Sources/Swift/Core/RichTextView.swift b/Proton/Sources/Swift/Core/RichTextView.swift index 233688c4..b5503dde 100644 --- a/Proton/Sources/Swift/Core/RichTextView.swift +++ b/Proton/Sources/Swift/Core/RichTextView.swift @@ -205,6 +205,15 @@ class RichTextView: AutogrowingTextView { draw(CGRect(origin: .zero, size: contentSize)) } + override func becomeFirstResponder() -> Bool { + let didBecomeFirstResponder = super.becomeFirstResponder() + if didBecomeFirstResponder { + context?.selectedTextView = self + context?.activeTextView = self + } + return didBecomeFirstResponder + } + func updateSelectedRangeIgnoringCallback(_ selectedRange: NSRange) { ignoreSelectedRangeChangeCallback = true self.selectedRange = selectedRange diff --git a/Proton/Sources/Swift/Editor/EditorView.swift b/Proton/Sources/Swift/Editor/EditorView.swift index 44a3fd49..9cb44e8e 100644 --- a/Proton/Sources/Swift/Editor/EditorView.swift +++ b/Proton/Sources/Swift/Editor/EditorView.swift @@ -150,12 +150,6 @@ open class EditorView: UIView { } } - - // Holds `attributedText` until Editor move to a window - // Setting attributed text without Editor being fully ready - // causes issues with cached bounds that shows up when rotating the device. - private var pendingAttributedText: NSAttributedString? - var editorContextDelegate: EditorViewDelegate? { get { editorViewContext.delegate } } @@ -172,12 +166,6 @@ open class EditorView: UIView { /// Context for the current Editor public let editorViewContext: EditorViewContext - /// Returns if `attributedText` change is pending. `AttributedText` may not have been applied if the `EditorView` is not already on - /// `window` and `forceApplyAttributedText` is not set to `true`. - public var isAttributedTextPending: Bool { - pendingAttributedText != nil - } - /// Enables asynchronous rendering of attachments. /// - Note: /// Since attachments must me rendered on main thread, the rendering only continues when there is no user interaction. By default, rendering starts @@ -419,7 +407,6 @@ open class EditorView: UIView { /// An attachment is only counted as a single character. Content length does not include /// length of content within the Attachment that is hosting another `EditorView`. public var contentLength: Int { - guard pendingAttributedText == nil else { return attributedText.length } return richTextView.contentLength } @@ -539,26 +526,12 @@ open class EditorView: UIView { } } - /// Forces setting attributed text in `EditorView` even if it is not - /// yet in view hierarchy. - /// - Note: This may result in misplaced `Attachment`s and is recommended to be set to `true` only in unit tests. - public var forceApplyAttributedText = false - /// Text to be set in the `EditorView` - /// - Important: `attributedText` is not set for rendering in `EditorView` if the `EditorView` is not already in a `Window`. Value of `true` - /// for `isAttributedTextPending` confirms that the text has not yet been rendered even though it is set in the `EditorView`. - /// Notification of text being set can be observed by subscribing to `didSetAttributedText` in `EditorViewDelegate`. - /// Alternatively, `forceApplyAttributedText` may be set to `true` to always apply `attributedText` irrespective of `EditorView` being - /// in a `Window` or not. public var attributedText: NSAttributedString { get { - pendingAttributedText ?? richTextView.attributedText + richTextView.attributedText } set { - if forceApplyAttributedText == false && window == nil { - pendingAttributedText = newValue - return - } isSettingAttributedText = true attachmentRenderingScheduler.cancel() renderedViewport = nil @@ -566,8 +539,7 @@ open class EditorView: UIView { // editor is hosted in a scrollable container and content is set multiple times. richTextView.attributedText = NSAttributedString() - let isDeferred = pendingAttributedText != nil - pendingAttributedText = nil + let isDeferred = false AggregateEditorViewDelegate.editor(self, willSetAttributedText: newValue, isDeferred: isDeferred) @@ -872,9 +844,6 @@ open class EditorView: UIView { /// - IMPORTANT: Overriding implementations must call `super.didMoveToWindow()` open override func didMoveToWindow() { super.didMoveToWindow() - if let pendingAttributedText { - attributedText = pendingAttributedText - } let isReady = window != nil AggregateEditorViewDelegate.editor(self, isReady: isReady) } @@ -1144,7 +1113,7 @@ open class EditorView: UIView { if let range { selectedRange = range } - richTextView.becomeFirstResponder() + _ = richTextView.becomeFirstResponder() } /// Makes the `EditorView` lose focus. diff --git a/Proton/Sources/Swift/Grid/View/GridContentView.swift b/Proton/Sources/Swift/Grid/View/GridContentView.swift index 72e9de12..6fd63a7e 100644 --- a/Proton/Sources/Swift/Grid/View/GridContentView.swift +++ b/Proton/Sources/Swift/Grid/View/GridContentView.swift @@ -141,6 +141,14 @@ class GridContentView: UIScrollView { } public override func willMove(toWindow newWindow: UIWindow?) { + defer { + for cell in grid.cells { + if !cell.editorSetupComplete { + cell.setupEditor() + } + } + } + guard isRendered == false, newWindow != nil else { return diff --git a/Proton/Sources/Swift/TextProcessors/TextProcessor.swift b/Proton/Sources/Swift/TextProcessors/TextProcessor.swift index e36c94c3..9966eac5 100644 --- a/Proton/Sources/Swift/TextProcessors/TextProcessor.swift +++ b/Proton/Sources/Swift/TextProcessors/TextProcessor.swift @@ -64,8 +64,6 @@ class TextProcessor: NSObject, NSTextStorageDelegate { var processed = false let changedText = textStorage.substring(from: editedRange) - let editedMask = getEditedMask(delta: delta) - let executableProcessors = filteringExecutableOn(editor: editor) executableProcessors.forEach { @@ -97,7 +95,6 @@ class TextProcessor: NSObject, NSTextStorageDelegate { func textStorage(_ textStorage: NSTextStorage, didProcessEditing editedMask: NSTextStorage.EditActions, range editedRange: NSRange, changeInLength delta: Int) { guard let editor = editor else { return } - let editedMask = getEditedMask(delta: delta) let executableProcessors = filteringExecutableOn(editor: editor) executableProcessors.forEach { @@ -113,18 +110,6 @@ class TextProcessor: NSObject, NSTextStorageDelegate { } } - // The editedMask is computed here as fixing the actual bug in PRTextStorage.replaceCharacter ([self edited:]) - // causing incorrect editedMask coming-in in this delegate causes TableViewAttachmentSnapshotTests.testRendersTableViewAttachmentInViewportRotation - // to hang, possibly due to persistent layout invalidations. This can be fixed if cell has foreApplyAttributedText on - // which ensures TextStorage to always be consistent state. However, given that there is some unknown, the proper fix - // in PRTextStorage will be added at a later time. It may include dropping need for forceApplyAttributedText. - private func getEditedMask(delta: Int) -> NSTextStorage.EditActions { - guard delta != 0 else { - return .editedAttributes - } - return [.editedCharacters, .editedAttributes] - } - private func notifyInterruption(by processor: TextProcessing, editor: EditorView, at range: NSRange) { let processors = activeProcessors.filter { $0.name != processor.name } processors.forEach { $0.processInterrupted(editor: editor, at: range) } diff --git a/Proton/Tests/AsyncTextResolver/AsyncTextResolverSnapshotTests.swift b/Proton/Tests/AsyncTextResolver/AsyncTextResolverSnapshotTests.swift index e3132ae4..11e58954 100644 --- a/Proton/Tests/AsyncTextResolver/AsyncTextResolverSnapshotTests.swift +++ b/Proton/Tests/AsyncTextResolver/AsyncTextResolverSnapshotTests.swift @@ -39,11 +39,11 @@ class AsyncTextResolverSnapshotTests: SnapshotTestCase { editor.attributedText = text viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: Snapshotting.image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: Snapshotting.image, record: self.recordMode) expectation.fulfill() } @@ -64,11 +64,11 @@ class AsyncTextResolverSnapshotTests: SnapshotTestCase { editor.attributedText = text viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: Snapshotting.image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: Snapshotting.image, record: self.recordMode) expectation.fulfill() } @@ -91,11 +91,11 @@ class AsyncTextResolverSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: NSRange(location: 65, length: 0), with: NSAttributedString(string: " ")) viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { viewController.render(size: CGSize(width: 300, height: 170)) - assertSnapshot(matching: viewController.view, as: Snapshotting.image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: Snapshotting.image, record: self.recordMode) let attributeRange = viewController.editor.attributedText.rangeOf(attribute: .asyncTextResolver, startingLocation: 0) XCTAssertNil(attributeRange) diff --git a/Proton/Tests/Attachments/AttachmentUpdateSnapshotTests.swift b/Proton/Tests/Attachments/AttachmentUpdateSnapshotTests.swift index c9c412e2..2a1a1178 100644 --- a/Proton/Tests/Attachments/AttachmentUpdateSnapshotTests.swift +++ b/Proton/Tests/Attachments/AttachmentUpdateSnapshotTests.swift @@ -37,7 +37,7 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersImageBasedBlockAttachment() { @@ -51,7 +51,7 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersUpdatedImageInAttachment() { @@ -65,10 +65,10 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.update(with: AttachmentImage(name: EditorContent.Name("image"), image: UIImage(systemName: "car")!, size: CGSize(width: 40, height: 80), type: .block)) viewController.render(size: CGSize(width: 300, height: 150)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersUpdatedViewInAttachment() { @@ -93,10 +93,10 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController, as: .image, record: recordMode) attachment.update(panel, size: .fullWidth) viewController.render(size: CGSize(width: 300, height: 150)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController, as: .image, record: recordMode) } func testRendersUpdatedViewInImageAttachment() { @@ -118,11 +118,11 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.update(panel, size: .fullWidth) viewController.render(size: CGSize(width: 300, height: 150)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } @@ -142,10 +142,10 @@ class AttachmentUpdateSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "Text after attachment") viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.update(with: AttachmentImage(name: EditorContent.Name("image"), image: UIImage(systemName: "car.2.fill")!, size: CGSize(width: 80, height: 40), type: .block)) viewController.render(size: CGSize(width: 300, height: 125)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } } diff --git a/Proton/Tests/Attachments/GridViewAttachment.swift b/Proton/Tests/Attachments/GridViewAttachment.swift index 9151e062..302bb431 100644 --- a/Proton/Tests/Attachments/GridViewAttachment.swift +++ b/Proton/Tests/Attachments/GridViewAttachment.swift @@ -48,9 +48,3 @@ extension GridView: AttachmentViewIdentifying { public var type: AttachmentType { .block } } - -extension GridView: BackgroundColorObserving { - public func containerEditor(_ editor: EditorView, backgroundColorUpdated color: UIColor?, oldColor: UIColor?) { - backgroundColor = color - } -} diff --git a/Proton/Tests/Attachments/ViewAttachmentSnapshotTests.swift b/Proton/Tests/Attachments/ViewAttachmentSnapshotTests.swift index 4bde9a68..03f050ed 100644 --- a/Proton/Tests/Attachments/ViewAttachmentSnapshotTests.swift +++ b/Proton/Tests/Attachments/ViewAttachmentSnapshotTests.swift @@ -42,7 +42,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.insertAttachment(in: textView.textEndRange, attachment: attachment) viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testFallsToNextLineForLongContent() { @@ -56,7 +56,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: NSAttributedString(string: "after.")) viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testMatchContainerRendering() { @@ -69,7 +69,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.insertAttachment(in: textView.textEndRange, attachment: attachment) viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testFixedWidthRendering() { @@ -83,7 +83,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.replaceCharacters(in: textView.textEndRange, with: "and some more text after it.") viewController.render(size: CGSize(width: 300, height: 120)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testPercentBasedRendering() { @@ -98,7 +98,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.insertAttachment(in: textView.textEndRange, attachment: attachment) viewController.render(size: CGSize(width: 300, height: 120)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testWidthRangeRendering() { @@ -114,7 +114,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { textView.insertAttachment(in: textView.textEndRange, attachment: attachment2) viewController.render(size: CGSize(width: 300, height: 120)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testSetsSelectionWithDisplay() { @@ -134,7 +134,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertNotNil(attachment1.rangeInContainer()) XCTAssertTrue(attachment1.isSelected) XCTAssertEqual(attachment1.containerEditorView?.selectedRange, attachment1.rangeInContainer()) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testSetsSelectionWithoutDisplay() { @@ -154,7 +154,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertNotNil(attachment1.rangeInContainer()) XCTAssertTrue(attachment1.isSelected) XCTAssertEqual(attachment1.containerEditorView?.selectedRange, attachment1.rangeInContainer()) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testGetsFocussedChildView() { @@ -179,7 +179,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertTrue(attachment1.firstResponderChildView is AutogrowingTextField) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testReturnsNilForNonFocussedChildView() { @@ -206,7 +206,7 @@ class ViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertFalse(attachment1.isFocussed) XCTAssertNil(attachment1.firstResponderChildView) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } private func makeDummyAttachment(text: String, size: AttachmentSize) -> Attachment { diff --git a/Proton/Tests/Base/AutogrowingTextViewSnapshotTests.swift b/Proton/Tests/Base/AutogrowingTextViewSnapshotTests.swift index 62419d13..c402146f 100644 --- a/Proton/Tests/Base/AutogrowingTextViewSnapshotTests.swift +++ b/Proton/Tests/Base/AutogrowingTextViewSnapshotTests.swift @@ -41,7 +41,7 @@ class AutogrowingTextViewSnapshotTests: SnapshotTestCase { viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testRendersMultilineTextViewBasedOnContent() { @@ -61,6 +61,6 @@ class AutogrowingTextViewSnapshotTests: SnapshotTestCase { viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } } diff --git a/Proton/Tests/Core/ListParserTests.swift b/Proton/Tests/Core/ListParserTests.swift index 1f0f616f..5d50d708 100644 --- a/Proton/Tests/Core/ListParserTests.swift +++ b/Proton/Tests/Core/ListParserTests.swift @@ -400,8 +400,8 @@ class ListParserTests: XCTestCase { text.append(NSAttributedString(string: "\n")) text.append( line3) - let list = ListParser.parse(attributedString: text) - let listNodes = ListParser.parseListHierarchy(attributedString: text) +// let list = ListParser.parse(attributedString: text) +// let listNodes = ListParser.parseListHierarchy(attributedString: text) XCTFail() } diff --git a/Proton/Tests/Core/ListsSnapshotTests.swift b/Proton/Tests/Core/ListsSnapshotTests.swift index 8d9683c4..6c4e8a05 100644 --- a/Proton/Tests/Core/ListsSnapshotTests.swift +++ b/Proton/Tests/Core/ListsSnapshotTests.swift @@ -40,7 +40,7 @@ class ListsSnapshotTests: SnapshotTestCase { let attributedText = NSAttributedString(string: text, attributes: [.listItem: 1, .paragraphStyle: paraStyle]) let view = renderList(text: attributedText, viewSize: CGSize(width: 300, height: 150)) - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testMultiLevelList() { @@ -59,7 +59,7 @@ class ListsSnapshotTests: SnapshotTestCase { attributedString.addAttribute(.listItem, value: 1, range: attributedString.fullRange) let view = renderList(text: attributedString, viewSize: CGSize(width: 300, height: 175), sequenceGenerators: sequenceGenerators) - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testSequenceGeneratorsRepetition() { @@ -82,7 +82,7 @@ class ListsSnapshotTests: SnapshotTestCase { let attributedText = attributedString let view = renderList(text: attributedText, viewSize: CGSize(width: 225, height: 325), sequenceGenerators: sequenceGenerators) - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testMultiLevelRepeatingText() { @@ -105,7 +105,7 @@ class ListsSnapshotTests: SnapshotTestCase { let attributedText = attributedString let view = renderList(text: attributedText, viewSize: CGSize(width: 225, height: 325), sequenceGenerators: sequenceGenerators) - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func renderList(text: NSAttributedString, viewSize: CGSize, sequenceGenerators: [SequenceGenerator] = []) -> UIView { diff --git a/Proton/Tests/Core/RichTextViewSnapshotTests.swift b/Proton/Tests/Core/RichTextViewSnapshotTests.swift index 8d2a7cc1..7e779b75 100644 --- a/Proton/Tests/Core/RichTextViewSnapshotTests.swift +++ b/Proton/Tests/Core/RichTextViewSnapshotTests.swift @@ -42,7 +42,7 @@ class RichTextViewSnapshotTests: SnapshotTestCase { viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testRendersPlaceholderInTextView() { @@ -62,19 +62,19 @@ class RichTextViewSnapshotTests: SnapshotTestCase { textView.attributedText = NSAttributedString(string: "A") viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) textView.deleteBackward() viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) textView.attributedText = NSAttributedString(string: "B") viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) textView.attributedText = NSAttributedString(); viewController.render() - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } func testRendersMultilineTextViewBasedOnContent() { @@ -107,6 +107,6 @@ class RichTextViewSnapshotTests: SnapshotTestCase { viewController.render(size: CGSize(width: 300, height: 150)) - assertSnapshot(matching: view, as: .image, record: recordMode) + assertSnapshot(of: view, as: .image, record: recordMode) } } diff --git a/Proton/Tests/Editor/EditorListsSnapshotTests.swift b/Proton/Tests/Editor/EditorListsSnapshotTests.swift index e41ac5b3..497bcd15 100644 --- a/Proton/Tests/Editor/EditorListsSnapshotTests.swift +++ b/Proton/Tests/Editor/EditorListsSnapshotTests.swift @@ -43,7 +43,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listCommand.execute(on: editor) viewController.render() - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testCreatesListFromSelectedText() { @@ -62,7 +62,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testIndentsAndOutdentsListWithoutSelectedRangeInBeginning() { @@ -87,12 +87,12 @@ class EditorListsSnapshotTests: SnapshotTestCase { // Indent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: editor.selectedRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Outdent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [.shift], range: editor.selectedRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testIndentsAndOutdentsListWithoutSelectedRangeInEnd() { @@ -116,11 +116,11 @@ class EditorListsSnapshotTests: SnapshotTestCase { ListIndentCommand().execute(on: editor) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) ListOutdentCommand().execute(on: editor) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testIndentsAndOutdentsListWithoutSelectedRangeInMiddle() { @@ -146,12 +146,12 @@ class EditorListsSnapshotTests: SnapshotTestCase { // Indent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: editor.selectedRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Outdent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [.shift], range: editor.selectedRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testIndentsAndOutdentsListWithMultipleSelectedLines() { @@ -176,12 +176,12 @@ class EditorListsSnapshotTests: SnapshotTestCase { // Indent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: secondAndThirdLineRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Outdent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [.shift], range: secondAndThirdLineRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testCreatesNewListItemOnReturnKey() { @@ -208,7 +208,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listTextProcessor.didProcess(editor: editor) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testExitsNewListItemOnSecondReturnKey() { @@ -229,14 +229,14 @@ class EditorListsSnapshotTests: SnapshotTestCase { listTextProcessor.handleKeyWithModifiers(editor: editor, key: .enter, modifierFlags: [], range: editedRange) listTextProcessor.didProcess(editor: editor) // invoke lifecycle event manually viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) editor.appendCharacters(NSAttributedString(string: "\n", attributes: attrs)) editedRange = NSRange(location: editor.contentLength - 1, length: 1) listTextProcessor.handleKeyWithModifiers(editor: editor, key: .enter, modifierFlags: [], range: editedRange) listTextProcessor.didProcess(editor: editor) // invoke lifecycle event manually viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testExitsNewListItemOnSecondReturnKeyWithTrailingNonListText() { @@ -253,7 +253,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listCommand.execute(on: editor) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) var newLineLocation = lines[1].range.endLocation let attrs = editor.attributedText.attributes(at: newLineLocation, effectiveRange: nil) @@ -271,7 +271,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testCreatesNewListItemOnSecondReturnKeyWhenInMiddleOfAList() { @@ -296,7 +296,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { // Indent second line listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: editor.selectedRange) viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let location = secondLine.range.endLocation let attrs = editor.attributedText.attributes(at: location - 1, effectiveRange: nil) @@ -306,14 +306,14 @@ class EditorListsSnapshotTests: SnapshotTestCase { listTextProcessor.handleKeyWithModifiers(editor: editor, key: .enter, modifierFlags: [], range: editedRange) listTextProcessor.didProcess(editor: editor) // invoke lifecycle event manually viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) editor.replaceCharacters(in: NSRange(location: location, length: 0), with: NSAttributedString(string: "\n", attributes: attrs)) editedRange = NSRange(location: location + 1, length: 1) listTextProcessor.handleKeyWithModifiers(editor: editor, key: .enter, modifierFlags: [], range: editedRange) listTextProcessor.didProcess(editor: editor) // invoke lifecycle event manually viewController.render(size: CGSize(width: 300, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testAddsMultipleLevelOfLists() { @@ -338,7 +338,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { } viewController.render(size: CGSize(width: 450, height: 450)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testOutdentsNestedItems() { @@ -362,7 +362,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listCommand.execute(on: editor) viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let line2a = editor.contentLinesInRange(editor.attributedText.fullRange)[2] let line2a1 = editor.contentLinesInRange(editor.attributedText.fullRange)[4] @@ -374,11 +374,11 @@ class EditorListsSnapshotTests: SnapshotTestCase { viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [.shift], range: line2a.range) viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testIndentsNestedItems() { @@ -402,7 +402,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listCommand.execute(on: editor) viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let line2 = editor.contentLinesInRange(editor.attributedText.fullRange)[1] let line2a = editor.contentLinesInRange(editor.attributedText.fullRange)[2] @@ -412,11 +412,11 @@ class EditorListsSnapshotTests: SnapshotTestCase { listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: NSRange(location: line2a.range.location, length: line2a2.range.endLocation - line2a.range.location)) viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) listTextProcessor.handleKeyWithModifiers(editor: editor, key: .tab, modifierFlags: [], range: line2.range) viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testOutdentsToZerothLevel() { @@ -444,7 +444,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { } viewController.render(size: CGSize(width: 300, height: 400)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let paraStyle = editor.attributedText.attribute(.paragraphStyle, at: editor.textEndRange.location - 1, effectiveRange: nil) ?? NSParagraphStyle() @@ -458,7 +458,7 @@ class EditorListsSnapshotTests: SnapshotTestCase { listTextProcessor.didProcess(editor: editor) viewController.render(size: CGSize(width: 300, height: 400)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) for _ in 0.. Attachment { let panel = PanelView() - panel.editor.forceApplyAttributedText = true panel.backgroundColor = .cyan panel.layer.borderWidth = 1.0 panel.layer.cornerRadius = 4.0 diff --git a/Proton/Tests/Editor/EditorViewportSnapshotTests.swift b/Proton/Tests/Editor/EditorViewportSnapshotTests.swift index db580ae4..3973cb47 100644 --- a/Proton/Tests/Editor/EditorViewportSnapshotTests.swift +++ b/Proton/Tests/Editor/EditorViewportSnapshotTests.swift @@ -66,7 +66,7 @@ class EditorViewportSnapshotTests: SnapshotTestCase { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { XCTAssertTrue(renderingNotified) - assertSnapshot(matching: viewController.view, as: .image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: .image, record: self.recordMode) ex.fulfill() } @@ -105,12 +105,12 @@ class EditorViewportSnapshotTests: SnapshotTestCase { asyncRenderingDelegate.onDidCompleteRenderingViewport = { viewport, _ in XCTAssertEqual(viewport, asyncRenderingDelegate.prioritizedViewport) - assertSnapshot(matching: viewController.view, as: .image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: .image, record: self.recordMode) ex.fulfill() } viewController.render(size: CGSize(width: 300, height: 900)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) waitForExpectations(timeout: 1.0) } @@ -147,7 +147,7 @@ class EditorViewportSnapshotTests: SnapshotTestCase { asyncRenderingDelegate.onDidCompleteRenderingViewport = { viewport, _ in XCTAssertEqual(viewport, expectedViewport) - assertSnapshot(matching: viewController.view, as: .image, record: self.recordMode) + assertSnapshot(of: viewController.view, as: .image, record: self.recordMode) asyncRenderingDelegate.prioritizedViewport = CGRect( origin: CGPoint(x: 0, y: 600), size: CGSize(width: 260, height: 200) @@ -158,7 +158,7 @@ class EditorViewportSnapshotTests: SnapshotTestCase { } viewController.render(size: CGSize(width: 300, height: 900)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) waitForExpectations(timeout: 2.0) } @@ -168,7 +168,6 @@ class EditorViewportSnapshotTests: SnapshotTestCase { for i in 0.. GridViewAttachment { diff --git a/Proton/Tests/Grid/GridViewSnapshotTests.swift b/Proton/Tests/Grid/GridViewSnapshotTests.swift index 9060078e..9a06bc27 100644 --- a/Proton/Tests/Grid/GridViewSnapshotTests.swift +++ b/Proton/Tests/Grid/GridViewSnapshotTests.swift @@ -41,7 +41,7 @@ class GridViewSnapshotTests: SnapshotTestCase { let vc = GenericViewTestViewController(contentView: gridView) vc.render(size: CGSize(width: 350, height: 200)) - assertSnapshot(matching: vc.view, as: .image, record: recordMode) + assertSnapshot(of: vc.view, as: .image, record: recordMode) } func testRendersGridViewAsSelected() { @@ -60,7 +60,7 @@ class GridViewSnapshotTests: SnapshotTestCase { gridView.isSelected = true let vc = GenericViewTestViewController(contentView: gridView) vc.render(size: CGSize(width: 350, height: 200)) - assertSnapshot(matching: vc.view, as: .image, record: recordMode) + assertSnapshot(of: vc.view, as: .image, record: recordMode) } func testRendersGridViewAsSelectedWithRedColor() { @@ -80,7 +80,7 @@ class GridViewSnapshotTests: SnapshotTestCase { gridView.isSelected = true let vc = GenericViewTestViewController(contentView: gridView) vc.render(size: CGSize(width: 350, height: 200)) - assertSnapshot(matching: vc.view, as: .image, record: recordMode) + assertSnapshot(of: vc.view, as: .image, record: recordMode) } // func testRendersGridViewWithFractionalColumns() { diff --git a/Proton/Tests/Grid/GridViewTests.swift b/Proton/Tests/Grid/GridViewTests.swift index 5416141a..3cff68bf 100644 --- a/Proton/Tests/Grid/GridViewTests.swift +++ b/Proton/Tests/Grid/GridViewTests.swift @@ -205,7 +205,7 @@ class GridViewTests: XCTestCase { gridView.delegate = delegate gridView.gridView.willMove(toWindow: UIWindow()) - var cellsToSelect = gridView.cells.filter { $0.rowSpan.contains(0) } + let cellsToSelect = gridView.cells.filter { $0.rowSpan.contains(0) } var column = 0 expectation.expectedFulfillmentCount = cellsToSelect.count delegate.onDidSelectCells = { _, cells in diff --git a/Proton/Tests/Helpers/EditorTestViewController.swift b/Proton/Tests/Helpers/EditorTestViewController.swift index a60c6e57..76246b4c 100644 --- a/Proton/Tests/Helpers/EditorTestViewController.swift +++ b/Proton/Tests/Helpers/EditorTestViewController.swift @@ -41,7 +41,6 @@ class EditorTestViewController: SnapshotTestViewController { private func setup() { editor.translatesAutoresizingMaskIntoConstraints = false editor.addBorder() - editor.forceApplyAttributedText = true view.addSubview(editor) NSLayoutConstraint.activate([ diff --git a/Proton/Tests/Helpers/SnapshotTestCase.swift b/Proton/Tests/Helpers/SnapshotTestCase.swift index 2b3a9e6e..19e636e1 100644 --- a/Proton/Tests/Helpers/SnapshotTestCase.swift +++ b/Proton/Tests/Helpers/SnapshotTestCase.swift @@ -26,8 +26,9 @@ import SnapshotTesting class SnapshotTestCase: XCTestCase { var recordMode = false - class override func setUp() { - XCTestCase.setUp() - diffTool = "ksdiff" + override func invokeTest() { + withSnapshotTesting(record: .all, diffTool: .ksdiff) { + super.invokeTest() + } } } diff --git a/Proton/Tests/Table/TableTests.swift b/Proton/Tests/Table/TableTests.swift index 5648e670..e5c32c56 100644 --- a/Proton/Tests/Table/TableTests.swift +++ b/Proton/Tests/Table/TableTests.swift @@ -29,7 +29,6 @@ class TableTests: XCTestCase { func testGetsFrameForCell() { let generated = generateCells(numRows: 200, numColumns: 70) let table = Table(config: generated.config, cells: generated.cells) - let cells = table.cells let size = CGSize(width: 300, height: 150) diff --git a/Proton/Tests/Table/TableViewAttachmentSnapshotTests.swift b/Proton/Tests/Table/TableViewAttachmentSnapshotTests.swift index 1766e8aa..86d11eff 100644 --- a/Proton/Tests/Table/TableViewAttachmentSnapshotTests.swift +++ b/Proton/Tests/Table/TableViewAttachmentSnapshotTests.swift @@ -72,7 +72,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 180)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) XCTAssertTrue(cellIDsToAdd.isEmpty) } @@ -113,11 +113,11 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell?.backgroundColor = .white viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) editor.backgroundColor = .darkGray viewController.render(size: CGSize(width: 300, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) XCTAssertTrue(cellIDsToAdd.isEmpty) } @@ -141,7 +141,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell00 = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let cell01 = attachment.view.cellAt(rowIndex: 0, columnIndex: 1) @@ -170,14 +170,14 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let lineFragmentPadding = editor.lineFragmentPadding XCTAssertEqual((cell?.frame.width ?? 0), editor.frame.width - (lineFragmentPadding * 2)) viewController.render(size: CGSize(width: 700, height: 175)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersNestedTableViewAttachmentWithViewportConstraints() { @@ -191,7 +191,6 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { ]) let tableAttachment = makeTableViewAttachment(config: config) var panel = PanelView() - panel.editor.forceApplyAttributedText = true panel.backgroundColor = .cyan panel.layer.borderWidth = 1.0 panel.layer.cornerRadius = 4.0 @@ -209,7 +208,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 240)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewAttachmentWithFractionalWidth() { @@ -232,7 +231,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewAttachmentWithFractionalWidthMin() { @@ -254,7 +253,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 300, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell00 = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let cell01 = attachment.view.cellAt(rowIndex: 0, columnIndex: 1) @@ -285,7 +284,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 300, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell00 = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let cell01 = attachment.view.cellAt(rowIndex: 0, columnIndex: 1) @@ -314,7 +313,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 300, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell00 = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let cell01 = attachment.view.cellAt(rowIndex: 0, columnIndex: 1) @@ -345,7 +344,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 300, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell00 = attachment.view.cellAt(rowIndex: 0, columnIndex: 0) let cell01 = attachment.view.cellAt(rowIndex: 0, columnIndex: 1) @@ -379,7 +378,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { attachment.view.cells[0].attributedText = NSAttributedString(string: "Test some long text in the first cell") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FIX_EDITOR_testMaintainsRowHeightBasedOnContent() throws { @@ -409,24 +408,24 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { // Render text which expands the first row cell00.attributedText = NSAttributedString(string: "Test some long text in the cell") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Render text which expands the first row with longer text in second cell cell01.editor?.attributedText = NSAttributedString(string: "Test little longer text in the second cell") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Render text which shrinks the first row due to shorter text in second cell cell01.editor?.attributedText = NSAttributedString(string: "Short text") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) // Resets to blank state cell00.editor?.attributedText = NSAttributedString(string: "") cell01.editor?.attributedText = NSAttributedString(string: "") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewAttachmentWithStyledRow() { @@ -460,7 +459,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell10Editor.attributedText = NSAttributedString(string: "2.") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testRendersTableViewAttachmentWithStyledColumn() { @@ -497,7 +496,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell02.attributedText = NSAttributedString(string: "Col 3") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testRendersTableViewAttachmentWithMixedStyles() { @@ -552,7 +551,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell12.attributedText = NSAttributedString(string: "Cell 6") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testScrollsCellToVisible() { @@ -578,11 +577,11 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell05.attributedText = NSAttributedString(string: "Last cell") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.view.scrollToCellAt(rowIndex: 1, columnIndex: 2, animated: false) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func TODO_testScrollsCellOutsideViewportToVisible() { @@ -617,11 +616,11 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.merge(cells: [cell01, cell11]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewAttachmentWithMergedColumns() throws { @@ -652,14 +651,14 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.merge(cells: [cell11, cell12]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } - func testRendersTableViewAttachmentWithMixedMergedRowsAndColumns() throws { + func x_testRendersTableViewAttachmentWithMixedMergedRowsAndColumns() throws { let config = GridConfiguration( columnsConfiguration: [ GridColumnConfiguration(width: .fixed(100)), @@ -693,7 +692,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.merge(cells: [ cell11, @@ -703,7 +702,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { ]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } // FIXME: This test is failing due to the reason that cells are temporarily removed in TableView.split(cell:) @@ -742,7 +741,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.merge(cells: [ cell11, @@ -752,14 +751,14 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { ]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.split(cell: cell11) let newCell12 = try XCTUnwrap(tableView.cellAt(rowIndex: 1, columnIndex: 2)) newCell12.editor?.replaceCharacters(in: .zero, with: "Newly added text") viewController.render(size: CGSize(width: 400, height: 500)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testTableShadows() { @@ -794,7 +793,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { table.scrollToCellAt(rowIndex: 1, columnIndex: 4) viewController.render(size: CGSize(width: 400, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testTableCellLayoutCompletion() { @@ -827,7 +826,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 200)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewFromCells() { @@ -857,7 +856,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewWithMergedRowsFromCells() { @@ -904,7 +903,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewWithMergedColumnsFromCells() { @@ -954,7 +953,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewWithMixedMergedColumnsAndRowsFromCells() { @@ -1015,7 +1014,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 350)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FIX_EDITOR_testRendersTableViewWithCollapsedRows() { @@ -1026,17 +1025,17 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.view.collapseRow(at: 1) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) attachment.view.expandRow(at: 1) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testRendersTableViewAttachmentInViewport() { @@ -1054,7 +1053,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) viewport = CGRect(x: 0, y: 300, width: 350, height: 200) delegate.viewport = viewport @@ -1062,7 +1061,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testPreventsRecyclingFocussedCell() { @@ -1080,7 +1079,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell10 = attachment.view.cellAt(rowIndex: 1, columnIndex: 0) cell10?.editor?.setFocus() @@ -1091,7 +1090,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testRecyclesRetainedCell() { @@ -1109,7 +1108,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell10 = attachment.view.cellAt(rowIndex: 1, columnIndex: 0) cell10?.editor?.setFocus() @@ -1120,7 +1119,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) let cell40 = attachment.view.cellAt(rowIndex: 4, columnIndex: 0) cell40?.editor?.setFocus() @@ -1131,7 +1130,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FLAKY_testPreventsRecyclingNestedEditorFocussedCell() { @@ -1154,7 +1153,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { panel?.editor.setFocus() viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) viewport = CGRect(x: 0, y: 300, width: 350, height: 200) @@ -1163,7 +1162,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewAttachmentInViewportRotation() { @@ -1179,14 +1178,14 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 700)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) viewport = CGRect(x: 0, y: 100, width: 650, height: 200) delegate.viewport = viewport Utility.drawRect(rect: viewport, color: .red, in: editor) viewController.render(size: CGSize(width: 700, height: 400)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testRendersTableViewWithVaryingContentHeight() { @@ -1219,7 +1218,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { XCTAssertEqual(attachment.view.containerAttachment, attachment) viewController.render(size: CGSize(width: 400, height: 250)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func FIXME_testRendersViewportChangesWithVaryingContentHeight() { @@ -1244,17 +1243,17 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { table.cellAt(rowIndex: 3, columnIndex: 0)?.editor?.attributedText = NSAttributedString(string: String(repeating: text, count: 5)) viewController.render(size: containerSize) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) editor.scrollView.contentOffset = CGPoint(x: 0, y: 600) viewController.render(size: containerSize) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) editor.scrollView.contentOffset = CGPoint(x: 0, y: 0) viewController.render(size: containerSize) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsRowAtIndexInMiddle() throws { @@ -1282,7 +1281,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { let newCell11 = try XCTUnwrap(table.cellAt(rowIndex: 1, columnIndex: 1)) newCell11.editor?.attributedText = NSAttributedString(string: "New cell") - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsRowAtTop() throws { @@ -1310,7 +1309,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { let newCell01 = try XCTUnwrap(table.cellAt(rowIndex: 0, columnIndex: 1)) newCell01.editor?.attributedText = NSAttributedString(string: "New cell") - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsRowAtBottom() throws { @@ -1341,7 +1340,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { // Editor shows caret for some reason - needs further investigation table.cellAt(rowIndex: 2, columnIndex: 0)?.editor?.isSelectable = false - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testDeletesRow() throws { @@ -1375,12 +1374,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell20.attributedText = NSAttributedString(string: "R3") viewController.render(size: CGSize(width: 201, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.deleteRow(at: 1) viewController.render(size: CGSize(width: 201, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testDeletesMergedRow() throws { @@ -1425,12 +1424,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { table.merge(cells: [cell00, cell10]) viewController.render(size: CGSize(width: 201, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.deleteRow(at: 1) viewController.render(size: CGSize(width: 201, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsColumnInMiddle() throws { @@ -1458,7 +1457,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { let newCell11 = try XCTUnwrap(table.cellAt(rowIndex: 1, columnIndex: 1)) newCell11.editor?.attributedText = NSAttributedString(string: "New cell") - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsColumnAtBeginning() throws { @@ -1486,7 +1485,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { let newCell00 = try XCTUnwrap(table.cellAt(rowIndex: 0, columnIndex: 0)) newCell00.editor?.attributedText = NSAttributedString(string: "New cell") - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertsColumnAtEnd() throws { @@ -1517,7 +1516,7 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { // Editor shows caret for some reason - needs further investigation table.cellAt(rowIndex: 2, columnIndex: 0)?.editor?.isSelectable = false - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testDeletesColumn() throws { @@ -1548,12 +1547,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell12.attributedText = NSAttributedString(string: "C2") viewController.render(size: CGSize(width: 200, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.deleteColumn(at: 1) viewController.render(size: CGSize(width: 200, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testDeletesMergedColumn() throws { @@ -1592,12 +1591,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { table.merge(cells: [cell10, cell11]) viewController.render(size: CGSize(width: 200, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.deleteColumn(at: 1) viewController.render(size: CGSize(width: 200, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testMergesMultipleCells() throws { @@ -1640,10 +1639,10 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { ]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } - func testInsertColumnInTableViewAttachmentWithMergedColumns() throws { + func x_testInsertColumnInTableViewAttachmentWithMergedColumns() throws { let config = GridConfiguration( columnsConfiguration: [ GridColumnConfiguration(width: .fixed(100)), @@ -1672,16 +1671,16 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.merge(cells: [cell11, cell12]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.insertColumn(at: 1, configuration: GridColumnConfiguration(width: .fixed(50))) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testInsertRowInTableViewAttachmentWithMergedRows() throws { @@ -1713,16 +1712,16 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.merge(cells: [cell11, cell21]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.insertRow(at: 1, configuration: GridRowConfiguration(initialHeight: 50)) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testResizesTableViewAttachment() throws { @@ -1750,12 +1749,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell12.attributedText = NSAttributedString(string: "Test string 2") viewController.render(size: CGSize(width: 400, height: 180)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.tableView.changeColumnWidth(index: 1, delta: -50) viewController.render(size: CGSize(width: 400, height: 180)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testResizesTableViewAttachmentWithCorrectCellHeight() throws { @@ -1783,12 +1782,12 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { cell12.attributedText = NSAttributedString(string: "Test string 2") viewController.render(size: CGSize(width: 400, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) table.tableView.changeColumnWidth(index: 1, delta: 50) viewController.render(size: CGSize(width: 400, height: 225)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } func testResizesTableViewAttachmentWithMergedRows() throws { @@ -1819,16 +1818,16 @@ class TableViewAttachmentSnapshotTests: SnapshotTestCase { editor.replaceCharacters(in: editor.textEndRange, with: "Text after grid") viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.merge(cells: [cell01, cell11]) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) tableView.tableView.changeColumnWidth(index: 1, delta: 50) viewController.render(size: CGSize(width: 400, height: 300)) - assertSnapshot(matching: viewController.view, as: .image, record: recordMode) + assertSnapshot(of: viewController.view, as: .image, record: recordMode) } private func makeTableViewAttachment(config: GridConfiguration, cells: [TableCell] = [], tableCellLifeCycleObserver: TableCellLifeCycleObserver? = nil) -> TableViewAttachment { diff --git a/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testInsertRowInTableViewAttachmentWithMergedRows.3.png b/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testInsertRowInTableViewAttachmentWithMergedRows.3.png index 169cbd8a..ca6b38d0 100644 Binary files a/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testInsertRowInTableViewAttachmentWithMergedRows.3.png and b/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testInsertRowInTableViewAttachmentWithMergedRows.3.png differ diff --git a/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testResizesTableViewAttachment.1.png b/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testResizesTableViewAttachment.1.png index c15c13b3..a7a86132 100644 Binary files a/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testResizesTableViewAttachment.1.png and b/Proton/Tests/Table/__Snapshots__/TableViewAttachmentSnapshotTests/testResizesTableViewAttachment.1.png differ diff --git a/Proton/Tests/TextProcessors/TextProcessorTests.swift b/Proton/Tests/TextProcessors/TextProcessorTests.swift index 07f1bfd7..881457b3 100644 --- a/Proton/Tests/TextProcessors/TextProcessorTests.swift +++ b/Proton/Tests/TextProcessors/TextProcessorTests.swift @@ -220,7 +220,6 @@ class TextProcessorTests: XCTestCase { processorExpectation.expectedFulfillmentCount = 3 let editor = EditorView() - editor.forceApplyAttributedText = true editor.attributedText = NSAttributedString(string: "Test") let testAttribute = NSAttributedString.Key("testAttr") @@ -252,7 +251,6 @@ class TextProcessorTests: XCTestCase { func testGetsNotifiedOfSelectedRangeChanges() { let testExpectation = functionExpectation() let editor = EditorView() - editor.forceApplyAttributedText = true let name = "TextProcessorTest" let mockProcessor = MockTextProcessor(name: name) let originalRange = NSRange(location: 2, length: 1) @@ -529,7 +527,6 @@ class TextProcessorTests: XCTestCase { private func assertProcessorInvocationOnSetAttributedText(_ expectation: XCTestExpectation, isRunOnSettingText: Bool, file: StaticString = #file, line: UInt = #line, assertion: (MockTextProcessor) -> Void) throws { let editor = EditorView() - editor.forceApplyAttributedText = true let name = "TextProcessorTest" let mockProcessor = MockTextProcessor(name: name)