swiftformatting
This commit is contained in:
Родитель
2e40c74a1b
Коммит
add1d40ebc
|
@ -9,12 +9,12 @@
|
|||
import XCTest
|
||||
|
||||
class demoapp_ios_swift: 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.
|
||||
|
@ -22,15 +22,14 @@ class demoapp_ios_swift: XCTestCase {
|
|||
|
||||
// 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 testExample() {
|
||||
// Use recording to get started writing UI tests.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class AnalyticsViewController: UIViewController {
|
|||
MSAnalytics.trackEvent("Sample event")
|
||||
print("send a custom alert via Cocoapods")
|
||||
presentCustomEventAlert()
|
||||
|
||||
|
||||
case customColorButton:
|
||||
print("custom color property button pressed")
|
||||
presentColorPropertyAlert()
|
||||
|
@ -34,50 +34,50 @@ class AnalyticsViewController: UIViewController {
|
|||
}
|
||||
|
||||
// - MARK: Alert Functions
|
||||
|
||||
|
||||
func presentCustomEventAlert() {
|
||||
let alert = UIAlertController(title: "Event sent",
|
||||
message: "",
|
||||
preferredStyle: .alert)
|
||||
|
||||
|
||||
// OK Button
|
||||
alert.addAction(UIAlertAction(title: "OK",
|
||||
style: .default,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
self.present(alert, animated:true, completion: nil)
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
||||
func presentColorPropertyAlert() {
|
||||
let alert = UIAlertController(title: "Choose a color",
|
||||
message: "",
|
||||
preferredStyle: .alert)
|
||||
alert.view.tintColor = UIColor.black
|
||||
|
||||
|
||||
// Yellow button
|
||||
alert.addAction(UIAlertAction(title: "Yellow",
|
||||
style: .default,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
// sent yellow event here
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color" : "Yellow"])
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color": "Yellow"])
|
||||
|
||||
// Blue button
|
||||
alert.addAction(UIAlertAction(title: "Blue",
|
||||
style: .default,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
//sent blue event here
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color" : "Blue"])
|
||||
|
||||
// sent blue event here
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color": "Blue"])
|
||||
|
||||
// Red button
|
||||
alert.addAction(UIAlertAction(title: "Red",
|
||||
style: .default,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
//sent red event here
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color" : "Red"])
|
||||
|
||||
self.present(alert, animated:true, completion: nil)
|
||||
// sent red event here
|
||||
MSAnalytics.trackEvent("Color event", withProperties: ["Color": "Red"])
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
|
||||
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
MSMobileCenter.start("<APP SECRET HERE>", withServices:[
|
||||
MSMobileCenter.start("<APP SECRET HERE>", withServices: [
|
||||
MSAnalytics.self,
|
||||
MSCrashes.self,
|
||||
MSPush.self
|
||||
])
|
||||
MSPush.self,
|
||||
])
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -18,28 +18,27 @@ class CrashViewController: UIViewController {
|
|||
@IBAction func crashButtonTapped(_: UIButton) {
|
||||
presentCrashAlert()
|
||||
}
|
||||
|
||||
//- MARK: Alert Functions
|
||||
|
||||
// - MARK: Alert Functions
|
||||
func presentCrashAlert() {
|
||||
let alert = UIAlertController(title: "The app will close",
|
||||
message: "A crash report will be sent upon RE-LAUNCHING the app.",
|
||||
preferredStyle: UIAlertControllerStyle.alert)
|
||||
|
||||
|
||||
// Cancel Button
|
||||
alert.addAction(UIAlertAction(title: "Cancel",
|
||||
style: UIAlertActionStyle.default,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
}))
|
||||
// Crash App button
|
||||
alert.addAction(UIAlertAction(title: "Crash app",
|
||||
style: UIAlertActionStyle.destructive,
|
||||
handler: { (action) in alert.dismiss(animated: true, completion: nil)
|
||||
// generate test crash
|
||||
MSCrashes.generateTestCrash()
|
||||
fatalError()
|
||||
handler: { _ in alert.dismiss(animated: true, completion: nil)
|
||||
// generate test crash
|
||||
MSCrashes.generateTestCrash()
|
||||
fatalError()
|
||||
}))
|
||||
|
||||
self.present(alert, animated:true, completion: nil)
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,21 +10,20 @@ import XCTest
|
|||
@testable import demoapp_ios_swift
|
||||
|
||||
class demoapp_ios_swiftTests: XCTestCase {
|
||||
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// method called before invocation of each test method in class.
|
||||
}
|
||||
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
|
||||
func testCrashViewControllerLoads() {
|
||||
// test to ensure that the crash view controller loads.
|
||||
let vc = CrashViewController()
|
||||
XCTAssertNotNil(vc.view, "View did not load for CrashViewController.")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,26 +9,24 @@
|
|||
import XCTest
|
||||
|
||||
class demoapp_ios_swiftUITests: 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()
|
||||
|
||||
}
|
||||
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
|
||||
func testTrue() {
|
||||
XCTAssert(true)
|
||||
XCTAssert(true)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче