From 27eace979e202116e44db3dc6acc9a8427ecaa0a Mon Sep 17 00:00:00 2001 From: Tomáš Znamenáček Date: Wed, 14 Jan 2015 12:54:49 +0100 Subject: Added test for hotkeys and shortcut monitor. --- Framework/MASHotKeyTests.m | 15 +++++++++++++++ Framework/MASShortcutMonitorTests.m | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Framework/MASHotKeyTests.m create mode 100644 Framework/MASShortcutMonitorTests.m (limited to 'Framework') 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 -- cgit v1.2.3