Warning, /network/kdeconnect-ios/KDE Connect/KDE Connect UITests/KDE_Connect_UITests.swift is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Lucas Wang <lucas.wang@tuta.io> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 // Original header below: 0008 // 0009 // KDE_Connect_UITests.swift 0010 // KDE Connect UITests 0011 // 0012 // Created by Lucas Wang on 2021-06-17. 0013 // 0014 0015 import XCTest 0016 0017 // Intentional naming matching app target name 0018 // swiftlint:disable:next type_name 0019 class KDE_Connect_UITests: XCTestCase { 0020 override func setUpWithError() throws { 0021 // Put setup code here. This method is called before the invocation of each test method in the class. 0022 0023 // In UI tests it is usually best to stop immediately when a failure occurs. 0024 continueAfterFailure = false 0025 0026 // 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. 0027 } 0028 0029 override func tearDownWithError() throws { 0030 // Put teardown code here. This method is called after the invocation of each test method in the class. 0031 } 0032 0033 /// Take up to 10 screenshots for App Store release. 0034 func testTakeScreenshots() throws { 0035 let isPad = UIDevice.current.userInterfaceIdiom == .pad 0036 if isPad { 0037 XCUIDevice.shared.orientation = .landscapeLeft 0038 } 0039 0040 // UI tests must launch the application that they test. 0041 let app = XCUIApplication() 0042 setupSnapshot(app) 0043 app.launchArguments += [ 0044 "setupScreenshotDevices" 0045 ] 0046 app.launch() 0047 0048 func saveScreenshot(_ name: String) { 0049 snapshot(name) 0050 let attachment = XCTAttachment(screenshot: app.screenshot()) 0051 attachment.name = name 0052 attachment.lifetime = .keepAlways 0053 add(attachment) 0054 } 0055 0056 // Use recording to get started writing UI tests. 0057 // Use XCTAssert and related functions to verify your tests produce the correct results. 0058 0059 if !isPad { 0060 saveScreenshot("0. Home Screen") 0061 } 0062 0063 app.staticTexts["McIntosh"].tap() 0064 saveScreenshot("1. Device Details") 0065 0066 app.buttons["Slideshow Remote"].tap() 0067 saveScreenshot("3. Slideshow Remote") 0068 0069 app.navigationBars["Slideshow Remote"].buttons["McIntosh"].tap() 0070 app.buttons["Run Command"].tap() 0071 saveScreenshot("4. Run Command") 0072 0073 app.navigationBars["Run Command"].buttons["McIntosh"].tap() 0074 app.buttons["Remote Input"].tap() 0075 if isPad { 0076 app.navigationBars["Remote Input"].images["More"].tap() 0077 } 0078 saveScreenshot("5. Remote Input") 0079 if isPad { 0080 app.buttons["Send Single Left Click"].tap() 0081 } 0082 0083 // Order the files tab in front since this is our major feature 0084 app.tabBars["Tab Bar"].buttons["Files"].tap() 0085 if isPad { 0086 app.navigationBars["Status"].buttons["Sending"].tap() 0087 } else { 0088 app.navigationBars["File Transfers"].buttons["Sending"].tap() 0089 } 0090 saveScreenshot("2. Files") 0091 0092 app.tabBars["Tab Bar"].buttons["Settings"].tap() 0093 if isPad { 0094 app.staticTexts["Features"].tap() 0095 } 0096 saveScreenshot("6. Settings") 0097 0098 app.staticTexts["About"].tap() 0099 saveScreenshot("7. About") 0100 } 0101 0102 func testLaunchPerformance() throws { 0103 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { 0104 // This measures how long it takes to launch your application. 0105 measure(metrics: [XCTApplicationLaunchMetric()]) { 0106 XCUIApplication().launch() 0107 } 0108 } 0109 } 0110 }