# HG changeset patch # User Dennis Concepcion Martin # Date 1629134566 -3600 # Node ID 9439c76e65905eb0ce448544bd18b65bf3980e7d # Parent 501ea028ea5ec6da0737bfd2233c534b7333675d Add tests diff -r 501ea028ea5e -r 9439c76e6590 SimoleonUITests/SimoleonUITests.swift --- a/SimoleonUITests/SimoleonUITests.swift Mon Aug 16 18:22:38 2021 +0100 +++ b/SimoleonUITests/SimoleonUITests.swift Mon Aug 16 18:22:46 2021 +0100 @@ -11,6 +11,13 @@ override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. + if UIDevice.current.userInterfaceIdiom == .pad { + XCUIDevice.shared.orientation = .landscapeLeft + } + + let app = XCUIApplication() + app.launchArguments += ["-AppleLocale", "en_US"] + app.launch() // In UI tests it is usually best to stop immediately when a failure occurs. continueAfterFailure = false @@ -21,7 +28,58 @@ override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } - + + func testTabBar() throws { + let app = XCUIApplication() + if UIDevice.current.userInterfaceIdiom == .pad { + app.tables["Sidebar"].buttons["NavigateToConversion"].tap() + XCTAssertTrue(app.staticTexts["Convert"].exists) + + app.tables["Sidebar"].buttons["NavigateToFavorites"].tap() + XCTAssertTrue(app.staticTexts["Favorites"].exists) + + app.tables["Sidebar"].buttons["NavigateToSettings"].tap() + XCTAssertTrue(app.staticTexts["Settings"].exists) + } else { + app.tabBars.buttons.element(boundBy: 0).tap() + XCTAssertTrue(app.staticTexts["Convert"].exists) + + app.tabBars.buttons.element(boundBy: 1).tap() + XCTAssertTrue(app.staticTexts["Favorites"].exists) + + app.tabBars.buttons.element(boundBy: 2).tap() + XCTAssertTrue(app.staticTexts["Settings"].exists) + + } + } + + func testCurrencySelector() throws { + let app = XCUIApplication() + app.scrollViews.buttons["OpenCurrencySelector"].tap() + + let currencySearchBar = app.textFields["CurrencySearchBar"] + currencySearchBar.tap() + currencySearchBar.typeText("USD/BTC") + app.tables.buttons["From USD to BTC"].tap() + } + + func testCoreData() throws { + let app = XCUIApplication() + app.scrollViews.buttons["favorite"].tap() + + if UIDevice.current.userInterfaceIdiom == .pad { + app.tables["Sidebar"].buttons["NavigateToFavorites"].tap() + } else { + app.tabBars.buttons.element(boundBy: 1).tap() + } + + XCTAssertTrue(app.tables.buttons["From USD to GBP"].exists) + + let favoriteList = app.tables + favoriteList.buttons["From USD to GBP"].swipeLeft() + favoriteList.buttons["Delete"].tap() + XCTAssertFalse(app.tables.buttons["From USD to GBP"].exists) + } func testLaunchPerformance() throws { if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {