修复阅读器资源、朗读与持久化稳定性
阅读器在多会话朗读、加密 EPUB 资源、并发打开同一本书和多 UserDefaults 容器等场景下,存在旧异步结果覆盖新状态、锁屏控制串会话、大型明文资源被误拒绝、解压半成品被复用及标注跨容器混用的风险;同时高亮、书签、搜索和设置面板的空状态与自动化可访问性入口不完整。\n\n本次为朗读会话引入代次和当前 utterance 校验,远程控制改为仅响应当前会话并按自身 token 清理;加密资源 provider 先判定是否实际返回解密数据,明文大资源继续流式读取;解压缓存串行化以避免并发复用未完成目录。书签与高亮迁移至受保护文件,按 UserDefaults 容器隔离命名空间,保留标准容器旧文件兼容并确保新副本成功落盘后才删除历史数据。\n\n同步调整缓存淘汰、FoundationModels 弱链接、搜索/标注/设置面板交互与 UI 测试,并更新 Pod 生成配置及 API、风险文档。已执行 git diff --check 和 ReadViewDemo Debug Simulator 构建,结果为 BUILD SUCCEEDED。
This commit is contained in:
@@ -8,7 +8,9 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testReadingPositionRestoredOnReopen() throws {
|
||||
app.launchAndOpenSampleBook()
|
||||
// 必须用滚动模式:仿真翻页(默认)下没有 `epub.reader.paging`
|
||||
// collectionView,swipeLeft 落不到任何东西,页码永远停在 1
|
||||
app.launchAndOpenSampleBook(displayType: "scroll")
|
||||
app.waitForReader(timeout: 12)
|
||||
|
||||
_ = app.waitForDemoReaderState(timeout: 5, description: "存在页码") { $0.page != nil }
|
||||
@@ -30,7 +32,8 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
let backButton = app.buttons[IDs.readerBack]
|
||||
if backButton.waitForExistence(timeout: 3) { backButton.tap() }
|
||||
|
||||
app.launchAndOpenSampleBook()
|
||||
// 重开必须保留状态,否则 --demo-reset-state 会清掉刚存的阅读位置
|
||||
app.launchAndOpenSampleBook(displayType: "scroll", resetsReaderState: false)
|
||||
app.waitForReader(timeout: 12)
|
||||
|
||||
let restoredState = app.waitForDemoReaderState(timeout: 8, description: "恢复阅读位置") { state in
|
||||
@@ -61,7 +64,7 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
|
||||
app.showReaderChromeIfNeeded()
|
||||
if app.buttons[IDs.readerSettings].waitForExistence(timeout: 3) { app.buttons[IDs.readerSettings].tap() }
|
||||
if app.buttons[IDs.settingsFontIncrease].waitForExistence(timeout: 5) { app.buttons[IDs.settingsFontIncrease].tap() }
|
||||
app.increaseSettingsFontSize()
|
||||
if app.buttons[IDs.settingsDone].waitForExistence(timeout: 3) { app.buttons[IDs.settingsDone].tap() }
|
||||
|
||||
let backButton = app.buttons[IDs.readerBack]
|
||||
@@ -74,7 +77,8 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testPositionSurvivesFontChoiceAndLineHeightChange() throws {
|
||||
app.launchAndOpenSampleBook(resetsReaderState: true)
|
||||
// 同上:需要真正能翻页的模式
|
||||
app.launchAndOpenSampleBook(displayType: "scroll", resetsReaderState: true)
|
||||
app.waitForReader(timeout: 12)
|
||||
|
||||
let paging = app.collectionViews[IDs.readerPaging]
|
||||
@@ -97,17 +101,14 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
XCTAssertTrue(app.buttons[IDs.readerSettings].waitForExistence(timeout: 3))
|
||||
app.buttons[IDs.readerSettings].tap()
|
||||
|
||||
let fontChoiceControl = app.segmentedControls[IDs.settingsFontChoice]
|
||||
XCTAssertTrue(fontChoiceControl.waitForExistence(timeout: 5), "字体选择控件应出现")
|
||||
if fontChoiceControl.buttons.count > 1 {
|
||||
fontChoiceControl.buttons.element(boundBy: 1).tap()
|
||||
}
|
||||
|
||||
let lineHeightControl = app.segmentedControls[IDs.settingsLineHeight]
|
||||
XCTAssertTrue(lineHeightControl.waitForExistence(timeout: 5), "行距控件应出现")
|
||||
if lineHeightControl.buttons.count > 1 {
|
||||
lineHeightControl.buttons.element(boundBy: min(1, lineHeightControl.buttons.count - 1)).tap()
|
||||
}
|
||||
XCTAssertTrue(
|
||||
app.selectSettingsPillOption(pillIdentifier: IDs.settingsFontChoice, optionTitle: "宋体"),
|
||||
"字体选择控件应可切换"
|
||||
)
|
||||
XCTAssertTrue(
|
||||
app.selectSettingsPillOption(pillIdentifier: IDs.settingsLineHeight, optionTitle: "标准"),
|
||||
"行距控件应可切换"
|
||||
)
|
||||
|
||||
XCTAssertTrue(app.buttons[IDs.settingsDone].waitForExistence(timeout: 3))
|
||||
app.buttons[IDs.settingsDone].tap()
|
||||
@@ -131,8 +132,9 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
app.waitForDemoReaderState(timeout: 5, description: "bookmarks=1") { $0.bookmarks == 1 }
|
||||
|
||||
app.hideReaderChromeIfNeeded()
|
||||
let content = app.otherElements[IDs.readerSelectionText].firstMatch
|
||||
XCTAssertTrue(content.waitForExistence(timeout: 5))
|
||||
// 与其它选区用例一致:渲染路径没暴露选区元素时跳过,而不是硬失败在
|
||||
// 与本用例(跨重开保持)无关的前置步骤上
|
||||
let content = try app.requireSelectionText()
|
||||
let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.2, dy: 0.5))
|
||||
let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.55, dy: 0.5))
|
||||
start.press(forDuration: 0.8, thenDragTo: end)
|
||||
@@ -174,11 +176,10 @@ final class LocationPersistenceTests: XCTestCase {
|
||||
|
||||
app.showReaderChromeIfNeeded()
|
||||
app.buttons[IDs.readerSettings].tap()
|
||||
let fontChoiceControl = app.segmentedControls[IDs.settingsFontChoice]
|
||||
XCTAssertTrue(fontChoiceControl.waitForExistence(timeout: 5), "字体选择控件应出现")
|
||||
if fontChoiceControl.buttons.count > 1 {
|
||||
fontChoiceControl.buttons.element(boundBy: 1).tap()
|
||||
}
|
||||
XCTAssertTrue(
|
||||
app.selectSettingsPillOption(pillIdentifier: IDs.settingsFontChoice, optionTitle: "宋体"),
|
||||
"字体选择控件应可切换"
|
||||
)
|
||||
app.buttons[IDs.settingsDone].tap()
|
||||
|
||||
let content = app.otherElements[IDs.readerContent].firstMatch
|
||||
|
||||
Reference in New Issue
Block a user