generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c76221
commit 5091cdb
Showing
11 changed files
with
240 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,63 @@ | ||
//// | ||
//// This source file is part of the CS342 2023 PAWS Team Application project | ||
//// | ||
//// SPDX-FileCopyrightText: 2023 Stanford University | ||
//// | ||
//// SPDX-License-Identifier: MIT | ||
//// | ||
// | ||
// import XCTest | ||
// import XCTHealthKit | ||
// | ||
// | ||
// class HealthKitUploadTests: XCTestCase { | ||
// override func setUpWithError() throws { | ||
// try super.setUpWithError() | ||
// | ||
// continueAfterFailure = false | ||
// | ||
// let app = XCUIApplication() | ||
// app.launchArguments = ["--showOnboarding"] | ||
// app.deleteAndLaunch(withSpringboardAppName: "PAWS") | ||
// } | ||
// | ||
// | ||
// func testHealthKitMockUpload() throws { | ||
// let app = XCUIApplication() | ||
// | ||
//// try app.conductOnboardingIfNeeded() | ||
// | ||
// try navigateToMockUpload() | ||
// try assertObservationCellPresent(false) | ||
// | ||
// app.terminate() | ||
// | ||
// try exitAppAndOpenHealth(.steps) | ||
// | ||
// app.activate() | ||
// | ||
//// try navigateToMockUpload() | ||
// try assertObservationCellPresent(true, pressIfPresent: true) | ||
// try assertObservationCellPresent(true, pressIfPresent: false) | ||
// } | ||
// | ||
// | ||
// private func navigateToMockUpload() throws { | ||
// let app = XCUIApplication() | ||
// | ||
//// XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Mock Upload"].waitForExistence(timeout: 0.5)) | ||
//// app.tabBars["Tab Bar"].buttons["Mock Upload"].tap() | ||
// } | ||
// | ||
// private func assertObservationCellPresent(_ shouldBePresent: Bool, pressIfPresent: Bool = true) throws { | ||
// let app = XCUIApplication() | ||
// | ||
// let observationText = "/Observation/" | ||
// let predicate = NSPredicate(format: "label CONTAINS[c] %@", observationText) | ||
// | ||
// if shouldBePresent { | ||
// XCTAssertTrue(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5)) | ||
// if pressIfPresent { | ||
// app.staticTexts.containing(predicate).firstMatch.tap() | ||
// } | ||
// } else { | ||
// XCTAssertFalse(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5)) | ||
// } | ||
// } | ||
// } | ||
// This source file is part of the CS342 2023 PAWS Team Application project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import XCTest | ||
import XCTestExtensions | ||
import XCTHealthKit | ||
|
||
|
||
class HealthKitUploadTests: XCTestCase { | ||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
|
||
continueAfterFailure = false | ||
|
||
let app = XCUIApplication() | ||
app.launchArguments = ["--showOnboarding"] | ||
app.deleteAndLaunch(withSpringboardAppName: "PAWS") | ||
} | ||
|
||
|
||
func testHealthKitMockUpload() throws { | ||
let app = XCUIApplication() | ||
|
||
try app.conductOnboardingIfNeeded() | ||
|
||
try app.navigateToMockUpload() | ||
try app.assertObservationCellPresent(false) | ||
|
||
try exitAppAndOpenHealth(.electrocardiograms) | ||
|
||
app.activate() | ||
|
||
try app.navigateToMockUpload() | ||
try app.assertObservationCellPresent(true, pressIfPresent: true) | ||
try app.assertObservationCellPresent(true, pressIfPresent: false) | ||
} | ||
} | ||
|
||
extension XCUIApplication { | ||
fileprivate func navigateToMockUpload() throws { | ||
XCTAssertTrue(tabBars["Tab Bar"].buttons["Mock Upload"].waitForExistence(timeout: 0.5)) | ||
tabBars["Tab Bar"].buttons["Mock Upload"].tap() | ||
} | ||
|
||
fileprivate func assertObservationCellPresent(_ shouldBePresent: Bool, pressIfPresent: Bool = true) throws { | ||
let observationText = "/Observation/" | ||
let predicate = NSPredicate(format: "label CONTAINS[c] %@", observationText) | ||
|
||
if shouldBePresent { | ||
XCTAssertTrue(staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5)) | ||
if pressIfPresent { | ||
staticTexts.containing(predicate).firstMatch.tap() | ||
} | ||
} else { | ||
XCTAssertFalse(staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 0.5)) | ||
} | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
PAWSUITests/Helper Extensions/XCUIApplication+DeleteAndLaunch.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.