Skip to content

Commit

Permalink
Formatting + Dropping Hotkey Demo App.
Browse files Browse the repository at this point in the history
  • Loading branch information
n0shake committed Jul 7, 2021
1 parent a476616 commit 3b453de
Show file tree
Hide file tree
Showing 21 changed files with 122 additions and 94 deletions.
14 changes: 7 additions & 7 deletions Clocker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import FirebaseCore
import FirebaseCrashlytics

open class AppDelegate: NSObject, NSApplicationDelegate {
private lazy var floatingWindow: FloatingWindowController = FloatingWindowController.shared()
private lazy var panelController: PanelController = PanelController.shared()
private lazy var floatingWindow = FloatingWindowController.shared()
private lazy var panelController = PanelController.shared()
private var statusBarHandler: StatusItemHandler!
private var panelObserver: NSKeyValueObservation?

deinit {
panelObserver?.invalidate()
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change _: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
if let path = keyPath, path == PreferencesConstants.hotKeyPathIdentifier {
let hotKeyCenter = PTHotKeyCenter.shared()

Expand All @@ -30,10 +30,10 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
}

// Register new key
let newHotKey: PTHotKey = PTHotKey(identifier: keyPath,
keyCombo: newShortcut,
target: self,
action: #selector(ping(_:)))
let newHotKey = PTHotKey(identifier: keyPath,
keyCombo: newShortcut,
target: self,
action: #selector(ping(_:)))

hotKeyCenter?.register(newHotKey)
}
Expand Down
38 changes: 15 additions & 23 deletions Clocker/Clocker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
3531F7F126936DE900DF0111 /* upload-symbols in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7EC26936DE900DF0111 /* upload-symbols */; };
3531F7F226936DE900DF0111 /* upload-symbols in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7EC26936DE900DF0111 /* upload-symbols */; };
3531F7F52693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; };
3531F7F62693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; };
3531F7F72693882300DF0111 /* Keys.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3531F7F42693882300DF0111 /* Keys.plist */; };
3531F80626938D7700DF0111 /* GoogleUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3531F7FC26938D7600DF0111 /* GoogleUtilities.framework */; };
3531F80726938D7700DF0111 /* GoogleUtilities.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3531F7FC26938D7600DF0111 /* GoogleUtilities.framework */; };
Expand Down Expand Up @@ -216,13 +215,6 @@
remoteGlobalIDString = E273122E1349EC9000A84433;
remoteInfo = PTHotKey.framework;
};
9A86E2BF1CE04F1600547EE7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 9A86E2B51CE04F1600547EE7 /* ShortcutRecorder.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 0D6B2468180304DE00CE1142;
remoteInfo = Demo;
};
C20839CC21515C1F00C86589 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DD4F7BFB13C30F9F00825C6E /* Project object */;
Expand Down Expand Up @@ -769,7 +761,6 @@
children = (
9A86E2BC1CE04F1600547EE7 /* ShortcutRecorder.framework */,
9A86E2BE1CE04F1600547EE7 /* PTHotKey.framework */,
9A86E2C01CE04F1600547EE7 /* Demo.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -842,6 +833,14 @@
path = Frameworks;
sourceTree = "<group>";
};
9AEF66812693A6270036142F /* Recovered References */ = {
isa = PBXGroup;
children = (
3531F7F42693882300DF0111 /* Keys.plist */,
);
name = "Recovered References";
sourceTree = "<group>";
};
C2021B89219F30960036C247 /* Onboarding */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -916,6 +915,7 @@
3531F7EC26936DE900DF0111 /* upload-symbols */,
3531F7C026936C6E00DF0111 /* GoogleService-Info.plist */,
DD4F7C0513C30F9F00825C6E /* Products */,
9AEF66812693A6270036142F /* Recovered References */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -1032,7 +1032,6 @@
DD4F7C0213C30F9F00825C6E /* Resources */,
9A20A0711C4E808500FB45AB /* Login Item Helper */,
9A5E75EC204CC39700119939 /* Embed Frameworks */,
C2A632A020EAC5EE00EB6BEA /* SwiftFormat */,
3531F7F326936F5000DF0111 /* ShellScript */,
);
buildRules = (
Expand Down Expand Up @@ -1156,13 +1155,6 @@
remoteRef = 9A86E2BD1CE04F1600547EE7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
9A86E2C01CE04F1600547EE7 /* Demo.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = Demo.app;
remoteRef = 9A86E2BF1CE04F1600547EE7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
Expand Down Expand Up @@ -1559,7 +1551,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 94;
CURRENT_PROJECT_VERSION = 95;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1592,7 +1584,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 21.07.01;
MARKETING_VERSION = 21.07.02;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = com.abhishek.Clocker;
Expand Down Expand Up @@ -2128,7 +2120,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 94;
CURRENT_PROJECT_VERSION = 95;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -2162,7 +2154,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 21.07.01;
MARKETING_VERSION = 21.07.02;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
"OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG";
Expand Down Expand Up @@ -2210,7 +2202,7 @@
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 94;
CURRENT_PROJECT_VERSION = 95;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -2243,7 +2235,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 21.07.01;
MARKETING_VERSION = 21.07.02;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
"OTHER_SWIFT_FLAGS[arch=*]" = "-D RELEASE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
endingColumnNumber = "9223372036854775807"
startingLineNumber = "47"
endingLineNumber = "47"
landmarkName = "geocodingKey"
landmarkType = "24">
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
Expand Down
2 changes: 1 addition & 1 deletion Clocker/ClockerUITests/AboutUsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AboutUsTests: XCTestCase {
tapAboutTab()

let appDisplayName = "CFBundleDisplayName".localizedString()
let expectedVersion = "\(appDisplayName) 21.07.01 (93)"
let expectedVersion = "\(appDisplayName) 21.07.02 (95)"

guard let presentVersion = app.windows["Clocker"].staticTexts["ClockerVersion"].value as? String else {
XCTFail("Present version not present")
Expand Down
46 changes: 36 additions & 10 deletions Clocker/ClockerUITests/CopyToClipboardTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import XCTest

class CopyToClipboardTests: XCTestCase {
var app: XCUIApplication!

override func setUp() {
continueAfterFailure = false
app = XCUIApplication()
app.launch()

if app.tables["FloatingTableView"].exists == false {
app.tapMenubarIcon()
app.buttons["Pin"].click()
}
// if app.tables["FloatingTableView"].exists == false {
// app.tapMenubarIcon()
// app.buttons["Pin"].click()
// }
}

override func tearDownWithError() throws {
Expand All @@ -23,20 +23,20 @@ class CopyToClipboardTests: XCTestCase {
func testFullCopy() throws {
let cellCount = app.tables["FloatingTableView"].cells.count
var clipboardValue = String()
for cellIndex in 0..<cellCount {
for cellIndex in 0 ..< cellCount {
let cell = app.tables["FloatingTableView"].cells.element(boundBy: cellIndex)
let customLabel = cell.staticTexts["CustomNameLabelForCell"].value ?? "Nil Custom Label"
let time = cell.staticTexts["ActualTime"].value ?? "Nil Value"
clipboardValue.append(contentsOf: "\(customLabel) - \(time)\n")
}

app.buttons["Share"].click()
app/*@START_MENU_TOKEN@*/.menuItems["Copy All Times"]/*[[".dialogs[\"Clocker Panel\"]",".buttons[\"Share\"]",".menus.menuItems[\"Copy All Times\"]",".menuItems[\"Copy All Times\"]"],[[[-1,3],[-1,2],[-1,1,2],[-1,0,1]],[[-1,3],[-1,2],[-1,1,2]],[[-1,3],[-1,2]]],[0]]@END_MENU_TOKEN@*/.click()
app/*@START_MENU_TOKEN@*/ .menuItems["Copy All Times"]/*[[".dialogs[\"Clocker Panel\"]",".buttons[\"Share\"]",".menus.menuItems[\"Copy All Times\"]",".menuItems[\"Copy All Times\"]"],[[[-1,3],[-1,2],[-1,1,2],[-1,0,1]],[[-1,3],[-1,2],[-1,1,2]],[[-1,3],[-1,2]]],[0]]@END_MENU_TOKEN@*/ .click()

let clipboard = NSPasteboard.general.string(forType: .string)
XCTAssert(clipboardValue == clipboard)
}

func testIndividualTimezoneCopy() {
let cell = app.tables["FloatingTableView"].cells.firstMatch
let customLabel = cell.staticTexts["CustomNameLabelForCell"].value ?? "Nil Custom Label"
Expand All @@ -45,9 +45,35 @@ class CopyToClipboardTests: XCTestCase {

// Tap to copy!
cell.tap()

let clipboard = NSPasteboard.general.string(forType: .string) ?? "Empty Pasteboard"
XCTAssert(expectedValue == clipboard, "Clipboard value (\(clipboard)) doesn't match expected result")
}

func testModernSlider() {
if app.buttons["FloatingPin"].exists {
app.buttons["FloatingPin"].click()
}

app.tapMenubarIcon()
let modernSliderExists = app.collectionViews["ModernSlider"].exists
app.buttons["Preferences"].click()

let appearanceTab = app.toolbars.buttons.element(boundBy: 1)
appearanceTab.click()

let miscTab = app.tabs.element(boundBy: 1)
miscTab.click()

if modernSliderExists {
app.radioGroups["FutureSlider"].radioButtons["Legacy"].click()
} else {
app.radioGroups["FutureSlider"].radioButtons["Modern"].click()
}

app.tapMenubarIcon()

let newFloatingSliderExists = app.collectionViews["ModernSlider"].exists
XCTAssertNotEqual(newFloatingSliderExists, modernSliderExists)
}
}
2 changes: 1 addition & 1 deletion Clocker/ClockerUITests/FloatingWindowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FloatingWindowTests: XCTestCase {
app.buttons["Pin"].click()
}

addUIInterruptionMonitor(withDescription: "Reminders Access") { (alert) -> Bool in
addUIInterruptionMonitor(withDescription: "Reminders Access") { alert -> Bool in
let alertButton = alert.buttons["OK"]
if alertButton.exists {
alertButton.tap()
Expand Down
8 changes: 4 additions & 4 deletions Clocker/ClockerUITests/PreferencesTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PreferencesTest: XCTestCase {
return
}

app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.click()
app.windows["Clocker"].tables["TimezoneTableView"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).click()

XCTAssertTrue(app.checkBoxes["DeleteTimezone"].isEnabled)
}
Expand Down Expand Up @@ -334,7 +334,7 @@ class PreferencesTest: XCTestCase {

if rowQueryCount > 0 {
// Table Rows aren't hittable in Xcode 12.0 (10/7/20) and so we need to find a closer co-ordinate and perform click()
let currentElement = clockerWindow.tables["TimezoneTableView"].tableRows.firstMatch
let currentElement = clockerWindow.tables["TimezoneTableView"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
currentElement.click()

for _ in 0 ..< rowQueryCount {
Expand Down Expand Up @@ -416,7 +416,7 @@ extension XCTestCase {
return
}

let currentElement = app.windows["Clocker"].tableRows.firstMatch
let currentElement = app.windows["Clocker"].tableRows.firstMatch.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
currentElement.click()

while rowQueryCount > 0 {
Expand All @@ -442,7 +442,7 @@ extension XCTestCase {
}

private func deleteAtRow(_ rowToDelete: XCUIElement, for _: XCUIApplication, shouldSleep: Bool) {
rowToDelete.click()
rowToDelete.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).click()
rowToDelete.typeKey(XCUIKeyboardKey.delete, modifierFlags: XCUIElement.KeyModifierFlags())
if shouldSleep {
sleep(2)
Expand Down
9 changes: 5 additions & 4 deletions Clocker/ClockerUnitTests/ClockerUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ class ClockerUnitTests: XCTestCase {
let timezone = TimezoneData.customObject(from: $0)
return timezone?.placeID == "TestIdentifier"
}

// California is absent. Add it!
if filteredCount.count == 0 {
let timezoneData = TimezoneData(with: california)
let operationsObject = TimezoneDataOperations(with: timezoneData)
operationsObject.saveObject()
}

let oldCount = (defaults.object(forKey: CLDefaultPreferenceKey) as? [Data])?.count ?? 0

currentFavourites = currentFavourites.filter {
let timezone = TimezoneData.customObject(from: $0)
return timezone?.placeID != "TestIdentifier"
Expand Down Expand Up @@ -288,7 +288,8 @@ class ClockerUnitTests: XCTestCase {
guard let newDate = cal?.date(byAdding: .minute,
value: 0,
to: Date(),
options: .matchFirst) else {
options: .matchFirst)
else {
XCTFail("Unable to add dates!")
return
}
Expand Down
Loading

0 comments on commit 3b453de

Please sign in to comment.