Skip to content

Commit

Permalink
Issue #249: Add (failing) tests for conversion of polyphonic key pres…
Browse files Browse the repository at this point in the history
…sure and channel pressure events to commands.
  • Loading branch information
armadsen committed Apr 8, 2018
1 parent bc623e9 commit 2889317
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
55 changes: 55 additions & 0 deletions Framework/MIKMIDI Tests/MIKMIDIChannelEventTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// MIKMIDIChannelEventTests.m
// MIKMIDI Tests
//
// Created by Andrew R Madsen on 4/8/18.
// Copyright © 2018 Mixed In Key. All rights reserved.
//

#import <XCTest/XCTest.h>
#import <MIKMIDI/MIKMIDI.h>

@interface MIKMIDIChannelEventTests : XCTestCase

@end

@implementation MIKMIDIChannelEventTests

- (void)testConvertingPolyphonicKeyPressureEventToCommand
{
MIKMutableMIDIPolyphonicKeyPressureEvent *event = [[MIKMutableMIDIPolyphonicKeyPressureEvent alloc] init];
event.channel = 3;
event.pressure = 42;

XCTAssertEqual(event.channel, 3);
XCTAssertEqual(event.pressure, 42);

MIKMIDIClock *clock = [MIKMIDIClock clock];

MIKMIDIPolyphonicKeyPressureCommand *command = nil;
XCTAssertNoThrow(command = (id)[MIKMIDICommand commandFromChannelEvent:event clock:clock]);
XCTAssertTrue([command isKindOfClass:[MIKMIDIPolyphonicKeyPressureCommand class]]);
XCTAssertNotNil(command);
XCTAssertEqual(command.channel, event.channel);
XCTAssertEqual(command.pressure, event.pressure);
}

- (void)testConvertingChannelPressureEventToCommand
{
MIKMutableMIDIChannelPressureEvent *event = [[MIKMutableMIDIChannelPressureEvent alloc] init];
event.channel = 2;
event.pressure = 27;
XCTAssertEqual(event.channel, 2);
XCTAssertEqual(event.pressure, 27);

MIKMIDIClock *clock = [MIKMIDIClock clock];

MIKMIDIChannelPressureCommand *command = nil;
XCTAssertNoThrow(command = (id)[MIKMIDICommand commandFromChannelEvent:event clock:clock]);
XCTAssertTrue([command isKindOfClass:[MIKMIDIChannelPressureCommand class]]);
XCTAssertNotNil(command);
XCTAssertEqual(command.channel, event.channel);
XCTAssertEqual(command.pressure, event.pressure);
}

@end
4 changes: 4 additions & 0 deletions Framework/MIKMIDI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@
9DE259E519A7B4F800DA93E9 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE259E419A7B4F800DA93E9 /* AudioUnit.framework */; };
9DE259E619A7B50100DA93E9 /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D74EF2D17A7133900BEE89F /* CoreMIDI.framework */; };
9DE259E819A7B50600DA93E9 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DE259E719A7B50600DA93E9 /* AudioToolbox.framework */; };
9DE824A6207AD02000761A07 /* MIKMIDIChannelEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */; };
9DEBD03B1F7085DB00676C42 /* MIKMIDINoteCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
9DEBD03C1F7085DB00676C42 /* MIKMIDINoteCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
9DEBD03D1F7085DB00676C42 /* MIKMIDINoteCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DEBD03A1F7085DB00676C42 /* MIKMIDINoteCommand.m */; };
Expand Down Expand Up @@ -493,6 +494,7 @@
9DCDDB591AB3514100F8347E /* MIKMIDISequencerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDISequencerTests.m; sourceTree = "<group>"; };
9DE259E419A7B4F800DA93E9 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; };
9DE259E719A7B50600DA93E9 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MIKMIDIChannelEventTests.m; sourceTree = "<group>"; };
9DEBD0391F7085DB00676C42 /* MIKMIDINoteCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDINoteCommand.h; sourceTree = "<group>"; };
9DEBD03A1F7085DB00676C42 /* MIKMIDINoteCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIKMIDINoteCommand.m; sourceTree = "<group>"; };
9DEBD0401F708B0E00676C42 /* MIKMIDINoteCommand_SubclassMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIKMIDINoteCommand_SubclassMethods.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -572,6 +574,7 @@
9D0225301CC92ECF0090EAB4 /* MIKMIDIMetaEventTests.m */,
9DCDDB591AB3514100F8347E /* MIKMIDISequencerTests.m */,
9D2ED25E1AFBD062000325CC /* MIKMIDIResponderChainTests.m */,
9DE824A5207AD02000761A07 /* MIKMIDIChannelEventTests.m */,
9D4DF13C1AAB57430065F004 /* Supporting Files */,
9D4DF1501AAB57CD0065F004 /* Resources */,
);
Expand Down Expand Up @@ -1209,6 +1212,7 @@
9D2ED25F1AFBD062000325CC /* MIKMIDIResponderChainTests.m in Sources */,
9D4DF14D1AAB57800065F004 /* MIKMIDISequenceTests.m in Sources */,
9D4DF1541AAB60490065F004 /* MIKMIDITrackTests.m in Sources */,
9DE824A6207AD02000761A07 /* MIKMIDIChannelEventTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 2889317

Please sign in to comment.