TestingAppDelegate.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // TestingSceneDelegate.swift
  3. // ark_ui_basic
  4. //
  5. // Status: Complete for iOS
  6. #if os(iOS) || os(visionOS)
  7. import UIKit
  8. #elseif os(macOS)
  9. import AppKit
  10. #endif
  11. // MARK: - TestingAppDelegate [6.4.41] [iOS]
  12. class TestingAppDelegate: DelegateBaseClass, PlatformApplicationDelegate {
  13. static var testHost: (PlatformView & TestHost)?
  14. static var comparisonHost: (PlatformView & TestHost)?
  15. static var performanceTests: [_PerformanceTest]?
  16. static var application: PlatformApplication?
  17. #if os(iOS) || os(visionOS)
  18. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
  19. true
  20. }
  21. func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
  22. let configuration = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
  23. configuration.delegateClass = TestingSceneDelegate.self
  24. return configuration
  25. }
  26. // WIP
  27. @objc
  28. func application(_ application: UIApplication, runTest name: String, options: [AnyHashable: Any]) -> Bool {
  29. guard let performanceTests = TestingAppDelegate.performanceTests,
  30. let performanceTest = performanceTests.first(where: { $0.name == name }),
  31. let host = TestingAppDelegate.testHost else {
  32. return false
  33. }
  34. performanceTest.runTest(host: host, options: options)
  35. return true
  36. }
  37. #endif
  38. }