|
@@ -1,3 +1,4 @@ |
|
|
|
|
|
#include <SDL.h> |
|
|
#include <bdd-for-c.h> |
|
|
#include <bdd-for-c.h> |
|
|
#include <subprojects/SDL/SDL_keyboard.mock.h> |
|
|
#include <subprojects/SDL/SDL_keyboard.mock.h> |
|
|
#include <subprojects/SDL/SDL_joystick.mock.h> |
|
|
#include <subprojects/SDL/SDL_joystick.mock.h> |
|
@@ -37,11 +38,11 @@ spec("input") { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigInitialize); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigInitialize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("sets initial state") { |
|
|
it("sets initial state") { |
|
@@ -54,13 +55,13 @@ spec("input") { |
|
|
it("calls load method") { |
|
|
it("calls load method") { |
|
|
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigInitialize), "Config load function not called."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_JoystickInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("opens device handles") { |
|
|
it("opens device handles") { |
|
@@ -327,7 +328,7 @@ spec("input") { |
|
|
static IZ_JoystickState state[IZ_PLAYERS]; |
|
|
static IZ_JoystickState state[IZ_PLAYERS]; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
before_each() { |
|
|
before_each() { |
|
@@ -341,7 +342,7 @@ spec("input") { |
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_JoystickSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
IZ_JoystickSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -383,11 +384,11 @@ spec("input") { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigInitialize); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigInitialize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
before_each() { |
|
|
before_each() { |
|
@@ -407,13 +408,13 @@ spec("input") { |
|
|
it("calls load method") { |
|
|
it("calls load method") { |
|
|
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigInitialize), "Config load function not called."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_KeyboardInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -459,7 +460,7 @@ spec("input") { |
|
|
static IZ_KeyboardState state[IZ_PLAYERS] = {}; |
|
|
static IZ_KeyboardState state[IZ_PLAYERS] = {}; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
before_each() { |
|
|
before_each() { |
|
@@ -473,7 +474,7 @@ spec("input") { |
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_KeyboardSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
IZ_KeyboardSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -495,19 +496,19 @@ spec("input") { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigInitialize); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigInitialize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigInitialize); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigInitialize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("sets initial state") { |
|
|
it("sets initial state") { |
|
@@ -520,13 +521,13 @@ spec("input") { |
|
|
it("calls load method") { |
|
|
it("calls load method") { |
|
|
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigInitialize), "Config load function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigInitialize), "Config load function not called."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
IZ_MIDIInputInitialize(&state, IZ_CONFIG_GAME_PATH, 0, NULL); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("opens device handles") { |
|
|
it("opens device handles") { |
|
@@ -547,17 +548,17 @@ spec("input") { |
|
|
static IZ_MIDIInputState state[IZ_PLAYERS]; |
|
|
static IZ_MIDIInputState state[IZ_PLAYERS]; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(IZ_ConfigSave); |
|
|
|
|
|
|
|
|
mock_reset(INI_ConfigSave); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
IZ_MIDIInputSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
IZ_MIDIInputSaveConfig(&state, IZ_CONFIG_GAME_PATH); |
|
|
|
|
|
|
|
|
check(mock_is_called(IZ_ConfigSave), "Config save function not called."); |
|
|
|
|
|
|
|
|
check(mock_is_called(INI_ConfigSave), "Config save function not called."); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -570,7 +571,7 @@ spec("input") { |
|
|
describe("on player %u", p) { |
|
|
describe("on player %u", p) { |
|
|
for (u8 i = 0; i < IZ_CONTROLS; i += 1) { |
|
|
for (u8 i = 0; i < IZ_CONTROLS; i += 1) { |
|
|
it("handles %s action activation", IZ_ACTION_NAMES[i]) { |
|
|
it("handles %s action activation", IZ_ACTION_NAMES[i]) { |
|
|
e.message = IZ_MIDI_NOTE_ON | (IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i] << 8); |
|
|
|
|
|
|
|
|
e.message = MIDI_MESSAGE_NOTEON | (IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i] << 8); |
|
|
state[p].config.control_mapping[i] = IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i]; |
|
|
state[p].config.control_mapping[i] = IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i]; |
|
|
action[p] = 0; |
|
|
action[p] = 0; |
|
|
|
|
|
|
|
@@ -582,7 +583,7 @@ spec("input") { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
it("handles %s action deactivation", IZ_ACTION_NAMES[i]) { |
|
|
it("handles %s action deactivation", IZ_ACTION_NAMES[i]) { |
|
|
e.message = IZ_MIDI_NOTE_OFF | (IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i] << 8); |
|
|
|
|
|
|
|
|
e.message = MIDI_MESSAGE_NOTEOFF | (IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i] << 8); |
|
|
state[p].config.control_mapping[i] = IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i]; |
|
|
state[p].config.control_mapping[i] = IZ_MIDI_INPUT_DEFAULT_STATE[p].config.control_mapping[i]; |
|
|
action[p] = ~0; |
|
|
action[p] = ~0; |
|
|
|
|
|
|
|
|