69 lines
2.4 KiB
Swift
69 lines
2.4 KiB
Swift
import XCTest
|
|
|
|
final class ErrorAndEdgeCaseTests: XCTestCase {
|
|
private let app = XCUIApplication()
|
|
|
|
override func setUpWithError() throws {
|
|
continueAfterFailure = false
|
|
}
|
|
|
|
func testVerticalScrollSwipeNavigation() throws {
|
|
app.launchAndOpenSampleBook(displayType: "verticalscroll")
|
|
app.waitForReader(timeout: 12)
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
if paging.waitForExistence(timeout: 5) { paging.swipeUp() }
|
|
|
|
app.waitForReaderState(containing: "reader=opened", timeout: 5)
|
|
}
|
|
|
|
func testOpenAndCloseMultipleTimes() throws {
|
|
for iteration in 1...3 {
|
|
app.launchAndOpenSampleBook()
|
|
app.waitForReader(timeout: 12)
|
|
|
|
app.showReaderChromeIfNeeded()
|
|
let backButton = app.buttons[IDs.readerBack]
|
|
XCTAssertTrue(backButton.waitForExistence(timeout: 3), "返回按钮不存在")
|
|
backButton.tap()
|
|
|
|
let booksTable = app.tables[IDs.demoBooksTable]
|
|
XCTAssertTrue(booksTable.waitForExistence(timeout: 5), "书列表未出现")
|
|
}
|
|
}
|
|
|
|
func testRapidPageNavigation() throws {
|
|
app.launchAndOpenSampleBook()
|
|
app.waitForReader(timeout: 12)
|
|
app.waitForReaderPage(1, timeout: 5)
|
|
|
|
let paging = app.collectionViews[IDs.readerPaging]
|
|
guard paging.waitForExistence(timeout: 5) else { throw XCTSkip("分页视图不存在") }
|
|
|
|
for _ in 1...5 { paging.swipeLeft() }
|
|
|
|
app.waitForReaderState(containing: "reader=opened", timeout: 8)
|
|
}
|
|
|
|
func testSettingsPanelScrollReachesAllControls() throws {
|
|
app.launchAndOpenSampleBook()
|
|
app.waitForReader(timeout: 12)
|
|
|
|
app.showReaderChromeIfNeeded()
|
|
app.buttons[IDs.readerSettings].tap()
|
|
|
|
let settingsScroll = app.scrollViews[IDs.settingsScroll]
|
|
XCTAssertTrue(settingsScroll.waitForExistence(timeout: 5), "设置面板未出现")
|
|
|
|
XCTAssertTrue(app.buttons[IDs.settingsFontIncrease].waitForExistence(timeout: 3))
|
|
XCTAssertTrue(app.buttons[IDs.settingsBrightness].waitForExistence(timeout: 3))
|
|
|
|
settingsScroll.swipeUp()
|
|
XCTAssertTrue(app.segmentedControls[IDs.settingsDisplayType].waitForExistence(timeout: 5))
|
|
|
|
settingsScroll.swipeUp()
|
|
XCTAssertTrue(app.buttons[IDs.settingsTheme(5)].waitForExistence(timeout: 5))
|
|
|
|
app.buttons[IDs.settingsDone].tap()
|
|
}
|
|
} |