- 新增 RDEPUBReaderSearchCoordinator 与 RDEPUBSelectionState 管理搜索和选中状态 - 新增 BookmarkChromeStateTests、NavigationBackwardTests、SelectionAnnotateTests 等 UI 测试 - 新增多个边界测试 epub 样本(损坏结构、空归档、缺失文件、流式外链验证) - 重构阅读器 chrome 状态管理,统一 tool bar 与 search bar 交互 - 优化大书分页缓存策略(RDEPUBChapterSummaryDiskCache、RDEPUBPageCountCache) - 移除废弃的 RDEPUBLocationConverter 和 RDEPUBPageBreakPolicy - 更新 epub-bridge.js 与 JS bridge 通信协议 - 全面更新现有 UI 测试以适配新的 helper 和状态管理
77 lines
3.0 KiB
Swift
77 lines
3.0 KiB
Swift
import XCTest
|
|
|
|
final class PageNavigationTests: XCTestCase {
|
|
private let app = XCUIApplication()
|
|
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
func testContentAreaExistsForNavigation() {
|
|
app.launchAndOpenSampleBook()
|
|
app.waitForReader()
|
|
|
|
let content = app.otherElements[IDs.readerContent]
|
|
XCTAssertTrue(content.waitForExistence(timeout: 5), "阅读内容区域未出现")
|
|
}
|
|
|
|
func testPagingViewExistsInScrollMode() {
|
|
app.launchAndOpenSampleBook(displayType: "scroll")
|
|
app.waitForReader()
|
|
app.waitForDemoReaderState(timeout: 5, description: "display=horizontalScroll") { $0.display == "horizontalScroll" }
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
XCTAssertTrue(paging.waitForExistence(timeout: 5), "分页滚动视图未出现")
|
|
}
|
|
|
|
func testPagingViewExistsInVerticalScrollMode() {
|
|
app.launchAndOpenSampleBook(displayType: "vertical")
|
|
app.waitForReader()
|
|
app.waitForDemoReaderState(timeout: 5, description: "display=verticalScroll") { $0.display == "verticalScroll" }
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
XCTAssertTrue(paging.waitForExistence(timeout: 5), "分页滚动视图未出现")
|
|
}
|
|
|
|
func testSwipeInHorizontalScrollMode() {
|
|
app.launchAndOpenSampleBook(displayType: "scroll")
|
|
app.waitForReader()
|
|
app.waitForDemoReaderState(timeout: 5, description: "display=horizontalScroll") { $0.display == "horizontalScroll" }
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
XCTAssertTrue(paging.waitForExistence(timeout: 5))
|
|
|
|
let beforeState = app.waitForDemoReaderState(timeout: 5, description: "滑动前页码") { $0.page != nil }
|
|
let beforePage = beforeState.page ?? 0
|
|
|
|
paging.swipeLeft()
|
|
let afterState = app.waitForDemoReaderState(timeout: 8, description: "水平滑动后页码变化") { state in
|
|
guard let page = state.page else { return false }
|
|
return page != beforePage
|
|
}
|
|
XCTAssertNotEqual(beforePage, afterState.page, "水平滑动后页码未变化")
|
|
}
|
|
|
|
func testSwipeRightReturnsToPreviousPage() {
|
|
app.launchAndOpenSampleBook(displayType: "scroll", pageNumber: 3)
|
|
app.waitForReader()
|
|
app.waitForDemoReaderState(timeout: 8, description: "page=3") { $0.page == 3 }
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
XCTAssertTrue(paging.waitForExistence(timeout: 5))
|
|
paging.swipeRight()
|
|
|
|
let state = app.waitForDemoReaderState(timeout: 8, description: "returned to previous page") { state in
|
|
guard let page = state.page else { return false }
|
|
return page < 3
|
|
}
|
|
XCTAssertEqual(state.page, 2, "向右滑动后应回到上一页")
|
|
}
|
|
|
|
func testLaunchAtSpecificPageNumber() {
|
|
app.launchAndOpenSampleBook(pageNumber: 4)
|
|
app.waitForReader()
|
|
app.waitForDemoReaderState(timeout: 8, description: "page=4") { $0.page == 4 }
|
|
}
|
|
}
|