Fixed tests.

This commit is contained in:
mikeller 2018-12-16 11:28:04 +13:00
parent 53278c08f8
commit 1771ea687f
3 changed files with 23 additions and 20 deletions

View File

@ -35,12 +35,9 @@
#include "common/maths.h"
#include "common/utils.h"
#include "drivers/time.h"
#include "config/feature.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/rx.h"
#include "drivers/time.h"
#include "flight/pid.h"
@ -51,12 +48,17 @@
#include "fc/config.h"
#include "fc/controlrate_profile.h"
#include "fc/rc_adjustments.h"
#include "fc/rc_controls.h"
#include "fc/rc.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/rx.h"
#include "rx/rx.h"
#include "rc_adjustments.h"
#define ADJUSTMENT_RANGE_COUNT_INVALID -1
PG_REGISTER_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges, PG_ADJUSTMENT_RANGE_CONFIG, 1);

View File

@ -93,7 +93,7 @@ TEST(ArmingPreventionTest, CalibrationPowerOnGraceAngleThrottleArmSwitch)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -183,7 +183,7 @@ TEST(ArmingPreventionTest, ArmingGuardRadioLeftOnAndArmed)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -261,7 +261,7 @@ TEST(ArmingPreventionTest, Prearm)
modeActivationConditionsMutable(1)->modeId = BOXPREARM;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -304,7 +304,7 @@ TEST(ArmingPreventionTest, RadioTurnedOnAtAnyTimeArmed)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -370,7 +370,7 @@ TEST(ArmingPreventionTest, In3DModeAllowArmingWhenEnteringThrottleDeadband)
modeActivationConditionsMutable(0)->modeId = BOXARM;
modeActivationConditionsMutable(0)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(0)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->midrc = 1500;
@ -437,7 +437,7 @@ TEST(ArmingPreventionTest, When3DModeDisabledThenNormalThrottleArmingConditionAp
modeActivationConditionsMutable(1)->modeId = BOX3D;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -538,7 +538,7 @@ TEST(ArmingPreventionTest, WhenUsingSwitched3DModeThenNormalThrottleArmingCondit
modeActivationConditionsMutable(1)->modeId = BOX3D;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -632,7 +632,7 @@ TEST(ArmingPreventionTest, Rescue)
modeActivationConditionsMutable(1)->modeId = BOXGPSRESCUE;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -744,7 +744,7 @@ TEST(ArmingPreventionTest, ParalyzeOnAtBoot)
modeActivationConditionsMutable(1)->modeId = BOXPARALYZE;
modeActivationConditionsMutable(1)->range.startStep = CHANNEL_VALUE_TO_STEP(1750);
modeActivationConditionsMutable(1)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;
@ -794,7 +794,7 @@ TEST(ArmingPreventionTest, Paralyze)
modeActivationConditionsMutable(2)->range.endStep = CHANNEL_VALUE_TO_STEP(CHANNEL_RANGE_MAX);
modeActivationConditionsMutable(3)->modeId = BOXVTXPITMODE;
modeActivationConditionsMutable(3)->linkedTo = BOXPARALYZE;
useRcControlsConfig(NULL);
rcControlsInit();
// and
rxConfigMutable()->mincheck = 1050;

View File

@ -566,7 +566,6 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController0)
pidProfile.pid[PID_YAW].P = 7;
pidProfile.pid[PID_YAW].I = 17;
pidProfile.pid[PID_YAW].D = 27;
useAdjustmentConfig(&pidProfile);
// and
controlRateConfig_t controlRateConfig;
memset(&controlRateConfig, 0, sizeof (controlRateConfig));
@ -602,7 +601,8 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController0)
(1 << 5);
// when
useRcControlsConfig(&pidProfile);
currentPidProfile = &pidProfile;
rcControlsInit();
processRcAdjustments(&controlRateConfig);
// then
@ -638,7 +638,6 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController2)
pidProfile.D_f[PIDPITCH] = 20.0f;
pidProfile.D_f[PIDROLL] = 25.0f;
pidProfile.D_f[PIDYAW] = 27.0f;
useAdjustmentConfig(&pidProfile);
// and
controlRateConfig_t controlRateConfig;
@ -675,7 +674,8 @@ TEST_F(RcControlsAdjustmentsTest, processPIDIncreasePidController2)
(1 << 5);
// when
useRcControlsConfig(&escAndServoConfig, &pidProfile);
currentPidProfile = &pidProfile;
rcControlsInit();
processRcAdjustments(&controlRateConfig, &rxConfig);
// then
@ -733,6 +733,7 @@ uint16_t flightModeFlags = 0;
int16_t heading;
uint8_t stateFlags = 0;
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT];
pidProfile_t *currentPidProfile;
rxRuntimeConfig_t rxRuntimeConfig;
PG_REGISTER(blackboxConfig_t, blackboxConfig, PG_BLACKBOX_CONFIG, 0);
PG_REGISTER(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 2);