|
@@ -1,15 +1,14 @@ |
|
|
#include "../../../__mocks__/SDL_keyboard.mock.h" |
|
|
#include "../../../__mocks__/SDL_keyboard.mock.h" |
|
|
#include "../../../__mocks__/SDL_joystick.mock.h" |
|
|
#include "../../../__mocks__/SDL_joystick.mock.h" |
|
|
#include "../../../__mocks__/minIni.mock.h" |
|
|
#include "../../../__mocks__/minIni.mock.h" |
|
|
#include "../__mocks__/IZ_config.mock.h" |
|
|
|
|
|
#include "IZ_keyboard.h" |
|
|
#include "IZ_keyboard.h" |
|
|
#include "IZ_joystick.h" |
|
|
#include "IZ_joystick.h" |
|
|
|
|
|
|
|
|
short int GenerateAxisValueWithinThreshold(short int threshold) { |
|
|
|
|
|
|
|
|
int16_t GenerateAxisValueWithinThreshold(uint16_t threshold) { |
|
|
return rand() % threshold; |
|
|
return rand() % threshold; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
short int GenerateAxisValueOutsideThreshold(short int threshold) { |
|
|
|
|
|
|
|
|
int16_t GenerateAxisValueOutsideThreshold(uint16_t threshold) { |
|
|
return threshold + (rand() % (RAND_MAX - threshold - 1)) + 1; |
|
|
return threshold + (rand() % (RAND_MAX - threshold - 1)) + 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -23,7 +22,7 @@ spec("input") { |
|
|
describe("on axis motion events") { |
|
|
describe("on axis motion events") { |
|
|
before_each() { |
|
|
before_each() { |
|
|
e.type = SDL_JOYAXISMOTION; |
|
|
e.type = SDL_JOYAXISMOTION; |
|
|
state.config.axis_threshold = 8000; |
|
|
|
|
|
|
|
|
state.config.axis_threshold = 8000u; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
describe("on primary horizontal direction") { |
|
|
describe("on primary horizontal direction") { |
|
@@ -259,10 +258,6 @@ spec("input") { |
|
|
describe("LoadJoystickConfig") { |
|
|
describe("LoadJoystickConfig") { |
|
|
static IZ_JoystickConfig config; |
|
|
static IZ_JoystickConfig config; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
mock_reset(IZ_GetConfigPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(ini_getl); |
|
|
mock_reset(ini_getl); |
|
|
} |
|
|
} |
|
@@ -270,12 +265,7 @@ spec("input") { |
|
|
it("calls load method") { |
|
|
it("calls load method") { |
|
|
mock_set_expected_calls(ini_getl, CONTROLS - 4 + 1); |
|
|
mock_set_expected_calls(ini_getl, CONTROLS - 4 + 1); |
|
|
|
|
|
|
|
|
IZ_LoadJoystickConfig(&config, 0); |
|
|
|
|
|
|
|
|
|
|
|
check( |
|
|
|
|
|
mock_is_called(IZ_GetConfigPath), |
|
|
|
|
|
"SDL_GetBasePath() not called." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
IZ_LoadJoystickConfig("config.ini", &config, 0); |
|
|
|
|
|
|
|
|
check( |
|
|
check( |
|
|
mock_get_expected_calls(ini_getl) == mock_get_actual_calls(ini_getl), |
|
|
mock_get_expected_calls(ini_getl) == mock_get_actual_calls(ini_getl), |
|
@@ -289,10 +279,6 @@ spec("input") { |
|
|
describe("SaveJoystickConfig") { |
|
|
describe("SaveJoystickConfig") { |
|
|
static IZ_JoystickConfig config; |
|
|
static IZ_JoystickConfig config; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
mock_reset(IZ_GetConfigPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(ini_putl); |
|
|
mock_reset(ini_putl); |
|
|
} |
|
|
} |
|
@@ -306,7 +292,7 @@ spec("input") { |
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
mock_set_expected_calls(ini_putl, CONTROLS - 4 + 1); |
|
|
mock_set_expected_calls(ini_putl, CONTROLS - 4 + 1); |
|
|
|
|
|
|
|
|
IZ_SaveJoystickConfig(&config, 0); |
|
|
|
|
|
|
|
|
IZ_SaveJoystickConfig("config.ini", &config, 0); |
|
|
|
|
|
|
|
|
check( |
|
|
check( |
|
|
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl), |
|
|
mock_get_expected_calls(ini_putl) == mock_get_actual_calls(ini_putl), |
|
@@ -356,10 +342,6 @@ spec("input") { |
|
|
describe("LoadKeyboardConfig") { |
|
|
describe("LoadKeyboardConfig") { |
|
|
static IZ_KeyboardConfig config; |
|
|
static IZ_KeyboardConfig config; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
mock_reset(IZ_GetConfigPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(ini_gets); |
|
|
mock_reset(ini_gets); |
|
|
} |
|
|
} |
|
@@ -367,12 +349,7 @@ spec("input") { |
|
|
it("calls load method") { |
|
|
it("calls load method") { |
|
|
mock_set_expected_calls(ini_gets, CONTROLS); |
|
|
mock_set_expected_calls(ini_gets, CONTROLS); |
|
|
|
|
|
|
|
|
IZ_LoadKeyboardConfig(&config, 0); |
|
|
|
|
|
|
|
|
|
|
|
check( |
|
|
|
|
|
mock_is_called(IZ_GetConfigPath), |
|
|
|
|
|
"SDL_GetBasePath() not called." |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
IZ_LoadKeyboardConfig("config.ini", &config, 0); |
|
|
|
|
|
|
|
|
check( |
|
|
check( |
|
|
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets), |
|
|
mock_get_expected_calls(ini_gets) == mock_get_actual_calls(ini_gets), |
|
@@ -386,10 +363,6 @@ spec("input") { |
|
|
describe("SaveKeyboardConfig") { |
|
|
describe("SaveKeyboardConfig") { |
|
|
static IZ_KeyboardConfig config; |
|
|
static IZ_KeyboardConfig config; |
|
|
|
|
|
|
|
|
after_each() { |
|
|
|
|
|
mock_reset(IZ_GetConfigPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
after_each() { |
|
|
after_each() { |
|
|
mock_reset(ini_puts); |
|
|
mock_reset(ini_puts); |
|
|
} |
|
|
} |
|
@@ -403,7 +376,7 @@ spec("input") { |
|
|
it("calls save method") { |
|
|
it("calls save method") { |
|
|
mock_set_expected_calls(ini_puts, CONTROLS); |
|
|
mock_set_expected_calls(ini_puts, CONTROLS); |
|
|
|
|
|
|
|
|
IZ_SaveKeyboardConfig(&config, 0); |
|
|
|
|
|
|
|
|
IZ_SaveKeyboardConfig("config.ini", &config, 0); |
|
|
|
|
|
|
|
|
check( |
|
|
check( |
|
|
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts), |
|
|
mock_get_expected_calls(ini_puts) == mock_get_actual_calls(ini_puts), |
|
|