Skip to content

Commit

Permalink
Added in files
Browse files Browse the repository at this point in the history
  • Loading branch information
tyirvine committed May 9, 2022
1 parent 74715ad commit 5e359af
Show file tree
Hide file tree
Showing 102 changed files with 9,487 additions and 0 deletions.
82 changes: 82 additions & 0 deletions Informant-Tests/Informant_Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// Informant_Tests.swift
// Informant-Tests
//
// Created by Ty Irvine on 2022-04-05.
//

@testable import Informant
import SwiftUI
import XCTest

class Informant_Tests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
print("--------------- TEST START 🟢 ----------------")
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
print("--------------- TEST FINISH 🔴 ----------------")
}

/*
func testExample() throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
// Any test you write for XCTest can be annotated as throws and async.
// Mark your test throws to produce an unexpected failure when your test encounters an uncaught error.
// Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards.
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
}
}
*/

// MARK: - Test Helpers

func printTestName(name: String) {
print("🛃 TEST - \(name)")
}

// MARK: - Tests

// Tests to make sure the correct metadata can be found for the provided path
func testStandardSelection() throws {

printTestName(name: "Standard Selection")

// Provided selection
let path = "/Users/tyirvine/Files/Archive/Testing/SF-Display.otf"

// Measures total execution time
// Get current app delegate
let appDelegate = AppDelegate.current()

// Path bundle
let paths = Paths(paths: [path], state: .PathAvailable)

// Get the selection with the provided path
guard let data = appDelegate.dataController.getSelection(paths)?.data else {
return XCTAssertEqual(true, false, "Selection is not valid ❌")
}

// ---------------- Confirm data is valid ----------------

let failureMessage = """
Selection is not valid ❌
It's possible size is disabled in settings. Make sure it's enabled and try again.
"""

XCTAssertEqual(data.data[String.keyShowSize], "2.3 MB", failureMessage)
}
}
868 changes: 868 additions & 0 deletions Informant.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions Informant.xcodeproj/xcshareddata/xcschemes/Informant.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A09C2AE27C3F455007C1FE7"
BuildableName = "Informant.app"
BlueprintName = "Informant"
ReferencedContainer = "container:Informant.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A41B02427FCD88A00E0C089"
BuildableName = "Informant-Tests.xctest"
BlueprintName = "Informant-Tests"
ReferencedContainer = "container:Informant.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A09C2AE27C3F455007C1FE7"
BuildableName = "Informant.app"
BlueprintName = "Informant"
ReferencedContainer = "container:Informant.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9A09C2AE27C3F455007C1FE7"
BuildableName = "Informant.app"
BlueprintName = "Informant"
ReferencedContainer = "container:Informant.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
154 changes: 154 additions & 0 deletions Informant/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//
// AppDelegate.swift
// Informant
//
// Created by Ty Irvine on 2022-02-21.
//

import Cocoa
import SwiftUI

@main
class AppDelegate: NSObject, NSApplicationDelegate {

// ----------------------------- Universal ---------------------------

// Settings
var settings: Settings!

// ----------------------------- Controllers ---------------------------

// Status controller
var statusController: StatusController!

// Interaction controller
var interactionController: InteractionController!

// Data controller
var dataController: DataController!

// Interface controller
var interfaceController: InterfaceController!

// Display controller
var displayController: DisplayController!

// Menu controller
var menuController: MenuController!

// Path controller
var pathController: PathController!

// Update controller
var updateController: UpdateController!

// Settings controller
var settingsController: SettingsController!

// ------------------------------- Displays ----------------------------

// Status display
var statusDisplay: StatusDisplay!

// Float display
var floatDisplay: FloatDisplay!

// ------------------------------- Windows -----------------------------

// Settings window
var settingsWindowController: WindowController<SettingsView>!

// Welcome window
var welcomeWindowController: WindowController<WelcomeView>!

// About window
var aboutWindowController: WindowController<AboutView>!

// Accessibiility window
var accessibilityWindowController: WindowController<AccessibilityView>!

// Payment window
var paymentWindowController: WindowController<PaymentView>!

// -------------------------- Directors ------------------------------

// Data director
var dataDirector: DataDirector!

// Notification director
var notificationDirector: NotificationDirector!

// -------------------------- Items ------------------------------

/// We use this to access the menu bar status item. This toggles the panel open and closed. It's the main button.
var statusItem: NSStatusItem?

/// We use this to access the menu pop up.
var statusMenu: NSMenu?

// -------------------------- Testing ------------------------------

#if DEBUG
var testing: Testing?
#endif

// ======================== App Start ✳️ ============================

func applicationDidFinishLaunching(_ aNotification: Notification) {

// MARK: - Initialize

// Initialize settings
Settings.registerDefaults()
settingsController = SettingsController(appDelegate: self)
settings = settingsController.settings

// Initialize controllers
menuController = MenuController(appDelegate: self)
statusController = StatusController(appDelegate: self)
interactionController = InteractionController(appDelegate: self)
dataController = DataController(appDelegate: self)
interfaceController = InterfaceController(appDelegate: self)
displayController = DisplayController(appDelegate: self)
pathController = PathController(appDelegate: self)
updateController = UpdateController(appDelegate: self)

// Initialize directors
dataDirector = DataDirector()
notificationDirector = NotificationDirector(appDelegate: self)

// Initialize displays
statusDisplay = StatusDisplay(appDelegate: self)
floatDisplay = FloatDisplay(appDelegate: self)

// Initialize windows
settingsWindowController = WindowController(appDelegate: self, rootView: SettingsView(), fullToolbar: true)
welcomeWindowController = WindowController(appDelegate: self, rootView: WelcomeView())
aboutWindowController = WindowController(appDelegate: self, rootView: AboutView())
accessibilityWindowController = WindowController(appDelegate: self, rootView: AccessibilityView())
paymentWindowController = WindowController(appDelegate: self, rootView: PaymentView())

// MARK: - Start up

// Do an initialization of all displays
interfaceController.updatePause()
interfaceController.hideDisplays()

#if DEBUG
// Testing
testing = Testing(appDelegate: self)
#endif
}

// ======================== App Stop 🛑 ============================

func applicationWillTerminate(_ aNotification: Notification) {
interactionController.monitorKeyPress?.stop()
interactionController.monitorMouseDismiss?.stop()
interactionController.monitorDisplayMouseDrag?.stop()
}

func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
11 changes: 11 additions & 0 deletions Informant/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 5e359af

Please sign in to comment.