/*
 * Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

import XCTest

class S3TransferUtilitySampleSwiftUITests: XCTestCase {
        
    override func setUp() {
        super.setUp()
        
        // Put setup code here. This method is called before the invocation of each test method in the class.
        
        // In UI tests it is usually best to stop immediately when a failure occurs.
        continueAfterFailure = false
        // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
        XCUIApplication().launch()

        // 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.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testButtons() {
        // Use recording to get started writing UI tests.
        // Use XCTAssert and related functions to verify your tests produce the correct results.

        let app = XCUIApplication()
        let tabBarsQuery = app.tabBars
        let uploadButton = tabBarsQuery.buttons["Upload"]
        uploadButton.tap()
        app.buttons["Select Image and Upload"].tap()
        let cancelButton = app.navigationBars["Photos"].buttons["Cancel"]
        let exists = NSPredicate(format: "exists == 1")

        expectation(for: exists, evaluatedWith: cancelButton, handler: nil)
        waitForExpectations(timeout: 5, handler: nil)
        cancelButton.tap()
        let readyStaticText = app.staticTexts["Ready"]
        readyStaticText.tap()
        tabBarsQuery.buttons["Download"].tap()
        readyStaticText.tap()
        uploadButton.tap()
    }
    
}
