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.waitForReaderState(containing: "display=horizontalScroll", timeout: 5) let paging = app.collectionViews[IDs.readerPaging] XCTAssertTrue(paging.waitForExistence(timeout: 5), "分页滚动视图未出现") } func testPagingViewExistsInVerticalScrollMode() { app.launchAndOpenSampleBook(displayType: "vertical") app.waitForReader() app.waitForReaderState(containing: "display=verticalScroll", timeout: 5) let paging = app.collectionViews[IDs.readerPaging] XCTAssertTrue(paging.waitForExistence(timeout: 5), "分页滚动视图未出现") } func testSwipeInHorizontalScrollMode() { app.launchAndOpenSampleBook(displayType: "scroll") app.waitForReader() app.waitForReaderState(containing: "display=horizontalScroll", timeout: 5) 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, "水平滑动后页码未变化") } }