diff options
| -rw-r--r-- | Framework/MASHotKeyTests.m | 15 | ||||
| -rw-r--r-- | Framework/MASShortcutMonitorTests.m | 23 | ||||
| -rw-r--r-- | MASShortcut.xcodeproj/project.pbxproj | 8 | 
3 files changed, 46 insertions, 0 deletions
| diff --git a/Framework/MASHotKeyTests.m b/Framework/MASHotKeyTests.m new file mode 100644 index 0000000..65361ab --- /dev/null +++ b/Framework/MASHotKeyTests.m @@ -0,0 +1,15 @@ +#import "MASHotKey.h" + +@interface MASHotKeyTests : XCTestCase +@end + +@implementation MASHotKeyTests + +- (void) testBasicFunctionality +{ +    MASHotKey *hotKey = [MASHotKey registeredHotKeyWithShortcut: +        [MASShortcut shortcutWithKeyCode:kVK_ANSI_H modifierFlags:NSCommandKeyMask|NSAlternateKeyMask]]; +    XCTAssertNotNil(hotKey, @"Register a simple Cmd-Alt-H hotkey."); +} + +@end diff --git a/Framework/MASShortcutMonitorTests.m b/Framework/MASShortcutMonitorTests.m new file mode 100644 index 0000000..ccdcaef --- /dev/null +++ b/Framework/MASShortcutMonitorTests.m @@ -0,0 +1,23 @@ +#import "MASShortcutMonitor.h" + +@interface MASShortcutMonitorTests : XCTestCase +@end + +@implementation MASShortcutMonitorTests + +- (void) testMonitorCreation +{ +    XCTAssertNotNil([MASShortcutMonitor sharedMonitor], @"Create a shared shortcut monitor."); +} + +- (void) testShortcutRegistration +{ +    MASShortcutMonitor *monitor = [MASShortcutMonitor sharedMonitor]; +    MASShortcut *shortcut = [MASShortcut shortcutWithKeyCode:kVK_ANSI_H modifierFlags:NSCommandKeyMask|NSAlternateKeyMask]; +    XCTAssertTrue([monitor registerShortcut:shortcut withAction:NULL], @"Register a shortcut."); +    XCTAssertTrue([monitor isShortcutRegistered:shortcut], @"Remember a previously registered shortcut."); +    [monitor unregisterShortcut:shortcut]; +    XCTAssertFalse([monitor isShortcutRegistered:shortcut], @"Forget shortcut after unregistering."); +} + +@end diff --git a/MASShortcut.xcodeproj/project.pbxproj b/MASShortcut.xcodeproj/project.pbxproj index 41b78d1..ea5125c 100644 --- a/MASShortcut.xcodeproj/project.pbxproj +++ b/MASShortcut.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@  	objects = {  /* Begin PBXBuildFile section */ +		0D39DCA21A668A4400639145 /* MASHotKeyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D39DCA11A668A4400639145 /* MASHotKeyTests.m */; }; +		0D39DCA41A668E5500639145 /* MASShortcutMonitorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D39DCA31A668E5500639145 /* MASShortcutMonitorTests.m */; };  		0D827CD71990D4420010B8EF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D827CD61990D4420010B8EF /* Cocoa.framework */; };  		0D827D251990D55E0010B8EF /* MASShortcut.h in Headers */ = {isa = PBXBuildFile; fileRef = 0D827D1B1990D55E0010B8EF /* MASShortcut.h */; settings = {ATTRIBUTES = (Public, ); }; };  		0D827D261990D55E0010B8EF /* MASShortcut.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D827D1C1990D55E0010B8EF /* MASShortcut.m */; }; @@ -64,6 +66,8 @@  /* End PBXCopyFilesBuildPhase section */  /* Begin PBXFileReference section */ +		0D39DCA11A668A4400639145 /* MASHotKeyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MASHotKeyTests.m; path = Framework/MASHotKeyTests.m; sourceTree = "<group>"; }; +		0D39DCA31A668E5500639145 /* MASShortcutMonitorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MASShortcutMonitorTests.m; path = Framework/MASShortcutMonitorTests.m; sourceTree = "<group>"; };  		0D827CD31990D4420010B8EF /* MASShortcut.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MASShortcut.framework; sourceTree = BUILT_PRODUCTS_DIR; };  		0D827CD61990D4420010B8EF /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };  		0D827CD91990D4420010B8EF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -231,8 +235,10 @@  			children = (  				0DC2F17419922798003A0131 /* MASHotKey.h */,  				0DC2F17519922798003A0131 /* MASHotKey.m */, +				0D39DCA11A668A4400639145 /* MASHotKeyTests.m */,  				0D827DA319912D240010B8EF /* MASShortcutMonitor.h */,  				0D827DA419912D240010B8EF /* MASShortcutMonitor.m */, +				0D39DCA31A668E5500639145 /* MASShortcutMonitorTests.m */,  			);  			name = Monitoring;  			sourceTree = "<group>"; @@ -419,6 +425,8 @@  				0DC2F190199372B4003A0131 /* MASDictionaryTransformerTests.m in Sources */,  				0D827D9419910B740010B8EF /* MASShortcutTests.m in Sources */,  				0DC2F18919925F8F003A0131 /* MASShortcutBinderTests.m in Sources */, +				0D39DCA21A668A4400639145 /* MASHotKeyTests.m in Sources */, +				0D39DCA41A668E5500639145 /* MASShortcutMonitorTests.m in Sources */,  			);  			runOnlyForDeploymentPostprocessing = 0;  		}; | 
