comparison SimoleonUITests/SimoleonUITests.swift @ 132:9439c76e6590

Add tests
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 16 Aug 2021 18:22:46 +0100
parents 587924519d3b
children edc8719905fe
comparison
equal deleted inserted replaced
131:501ea028ea5e 132:9439c76e6590
9 9
10 class SimoleonUITests: XCTestCase { 10 class SimoleonUITests: XCTestCase {
11 11
12 override func setUpWithError() throws { 12 override func setUpWithError() throws {
13 // Put setup code here. This method is called before the invocation of each test method in the class. 13 // Put setup code here. This method is called before the invocation of each test method in the class.
14 if UIDevice.current.userInterfaceIdiom == .pad {
15 XCUIDevice.shared.orientation = .landscapeLeft
16 }
17
18 let app = XCUIApplication()
19 app.launchArguments += ["-AppleLocale", "en_US"]
20 app.launch()
14 21
15 // In UI tests it is usually best to stop immediately when a failure occurs. 22 // In UI tests it is usually best to stop immediately when a failure occurs.
16 continueAfterFailure = false 23 continueAfterFailure = false
17 24
18 // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 25 // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
19 } 26 }
20 27
21 override func tearDownWithError() throws { 28 override func tearDownWithError() throws {
22 // Put teardown code here. This method is called after the invocation of each test method in the class. 29 // Put teardown code here. This method is called after the invocation of each test method in the class.
23 } 30 }
24 31
32 func testTabBar() throws {
33 let app = XCUIApplication()
34 if UIDevice.current.userInterfaceIdiom == .pad {
35 app.tables["Sidebar"].buttons["NavigateToConversion"].tap()
36 XCTAssertTrue(app.staticTexts["Convert"].exists)
37
38 app.tables["Sidebar"].buttons["NavigateToFavorites"].tap()
39 XCTAssertTrue(app.staticTexts["Favorites"].exists)
40
41 app.tables["Sidebar"].buttons["NavigateToSettings"].tap()
42 XCTAssertTrue(app.staticTexts["Settings"].exists)
43 } else {
44 app.tabBars.buttons.element(boundBy: 0).tap()
45 XCTAssertTrue(app.staticTexts["Convert"].exists)
46
47 app.tabBars.buttons.element(boundBy: 1).tap()
48 XCTAssertTrue(app.staticTexts["Favorites"].exists)
49
50 app.tabBars.buttons.element(boundBy: 2).tap()
51 XCTAssertTrue(app.staticTexts["Settings"].exists)
52
53 }
54 }
55
56 func testCurrencySelector() throws {
57 let app = XCUIApplication()
58 app.scrollViews.buttons["OpenCurrencySelector"].tap()
59
60 let currencySearchBar = app.textFields["CurrencySearchBar"]
61 currencySearchBar.tap()
62 currencySearchBar.typeText("USD/BTC")
63 app.tables.buttons["From USD to BTC"].tap()
64 }
65
66 func testCoreData() throws {
67 let app = XCUIApplication()
68 app.scrollViews.buttons["favorite"].tap()
69
70 if UIDevice.current.userInterfaceIdiom == .pad {
71 app.tables["Sidebar"].buttons["NavigateToFavorites"].tap()
72 } else {
73 app.tabBars.buttons.element(boundBy: 1).tap()
74 }
75
76 XCTAssertTrue(app.tables.buttons["From USD to GBP"].exists)
77
78 let favoriteList = app.tables
79 favoriteList.buttons["From USD to GBP"].swipeLeft()
80 favoriteList.buttons["Delete"].tap()
81 XCTAssertFalse(app.tables.buttons["From USD to GBP"].exists)
82 }
25 83
26 func testLaunchPerformance() throws { 84 func testLaunchPerformance() throws {
27 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 85 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
28 // This measures how long it takes to launch your application. 86 // This measures how long it takes to launch your application.
29 measure(metrics: [XCTApplicationLaunchMetric()]) { 87 measure(metrics: [XCTApplicationLaunchMetric()]) {