use test files from radio & X7 tests
... and removed warnings dialog temporarily.
This commit is contained in:
@@ -103,20 +103,18 @@ void EEPROMInterface::showEepromErrors(QWidget *parent, const QString &title, co
|
||||
#endif
|
||||
|
||||
// TODO: No GUI here, e.g. return string list instead
|
||||
void EEPROMInterface::showEepromWarnings(QWidget *parent, const QString &title, unsigned long errorsFound)
|
||||
QString EEPROMInterface::getEepromWarnings(unsigned long errorsFound)
|
||||
{
|
||||
std::bitset<NUM_ERRORS> errors((unsigned long long)errorsFound);
|
||||
QStringList warningsList;
|
||||
if (errors.test(WARNING_WRONG_FIRMWARE)) { warningsList << tr("- Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used"); }
|
||||
if (errors.test(OLD_VERSION)) { warningsList << tr("- Your eeprom is from an old version of OpenTX, upgrading!\n To keep your original file as a backup, please choose File -> Save As specifying a different name."); }
|
||||
if (errors.test(WARNING_WRONG_FIRMWARE)) {
|
||||
warningsList << tr("- Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used");
|
||||
}
|
||||
if (errors.test(OLD_VERSION)) {
|
||||
warningsList << tr("- Your eeprom is from an old version of OpenTX, upgrading!\n To keep your original file as a backup, please choose File -> Save As specifying a different name.");
|
||||
}
|
||||
|
||||
QMessageBox msgBox(parent);
|
||||
msgBox.setWindowTitle(title);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setText(tr("Warnings!"));
|
||||
msgBox.setInformativeText(warningsList.join("\n"));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return warningsList.join("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ class EEPROMInterface
|
||||
virtual int getSize(const GeneralSettings &) = 0;
|
||||
|
||||
//static void showEepromErrors(QWidget *parent, const QString &title, const QString &mainMessage, unsigned long errorsFound);
|
||||
static void showEepromWarnings(QWidget *parent, const QString &title, unsigned long errorsFound);
|
||||
static QString getEepromWarnings(unsigned long errorsFound);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -259,11 +259,11 @@ class RawSource {
|
||||
bool isTimeBased(Board::Type board = Board::BOARD_UNKNOWN) const;
|
||||
bool isAvailable(const ModelData * const model = NULL, const GeneralSettings * const gs = NULL, Board::Type board = Board::BOARD_UNKNOWN) const;
|
||||
|
||||
bool operator == ( const RawSource & other) {
|
||||
bool operator == ( const RawSource & other) const {
|
||||
return (this->type == other.type) && (this->index == other.index);
|
||||
}
|
||||
|
||||
bool operator != ( const RawSource & other) {
|
||||
bool operator != ( const RawSource & other) const {
|
||||
return (this->type != other.type) || (this->index != other.index);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ class RawSwitch {
|
||||
QString toString(Board::Type board = Board::BOARD_UNKNOWN, const GeneralSettings * const generalSettings = NULL, const ModelData * const modelData = NULL) const;
|
||||
bool isAvailable(const ModelData * const model = NULL, const GeneralSettings * const gs = NULL, Board::Type board = Board::BOARD_UNKNOWN) const;
|
||||
|
||||
bool operator== ( const RawSwitch& other) {
|
||||
bool operator== ( const RawSwitch& other) const {
|
||||
return (this->type == other.type) && (this->index == other.index);
|
||||
}
|
||||
|
||||
bool operator!= ( const RawSwitch& other) {
|
||||
bool operator!= ( const RawSwitch& other) const {
|
||||
return (this->type != other.type) || (this->index != other.index);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ bool BinEepromFormat::load(RadioData & radioData)
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO: show warnings if any
|
||||
return extract(radioData, eeprom);
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ bool BinEepromFormat::extract(RadioData & radioData, const QByteArray & eeprom)
|
||||
std::bitset<NUM_ERRORS> result((unsigned long long)eepromInterface->load(radioData, (uint8_t *)eeprom.data(), eeprom.size()));
|
||||
if (result.test(ALL_OK)) {
|
||||
if (errors.test(HAS_WARNINGS)) {
|
||||
EEPROMInterface::showEepromWarnings(NULL, CPN_STR_TTL_WARNING, errors.to_ulong());
|
||||
setWarning(EEPROMInterface::getEepromWarnings(errors.to_ulong()));
|
||||
}
|
||||
board = eepromInterface->getBoard();
|
||||
return true;
|
||||
|
||||
@@ -8,6 +8,7 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
|
||||
target_include_directories(gtests-cpn-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
|
||||
add_definitions(-DGTESTS)
|
||||
set(TESTS_PATH ${COMPANION_SRC_DIRECTORY}/tests)
|
||||
set(RADIO_TESTS_PATH ${RADIO_SRC_DIRECTORY}/tests)
|
||||
configure_file(${TESTS_PATH}/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
@@ -2,12 +2,69 @@
|
||||
#include "location.h"
|
||||
#include "storage/storage.h"
|
||||
|
||||
TEST(Conversions, test_conversion)
|
||||
TEST(Conversions, ConversionX9DPFrom22)
|
||||
{
|
||||
QString error;
|
||||
RadioData simuData;
|
||||
Storage store = Storage(TESTS_PATH "/eeprom_22_x9d+.bin");
|
||||
RadioData radioData;
|
||||
Storage store = Storage(RADIO_TESTS_PATH "/eeprom_22_x9d+.bin");
|
||||
|
||||
EXPECT_EQ(true, store.load(simuData));
|
||||
qDebug() << store.error();
|
||||
EXPECT_EQ(true, store.load(radioData));
|
||||
|
||||
const ModelData& model = radioData.models[0];
|
||||
EXPECT_STREQ("Test", model.name);
|
||||
EXPECT_EQ(RawSwitch(SWITCH_TYPE_SWITCH,SWITCH_SA0), model.timers[0].mode);
|
||||
EXPECT_EQ(80, model.mixData[0].weight);
|
||||
EXPECT_EQ(900, model.limitData[0].max); // -100
|
||||
EXPECT_EQ(80, model.expoData[0].weight);
|
||||
EXPECT_EQ(HELI_SWASH_TYPE_120X, model.swashRingData.type);
|
||||
EXPECT_EQ(10, model.flightModeData[0].gvars[0]);
|
||||
EXPECT_STREQ("Tes", model.gvarData[0].name);
|
||||
EXPECT_EQ(PULSES_PXX_XJT_X16, model.moduleData[0].protocol);
|
||||
EXPECT_EQ(0, model.moduleData[0].subType);
|
||||
EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol);
|
||||
EXPECT_EQ(MODULE_SUBTYPE_R9M_FCC, model.moduleData[1].subType);
|
||||
EXPECT_STREQ("Thr", model.inputNames[0]);
|
||||
EXPECT_STREQ("Tes", model.sensorData[0].label);
|
||||
EXPECT_EQ(10, model.sensorData[0].id);
|
||||
EXPECT_EQ(9, model.sensorData[0].instance);
|
||||
EXPECT_EQ(RawSource(SOURCE_TYPE_TELEMETRY,0).toValue(), model.logicalSw[0].val1);
|
||||
}
|
||||
|
||||
TEST(Conversions, ConversionX7From22)
|
||||
{
|
||||
RadioData radioData;
|
||||
Storage store = Storage(RADIO_TESTS_PATH "/eeprom_22_x7.bin");
|
||||
|
||||
EXPECT_EQ(true, store.load(radioData));
|
||||
|
||||
const ModelData& model = radioData.models[0];
|
||||
EXPECT_STREQ("Test", model.name);
|
||||
EXPECT_EQ(PULSES_PXX_R9M, model.moduleData[1].protocol);
|
||||
EXPECT_EQ(MODULE_SUBTYPE_R9M_EU, model.moduleData[1].subType);
|
||||
|
||||
EXPECT_EQ(80, model.mixData[0].weight);
|
||||
EXPECT_EQ(80, model.expoData[0].weight);
|
||||
|
||||
EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0), model.mixData[4].srcRaw);
|
||||
EXPECT_EQ(RawSwitch(SWITCH_TYPE_TELEMETRY,1), model.mixData[4].swtch);
|
||||
EXPECT_EQ(HELI_SWASH_TYPE_120X, model.swashRingData.type);
|
||||
EXPECT_STREQ("Thr", model.inputNames[0]);
|
||||
|
||||
EXPECT_STREQ("Tes", model.sensorData[0].label);
|
||||
EXPECT_EQ(10, model.sensorData[0].id);
|
||||
EXPECT_EQ(9, model.sensorData[0].instance);
|
||||
EXPECT_EQ(900, model.limitData[0].max); // -100
|
||||
|
||||
EXPECT_EQ(10, model.flightModeData[0].gvars[0]);
|
||||
EXPECT_STREQ("FMtest", model.flightModeData[1].name);
|
||||
EXPECT_EQ(RawSwitch(SWITCH_TYPE_VIRTUAL,1), model.flightModeData[1].swtch);
|
||||
EXPECT_STREQ("Tes", model.gvarData[0].name);
|
||||
|
||||
EXPECT_EQ(LS_FN_VPOS, model.logicalSw[0].func);
|
||||
EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0).toValue(), model.logicalSw[0].val1);
|
||||
EXPECT_EQ(0, model.logicalSw[0].val2);
|
||||
|
||||
const FrSkyScreenData& screen = model.frsky.screens[0];
|
||||
EXPECT_EQ(TELEMETRY_SCREEN_NUMBERS, screen.type);
|
||||
EXPECT_EQ(RawSource(SOURCE_TYPE_PPM,0), screen.body.lines[0].source[0]);
|
||||
EXPECT_EQ(RawSource(SOURCE_TYPE_SPECIAL,4), screen.body.lines[0].source[1]);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -25,56 +25,6 @@
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// #if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
// #define RADIO_RESET() \
|
||||
// g_eeGeneral.switchConfig = 0x00007bff
|
||||
// #else
|
||||
// #define RADIO_RESET()
|
||||
// #endif
|
||||
|
||||
// inline void SYSTEM_RESET()
|
||||
// {
|
||||
// #if defined(EEPROM)
|
||||
// memset(modelHeaders, 0, sizeof(modelHeaders));
|
||||
// #endif
|
||||
// generalDefault();
|
||||
// g_eeGeneral.templateSetup = 0;
|
||||
// for (int i=0; i<NUM_SWITCHES; i++) {
|
||||
// simuSetSwitch(i, -1);
|
||||
// }
|
||||
// }
|
||||
|
||||
// inline void MODEL_RESET()
|
||||
// {
|
||||
// memset(&g_model, 0, sizeof(g_model));
|
||||
// memset(&anaInValues, 0, sizeof(anaInValues));
|
||||
// extern uint8_t s_mixer_first_run_done;
|
||||
// s_mixer_first_run_done = false;
|
||||
// lastFlightMode = 255;
|
||||
// }
|
||||
|
||||
// inline void MIXER_RESET()
|
||||
// {
|
||||
// memset(channelOutputs, 0, sizeof(channelOutputs));
|
||||
// memset(chans, 0, sizeof(chans));
|
||||
// memset(ex_chans, 0, sizeof(ex_chans));
|
||||
// memset(act, 0, sizeof(act));
|
||||
// memset(swOn, 0, sizeof(swOn));
|
||||
// mixerCurrentFlightMode = lastFlightMode = 0;
|
||||
// lastAct = 0;
|
||||
// logicalSwitchesReset();
|
||||
// }
|
||||
|
||||
// inline void TELEMETRY_RESET()
|
||||
// {
|
||||
// telemetryData.clear();
|
||||
// telemetryData.rssi.set(100);
|
||||
// for (int i=0; i<MAX_TELEMETRY_SENSORS; i++) {
|
||||
// telemetryItems[i].clear();
|
||||
// }
|
||||
// memclear(g_model.telemetrySensors, sizeof(g_model.telemetrySensors));
|
||||
// }
|
||||
|
||||
class OpenTxTest : public testing::Test
|
||||
{
|
||||
protected: // You should make the members protected s.t. they can be
|
||||
@@ -85,11 +35,6 @@ class OpenTxTest : public testing::Test
|
||||
// Otherwise, this can be skipped.
|
||||
virtual void SetUp()
|
||||
{
|
||||
// SYSTEM_RESET();
|
||||
// MODEL_RESET();
|
||||
// MIXER_RESET();
|
||||
// modelDefault(0);
|
||||
// RADIO_RESET();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
#define TESTS_PATH "@TESTS_PATH@"
|
||||
#define TESTS_PATH "@TESTS_PATH@"
|
||||
#define RADIO_TESTS_PATH "@RADIO_TESTS_PATH@"
|
||||
|
||||
Reference in New Issue
Block a user