-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from DJBen/ui-testing
Add testings for the main app and eliminate test warnings
- Loading branch information
Showing
17 changed files
with
805 additions
and
55 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// RealmManager.swift | ||
// Graviton | ||
// | ||
// Created by Sihao Lu on 12/13/17. | ||
// Copyright © 2017 Ben Lu. All rights reserved. | ||
// | ||
|
||
import RealmSwift | ||
import Orbits | ||
|
||
class RealmManager { | ||
static let `default` = RealmManager() | ||
|
||
func migrateRealmIfNeeded() { | ||
let config = Realm.Configuration( | ||
// Set the new schema version. This must be greater than the previously used | ||
// version (if you've never set a schema version before, the version is 0). | ||
schemaVersion: 1, | ||
|
||
// Set the block which will be called automatically when opening a Realm with | ||
// a schema version lower than the one set above | ||
migrationBlock: { _, oldSchemaVersion in | ||
// We haven’t migrated anything yet, so oldSchemaVersion == 0 | ||
if oldSchemaVersion < 1 { | ||
// Nothing to do! | ||
// Realm will automatically detect new properties and removed properties | ||
// And will update the schema on disk automatically | ||
} | ||
}) | ||
|
||
// Tell Realm to use this new configuration object for the default Realm | ||
Realm.Configuration.defaultConfiguration = config | ||
|
||
// Now that we've told Realm how to handle the schema change, opening the file | ||
// will automatically perform the migration | ||
_ = try! Realm() | ||
} | ||
|
||
func clearRedundantRealm(daysAgo: Double = 3) { | ||
// Remove all cached realm objects more than a few days ago | ||
CelestialBodyObserverInfo.clearOutdatedInfo(daysAgo: daysAgo) | ||
RiseTransitSetElevation.clearOutdatedInfo(daysAgo: daysAgo) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Logging.swift | ||
// Graviton | ||
// | ||
// Created by Sihao Lu on 2/7/18. | ||
// Copyright © 2018 Ben Lu. All rights reserved. | ||
// | ||
|
||
import SwiftyBeaver | ||
|
||
let logger = SwiftyBeaver.self | ||
|
||
func configureLogging() { | ||
let console = ConsoleDestination() | ||
console.minLevel = .verbose | ||
logger.addDestination(console) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// FormattersTest.swift | ||
// GravitonTests | ||
// | ||
// Created by Sihao Lu on 2/7/18. | ||
// Copyright © 2018 Ben Lu. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
import CoreLocation | ||
@testable import Graviton | ||
|
||
class FormattersTest: XCTestCase { | ||
func testCoordinateFormatter() { | ||
let formatter = CoordinateFormatter() | ||
|
||
let coordinate = CLLocationCoordinate2D(latitude: -32.1, longitude: 58.42) | ||
let result = formatter.string(for: coordinate) | ||
XCTAssertEqual(result, "32° 6′ 0″ S, 58° 25′ 12″ E") | ||
|
||
let coordinate2 = CLLocationCoordinate2D(latitude: 173.94, longitude: -21.7) | ||
let result2 = formatter.string(for: coordinate2) | ||
XCTAssertEqual(result2, "173° 56′ 24″ N, 21° 41′ 60″ W") | ||
|
||
let zero = CLLocationCoordinate2D() | ||
XCTAssertEqual(formatter.string(for: zero), "0° 0′ 0″ N, 0° 0′ 0″ E") | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// GravitonUITests.swift | ||
// GravitonUITests | ||
// | ||
// Created by Sihao Lu on 12/12/17. | ||
// Copyright © 2017 Ben Lu. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class GravitonUITests: XCTestCase { | ||
var app: XCUIApplication! | ||
|
||
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 | ||
app = XCUIApplication() | ||
setupSnapshot(app) | ||
app.launchArguments.append("--ui-testing") | ||
} | ||
|
||
override func tearDown() { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
super.tearDown() | ||
} | ||
|
||
func testExample() { | ||
app.launch() | ||
app.navigationBars["Graviton.ObserverView"].buttons["menu icon settings"].tap() | ||
let tablesQuery = app.tables | ||
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Debugging"]/*[[".cells.staticTexts[\"Debugging\"]",".staticTexts[\"Debugging\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap() | ||
tablesQuery/*@START_MENU_TOKEN@*/.staticTexts["Horizontal Directions"]/*[[".cells.staticTexts[\"Horizontal Directions\"]",".staticTexts[\"Horizontal Directions\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap() | ||
tablesQuery/*@START_MENU_TOKEN@*/.buttons["West"]/*[[".cells.buttons[\"West\"]",".buttons[\"West\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap() | ||
|
||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>BNDL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.