ReadViewSDK/ReadViewDemo/ReadViewDemoUITests/ReaderUITests/NavigationBackwardTests.swift
shen 6f75b083f7 feat: EPUB 阅读器搜索、选中注释、书签 chrome 状态及大量重构优化
- 新增 RDEPUBReaderSearchCoordinator 与 RDEPUBSelectionState 管理搜索和选中状态
- 新增 BookmarkChromeStateTests、NavigationBackwardTests、SelectionAnnotateTests 等 UI 测试
- 新增多个边界测试 epub 样本(损坏结构、空归档、缺失文件、流式外链验证)
- 重构阅读器 chrome 状态管理,统一 tool bar 与 search bar 交互
- 优化大书分页缓存策略(RDEPUBChapterSummaryDiskCache、RDEPUBPageCountCache)
- 移除废弃的 RDEPUBLocationConverter 和 RDEPUBPageBreakPolicy
- 更新 epub-bridge.js 与 JS bridge 通信协议
- 全面更新现有 UI 测试以适配新的 helper 和状态管理
2026-06-13 22:48:56 +08:00

84 lines
2.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import XCTest
///
///
final class NavigationBackwardTests: XCTestCase {
private let app = XCUIApplication()
override func setUpWithError() throws {
continueAfterFailure = false
}
///
func testSwipeRightGoesToPreviousPage() throws {
app.launchAndOpenSampleBook()
app.waitForReader()
//
let content = app.otherElements[IDs.readerContent].firstMatch
guard content.waitForExistence(timeout: 5) else {
throw XCTSkip("内容区域不存在")
}
content.swipeLeft()
Thread.sleep(forTimeInterval: 0.5)
content.swipeLeft()
Thread.sleep(forTimeInterval: 0.5)
//
let stateAfterForward = app.waitForDemoReaderState(timeout: 5, description: "page after forward") {
($0.page ?? 0) > 1
}
let pageAfterForward = stateAfterForward.page ?? 2
XCTAssertGreaterThan(pageAfterForward, 1, "应已前进到第 2 页或更后")
//
content.swipeRight()
Thread.sleep(forTimeInterval: 0.5)
//
let stateAfterBack = app.waitForDemoReaderState(timeout: 5, description: "page after back") {
($0.page ?? 0) < pageAfterForward
}
XCTAssertLessThan(stateAfterBack.page ?? 0, pageAfterForward, "向右滑动后页码应减少")
}
///
func testDisplayTypeSwitchMidSession() throws {
app.launchAndOpenSampleBook(displayType: "horizontalScroll")
app.waitForReader()
//
app.waitForDemoReaderState(timeout: 5, description: "initial horizontalScroll") {
$0.display == "horizontalScroll"
}
//
app.showReaderChromeIfNeeded()
let settingsButton = app.buttons[IDs.readerSettings]
guard settingsButton.waitForExistence(timeout: 3) else {
throw XCTSkip("设置按钮不存在")
}
settingsButton.tap()
//
let displayTypeButton = app.buttons[IDs.settingsDisplayType]
guard displayTypeButton.waitForExistence(timeout: 3) else {
throw XCTSkip("显示模式按钮不存在")
}
displayTypeButton.tap()
//
let doneButton = app.buttons[IDs.settingsDone]
if doneButton.waitForExistence(timeout: 3) {
doneButton.tap()
}
//
app.waitForDemoReaderState(timeout: 5, description: "switched to verticalScroll") {
$0.display == "verticalScroll"
}
}
}