Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions Click2Minimize.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,31 @@
21B199F72CFF981D00EA628D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 21B199F62CFF981D00EA628D /* Assets.xcassets */; };
21B19A052CFF9D1300EA628D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 21B19A042CFF9D1300EA628D /* AppDelegate.swift */; };
21E5E2E72D009E7E00B51E70 /* Accessibility.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 21E5E2E62D009E7E00B51E70 /* Accessibility.framework */; };
4B07C6A99FCD498CBE385CBA /* AppDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F84BFCE563994B3D15BB94B /* AppDelegateTests.swift */; };
503F200104A877F9B37B3E9B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 918D4F75C6AB434D34149873 /* Cocoa.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
1C397C6DE342A22463B79EC7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 21B199E72CFF981C00EA628D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 21B199EE2CFF981C00EA628D;
remoteInfo = Click2Minimize;
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1855DA84FAD6FD7ECD654AC2 /* Click2MinimizeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Click2MinimizeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
21498BA72D00A20600EE1BF3 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
21B199EF2CFF981C00EA628D /* Click2Minimize.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Click2Minimize.app; sourceTree = BUILT_PRODUCTS_DIR; };
21B199F62CFF981D00EA628D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
21B199FB2CFF981D00EA628D /* Click2Minimize.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Click2Minimize.entitlements; sourceTree = "<group>"; };
21B19A042CFF9D1300EA628D /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
21B19A082D009C6E00EA628D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
21E5E2E62D009E7E00B51E70 /* Accessibility.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accessibility.framework; path = System/Library/Frameworks/Accessibility.framework; sourceTree = SDKROOT; };
5F84BFCE563994B3D15BB94B /* AppDelegateTests.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AppDelegateTests.swift; sourceTree = "<group>"; };
918D4F75C6AB434D34149873 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -32,6 +47,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
DCBA5BDE72764A4885C28C61 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
503F200104A877F9B37B3E9B /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -41,13 +64,15 @@
21B199F12CFF981C00EA628D /* Click2Minimize */,
21B199F02CFF981C00EA628D /* Products */,
21E5E2E52D009E7E00B51E70 /* Frameworks */,
833F4FD9F497062AAFF19C6E /* Click2MinimizeTests */,
);
sourceTree = "<group>";
};
21B199F02CFF981C00EA628D /* Products */ = {
isa = PBXGroup;
children = (
21B199EF2CFF981C00EA628D /* Click2Minimize.app */,
1855DA84FAD6FD7ECD654AC2 /* Click2MinimizeTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -68,10 +93,28 @@
isa = PBXGroup;
children = (
21E5E2E62D009E7E00B51E70 /* Accessibility.framework */,
73F2E3C67E4630FADF799558 /* OS X */,
);
name = Frameworks;
sourceTree = "<group>";
};
73F2E3C67E4630FADF799558 /* OS X */ = {
isa = PBXGroup;
children = (
918D4F75C6AB434D34149873 /* Cocoa.framework */,
);
name = "OS X";
sourceTree = "<group>";
};
833F4FD9F497062AAFF19C6E /* Click2MinimizeTests */ = {
isa = PBXGroup;
children = (
5F84BFCE563994B3D15BB94B /* AppDelegateTests.swift */,
);
name = Click2MinimizeTests;
path = Click2MinimizeTests;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -92,6 +135,24 @@
productReference = 21B199EF2CFF981C00EA628D /* Click2Minimize.app */;
productType = "com.apple.product-type.application";
};
89021AA91183EF9FBC4839AD /* Click2MinimizeTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = EFBE146066FD6070E2ACF6F9 /* Build configuration list for PBXNativeTarget "Click2MinimizeTests" */;
buildPhases = (
FA54C4570056119BF3738D03 /* Sources */,
DCBA5BDE72764A4885C28C61 /* Frameworks */,
1D59EA7765C219640FE0B626 /* Resources */,
);
buildRules = (
);
dependencies = (
E517EB6E2D917BC87C7B2876 /* PBXTargetDependency */,
);
name = Click2MinimizeTests;
productName = Click2MinimizeTests;
productReference = 1855DA84FAD6FD7ECD654AC2 /* Click2MinimizeTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand Down Expand Up @@ -121,11 +182,19 @@
projectRoot = "";
targets = (
21B199EE2CFF981C00EA628D /* Click2Minimize */,
89021AA91183EF9FBC4839AD /* Click2MinimizeTests */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
1D59EA7765C219640FE0B626 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
21B199ED2CFF981C00EA628D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -146,8 +215,25 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
FA54C4570056119BF3738D03 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4B07C6A99FCD498CBE385CBA /* AppDelegateTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
E517EB6E2D917BC87C7B2876 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = Click2Minimize;
target = 21B199EE2CFF981C00EA628D /* Click2Minimize */;
targetProxy = 1C397C6DE342A22463B79EC7 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
21B199FC2CFF981D00EA628D /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -282,6 +368,7 @@
DEVELOPMENT_TEAM = AMWSZNUAX5;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
ENABLE_TESTABILITY = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Click2Minimize/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Click2Minimize;
Expand Down Expand Up @@ -316,6 +403,7 @@
DEVELOPMENT_TEAM = AMWSZNUAX5;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
ENABLE_TESTABILITY = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Click2Minimize/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Click2Minimize;
Expand All @@ -335,6 +423,34 @@
};
name = Release;
};
450FE0366CBD348F2111815B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ENABLE_TESTABILITY = YES;
ENABLE_TESTING_SEARCH_PATHS = YES;
GENERATE_INFOPLIST_FILE = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.click2minimize.Click2MinimizeTests;
SDKROOT = macosx;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Click2Minimize.app/Contents/MacOS/Click2Minimize";
};
name = Release;
};
D5844C4E4BA489452E4DEC16 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ENABLE_TESTABILITY = YES;
ENABLE_TESTING_SEARCH_PATHS = YES;
GENERATE_INFOPLIST_FILE = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.click2minimize.Click2MinimizeTests;
SDKROOT = macosx;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Click2Minimize.app/Contents/MacOS/Click2Minimize";
};
name = Debug;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand All @@ -356,6 +472,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EFBE146066FD6070E2ACF6F9 /* Build configuration list for PBXNativeTarget "Click2MinimizeTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
450FE0366CBD348F2111815B /* Release */,
D5844C4E4BA489452E4DEC16 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 21B199E72CFF981C00EA628D /* Project object */;
Expand Down
67 changes: 67 additions & 0 deletions Click2MinimizeTests/AppDelegateTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import XCTest
@testable import Click2Minimize

class AppDelegateTests: XCTestCase {
var appDelegate: AppDelegate!

override func setUp() {
super.setUp()
appDelegate = AppDelegate()

// Reset UserDefaults for isolated testing
if let bundleID = Bundle.main.bundleIdentifier {
UserDefaults.standard.removePersistentDomain(forName: bundleID)
}
}

override func tearDown() {
appDelegate = nil
if let bundleID = Bundle.main.bundleIdentifier {
UserDefaults.standard.removePersistentDomain(forName: bundleID)
}
super.tearDown()
}

func testUpdateClickToHideState_EnablesState() {
// Arrange
let notification = Notification(name: NSNotification.Name("ClickToHideStateChanged"), object: true)

// Act
appDelegate.updateClickToHideState(notification)

// Assert
XCTAssertTrue(appDelegate.isClickToMinimizeEnabled)
XCTAssertTrue(UserDefaults.standard.bool(forKey: "ClickToMinimizeEnabled"))
}

func testUpdateClickToHideState_DisablesState() {
// Arrange
// Set initial state to true to ensure it actually changes to false
appDelegate.isClickToMinimizeEnabled = true
UserDefaults.standard.set(true, forKey: "ClickToMinimizeEnabled")

let notification = Notification(name: NSNotification.Name("ClickToHideStateChanged"), object: false)

// Act
appDelegate.updateClickToHideState(notification)

// Assert
XCTAssertFalse(appDelegate.isClickToMinimizeEnabled)
XCTAssertFalse(UserDefaults.standard.bool(forKey: "ClickToMinimizeEnabled"))
}

func testUpdateClickToHideState_InvalidObject() {
// Arrange
appDelegate.isClickToMinimizeEnabled = true
UserDefaults.standard.set(true, forKey: "ClickToMinimizeEnabled")

let notification = Notification(name: NSNotification.Name("ClickToHideStateChanged"), object: "Not a boolean")

// Act
appDelegate.updateClickToHideState(notification)

// Assert - state should remain unchanged
XCTAssertTrue(appDelegate.isClickToMinimizeEnabled)
XCTAssertTrue(UserDefaults.standard.bool(forKey: "ClickToMinimizeEnabled"))
}
}