mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
De-duplicate mixer tri and quad integration test setup code.
This commit is contained in:
parent
9f62349191
commit
cfe0d770ac
1 changed files with 35 additions and 51 deletions
|
@ -151,37 +151,53 @@ TEST_F(ChannelForwardingTest, TestForwardAuxChannelsToServosWithLessRemainingSer
|
|||
EXPECT_EQ(1250, servos[MAX_SUPPORTED_SERVOS - 0 - 1].value);
|
||||
}
|
||||
|
||||
class BasicMixerIntegrationTest : public ::testing::Test {
|
||||
protected:
|
||||
mixerConfig_t mixerConfig;
|
||||
rxConfig_t rxConfig;
|
||||
escAndServoConfig_t escAndServoConfig;
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS];
|
||||
gimbalConfig_t gimbalConfig = {
|
||||
.mode = GIMBAL_MODE_NORMAL
|
||||
};
|
||||
|
||||
TEST(FlightMixerTest, TestTricopterServo)
|
||||
{
|
||||
// given
|
||||
motorMixer_t customMixer[MAX_SUPPORTED_MOTORS];
|
||||
servoMixer_t customServoMixer[MAX_SUPPORTED_SERVOS];
|
||||
|
||||
virtual void SetUp() {
|
||||
updatedServoCount = 0;
|
||||
|
||||
mixerConfig_t mixerConfig;
|
||||
memset(&mixerConfig, 0, sizeof(mixerConfig));
|
||||
|
||||
rxConfig_t rxConfig;
|
||||
memset(&rxConfig, 0, sizeof(rxConfig));
|
||||
memset(&escAndServoConfig, 0, sizeof(escAndServoConfig));
|
||||
memset(&servoConf, 0, sizeof(servoConf));
|
||||
|
||||
memset(rcCommand, 0, sizeof(rcCommand));
|
||||
memset(axisPID, 0, sizeof(axisPID));
|
||||
|
||||
memset(&customMixer, 0, sizeof(customMixer));
|
||||
}
|
||||
|
||||
virtual void withDefaultEscAndServoConfiguration(void) {
|
||||
escAndServoConfig.mincommand = TEST_MIN_COMMAND;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(BasicMixerIntegrationTest, TestTricopterServo)
|
||||
{
|
||||
// given
|
||||
rxConfig.midrc = 1500;
|
||||
|
||||
mixerConfig.tri_unarmed_servo = 1;
|
||||
|
||||
escAndServoConfig_t escAndServoConfig;
|
||||
memset(&escAndServoConfig, 0, sizeof(escAndServoConfig));
|
||||
escAndServoConfig.mincommand = TEST_MIN_COMMAND;
|
||||
withDefaultEscAndServoConfiguration();
|
||||
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS];
|
||||
memset(&servoConf, 0, sizeof(servoConf));
|
||||
servoConf[5].min = DEFAULT_SERVO_MIN;
|
||||
servoConf[5].max = DEFAULT_SERVO_MAX;
|
||||
servoConf[5].middle = DEFAULT_SERVO_MIDDLE;
|
||||
servoConf[5].rate = 100;
|
||||
servoConf[5].forwardFromChannel = CHANNEL_FORWARDING_DISABLED;
|
||||
|
||||
gimbalConfig_t gimbalConfig = {
|
||||
.mode = GIMBAL_MODE_NORMAL
|
||||
};
|
||||
|
||||
mixerUseConfigs(
|
||||
servoConf,
|
||||
&gimbalConfig,
|
||||
|
@ -192,12 +208,6 @@ TEST(FlightMixerTest, TestTricopterServo)
|
|||
&rxConfig
|
||||
);
|
||||
|
||||
motorMixer_t customMixer[MAX_SUPPORTED_MOTORS];
|
||||
memset(&customMixer, 0, sizeof(customMixer));
|
||||
|
||||
servoMixer_t customServoMixer[MAX_SUPPORTED_SERVOS];
|
||||
memset(&customServoMixer, 0, sizeof(customServoMixer));
|
||||
|
||||
mixerInit(MIXER_TRI, customMixer, customServoMixer);
|
||||
|
||||
// and
|
||||
|
@ -209,10 +219,6 @@ TEST(FlightMixerTest, TestTricopterServo)
|
|||
mixerUsePWMOutputConfiguration(&pwmOutputConfiguration);
|
||||
|
||||
// and
|
||||
memset(rcCommand, 0, sizeof(rcCommand));
|
||||
|
||||
// and
|
||||
memset(axisPID, 0, sizeof(axisPID));
|
||||
axisPID[YAW] = 0;
|
||||
|
||||
// when
|
||||
|
@ -224,27 +230,12 @@ TEST(FlightMixerTest, TestTricopterServo)
|
|||
EXPECT_EQ(TEST_SERVO_MID, servos[0].value);
|
||||
}
|
||||
|
||||
TEST(FlightMixerTest, TestQuadMotors)
|
||||
TEST_F(BasicMixerIntegrationTest, TestQuadMotors)
|
||||
{
|
||||
// given
|
||||
updatedMotorCount = 0;
|
||||
|
||||
mixerConfig_t mixerConfig;
|
||||
memset(&mixerConfig, 0, sizeof(mixerConfig));
|
||||
|
||||
rxConfig_t rxConfig;
|
||||
memset(&rxConfig, 0, sizeof(rxConfig));
|
||||
|
||||
servoParam_t servoConf[MAX_SUPPORTED_SERVOS];
|
||||
memset(&servoConf, 0, sizeof(servoConf));
|
||||
|
||||
escAndServoConfig_t escAndServoConfig;
|
||||
memset(&escAndServoConfig, 0, sizeof(escAndServoConfig));
|
||||
escAndServoConfig.mincommand = TEST_MIN_COMMAND;
|
||||
|
||||
gimbalConfig_t gimbalConfig = {
|
||||
.mode = GIMBAL_MODE_NORMAL
|
||||
};
|
||||
withDefaultEscAndServoConfiguration();
|
||||
|
||||
mixerUseConfigs(
|
||||
servoConf,
|
||||
|
@ -256,13 +247,6 @@ TEST(FlightMixerTest, TestQuadMotors)
|
|||
&rxConfig
|
||||
);
|
||||
|
||||
motorMixer_t customMixer[MAX_SUPPORTED_MOTORS];
|
||||
memset(&customMixer, 0, sizeof(customMixer));
|
||||
|
||||
servoMixer_t customServoMixer[MAX_SUPPORTED_SERVOS];
|
||||
memset(&customServoMixer, 0, sizeof(customServoMixer));
|
||||
|
||||
|
||||
mixerInit(MIXER_QUADX, customMixer, customServoMixer);
|
||||
|
||||
// and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue