- 移除 RDEPUBSelectableTextView,改用原生 UITextView - 新增 NSAttributedString 自定义属性(com.rdreader.highlight/underline)注入高亮 - RDEPUBTextPageRenderView 统一绘制高亮背景、文字和选区 - RDEPUBTextSelectionController 精简,选区矩形传递给 RenderView 绘制 - 新增高亮选区复刻 WXRead 实现方案文档 - UI 测试适配新架构 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
51 lines
1.9 KiB
Swift
51 lines
1.9 KiB
Swift
import XCTest
|
|
|
|
final class ReaderAnnotationTests: XCTestCase {
|
|
private let app = XCUIApplication()
|
|
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
func testSelectionMenuCreatesHighlight() {
|
|
app.launchAndOpenSampleBook(pageNumber: 2)
|
|
app.waitForReader()
|
|
|
|
let content = app.textViews[IDs.readerSelectionText].firstMatch
|
|
XCTAssertTrue(content.waitForExistence(timeout: 5), "阅读内容区域未出现")
|
|
|
|
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.42))
|
|
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.68, dy: 0.42))
|
|
start.press(forDuration: 0.6, thenDragTo: end)
|
|
|
|
app.waitForReaderState(containing: "selection=1", timeout: 5)
|
|
|
|
let highlightMenuItem = app.menuItems["高亮"]
|
|
let highlightButton = app.buttons[IDs.readerSelectionHighlight]
|
|
if highlightMenuItem.waitForExistence(timeout: 3) {
|
|
highlightMenuItem.tap()
|
|
} else if highlightButton.waitForExistence(timeout: 3) {
|
|
highlightButton.tap()
|
|
} else {
|
|
XCTFail("选中文本后未出现高亮菜单")
|
|
}
|
|
|
|
app.waitForReaderState(containing: "highlights=1", timeout: 8)
|
|
}
|
|
|
|
func testLongPressSelectionDoesNotShowToolbars() {
|
|
app.launchAndOpenSampleBook(pageNumber: 2)
|
|
app.waitForReader()
|
|
|
|
let content = app.textViews[IDs.readerSelectionText].firstMatch
|
|
XCTAssertTrue(content.waitForExistence(timeout: 5), "阅读内容区域未出现")
|
|
|
|
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.42))
|
|
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.68, dy: 0.42))
|
|
start.press(forDuration: 0.6, thenDragTo: end)
|
|
|
|
app.waitForReaderState(containing: "selection=1", timeout: 5)
|
|
app.waitForReaderState(containing: "toolbar=hidden", timeout: 5)
|
|
}
|
|
}
|