feat: add in-reader search and restructure documentation
- Add RDEPUBReaderSearchBarView with animated show/hide, keyword navigation, and match counting integrated into the reader controller - Restructure docs: replace scattered design docs with consolidated BUSINESS_LOGIC.md and UML_CLASS_DIAGRAMS.md; update ARCHITECTURE.md - Add SearchTests and FanrenParseTimeTest; enhance LargeBookOnDemandTests - Add scripts/run_ui_regression.sh and summarize_ui_results.py for automated UI test execution and reporting Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
d20196ee34
commit
0e7c0577e3
@@ -70,6 +70,79 @@ final class LargeBookOnDemandTests: XCTestCase {
|
||||
XCTAssertEqual(reopenedState.knownChapters, reopenedState.buildableChapters)
|
||||
}
|
||||
|
||||
func testMiddleChapterOpenPositionStableAfterFullParse() throws {
|
||||
// 从中间章节打开,等后台解析完成,验证阅读位置不跳转
|
||||
app.launchAndOpenSampleBook(
|
||||
bookTitleQuery: largeBookQuery,
|
||||
pageNumber: 50,
|
||||
resetsReaderState: true
|
||||
)
|
||||
app.waitForReader(timeout: 20)
|
||||
|
||||
let partialState = app.waitForDemoReaderState(timeout: 15, description: "中间章节首开进入局部分页") { state in
|
||||
state.mode == "bookPageMap" && state.pagination == "partial" && (state.page ?? 0) >= 1
|
||||
}
|
||||
let pageAfterOpen = partialState.page ?? 0
|
||||
XCTAssertGreaterThan(pageAfterOpen, 1, "应从中间章节打开,当前页=\(pageAfterOpen)")
|
||||
|
||||
// 等待后台解析完成
|
||||
let fullState = app.waitForDemoReaderState(timeout: 90, description: "后台解析完成") { state in
|
||||
state.pagination == "full"
|
||||
}
|
||||
XCTAssertEqual(fullState.pagination, "full", "后台解析应完成")
|
||||
|
||||
// 验证页码未跳转(方案 C:pending map 不会在解析完成时应用)
|
||||
let pageAfterParse = fullState.page ?? 0
|
||||
XCTAssertEqual(pageAfterParse, pageAfterOpen,
|
||||
"后台解析完成后页码不应跳转:解析前=\(pageAfterOpen) 解析后=\(pageAfterParse)")
|
||||
|
||||
// 验证翻页功能正常(触发 pending map 应用)
|
||||
let paging = app.collectionViews[IDs.readerPaging]
|
||||
if paging.waitForExistence(timeout: 5) {
|
||||
paging.swipeLeft()
|
||||
}
|
||||
|
||||
let afterSwipe = app.waitForDemoReaderState(timeout: 10, description: "翻页后页码推进") { state in
|
||||
state.page != nil && state.page != pageAfterParse
|
||||
}
|
||||
XCTAssertGreaterThan(afterSwipe.page ?? 0, pageAfterParse,
|
||||
"翻页后页码应前进:翻页前=\(pageAfterParse) 翻页后=\(afterSwipe.page ?? 0)")
|
||||
}
|
||||
|
||||
func testMiddleChapterOpenSwipeAfterFullParseResolvesCorrectly() throws {
|
||||
// 从中间章节打开,等解析完成,连续翻页验证页码连续性
|
||||
app.launchAndOpenSampleBook(
|
||||
bookTitleQuery: largeBookQuery,
|
||||
pageNumber: 30,
|
||||
resetsReaderState: true
|
||||
)
|
||||
app.waitForReader(timeout: 20)
|
||||
|
||||
_ = app.waitForDemoReaderState(timeout: 15, description: "局部分页就绪") { state in
|
||||
state.mode == "bookPageMap" && state.pagination == "partial"
|
||||
}
|
||||
|
||||
// 等待解析完成
|
||||
_ = app.waitForDemoReaderState(timeout: 90, description: "后台解析完成") { state in
|
||||
state.pagination == "full"
|
||||
}
|
||||
|
||||
// 连续翻 3 页,验证页码连续递增
|
||||
let paging = app.collectionViews[IDs.readerPaging]
|
||||
XCTAssertTrue(paging.waitForExistence(timeout: 5), "分页视图不存在")
|
||||
|
||||
var previousPage = app.currentDemoReaderState()?.page ?? 0
|
||||
for i in 0..<3 {
|
||||
paging.swipeLeft()
|
||||
RunLoop.current.run(until: Date().addingTimeInterval(1))
|
||||
let currentState = app.currentDemoReaderState()
|
||||
let currentPage = currentState?.page ?? 0
|
||||
XCTAssertGreaterThan(currentPage, previousPage,
|
||||
"第 \(i + 1) 次翻页后页码应递增:前=\(previousPage) 后=\(currentPage)")
|
||||
previousPage = currentPage
|
||||
}
|
||||
}
|
||||
|
||||
func testLargeBookContinuousPagingExtendsKnownPageMap() throws {
|
||||
app.launchAndOpenSampleBook(bookTitleQuery: largeBookQuery, displayType: "scroll", resetsReaderState: true)
|
||||
app.waitForReader(timeout: 20)
|
||||
|
||||
Reference in New Issue
Block a user