MCPcopy Create free account
hub / github.com/KDE/labplot / testLinkSpreadSheetImportBLF

Method testLinkSpreadSheetImportBLF

tests/spreadsheet/SpreadsheetTest.cpp:3328–3449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3326}
3327
3328void SpreadsheetTest::testLinkSpreadSheetImportBLF() {
3329 QTemporaryFile blfFileName(QStringLiteral("XXXXXX.blf"));
3330 QVERIFY(blfFileName.open());
3331 QVector<Vector::BLF::CanMessage2*> messages{
3332 createCANMessage(337, 5, {0, 4, 252, 19, 0, 0, 0, 0}),
3333 createCANMessage(541, 10, {7, 39, 118, 33, 250, 30, 76, 24}), // 99.91, 85.66, 79.3, 22.2
3334 createCANMessage(337, 15, {47, 4, 60, 29, 0, 0, 0, 0}),
3335 createCANMessage(337, 20, {57, 4, 250, 29, 0, 0, 0, 0}),
3336 createCANMessage(541, 25, {7, 39, 118, 33, 250, 30, 76, 24}), // 99.91, 85.66, 79.3, 22.2
3337 }; // time is in nanoseconds
3338 createBLFFile(blfFileName.fileName(), messages);
3339
3340 QTemporaryFile dbcFile(QStringLiteral("XXXXXX.dbc"));
3341 QVERIFY(dbcFile.open());
3342 const auto dbcContent = R"(BO_ 337 STATUS: 8 Vector__XXX
3343 SG_ Value6 : 27|3@1+ (1,0) [0|7] "" Vector__XXX
3344 SG_ Value5 : 16|11@1+ (0.1,-102) [-102|102] "%" Vector__XXX
3345 SG_ Value2 : 8|2@1+ (1,0) [0|2] "" Vector__XXX
3346 SG_ Value3 : 10|1@1+ (1,0) [0|1] "" Vector__XXX
3347 SG_ Value7 : 30|2@1+ (1,0) [0|3] "" Vector__XXX
3348 SG_ Value4 : 11|4@1+ (1,0) [0|3] "" Vector__XXX
3349 SG_ Value1 : 0|8@1+ (1,0) [0|204] "Km/h" Vector__XXX"
3350BO_ 541 MSG2: 8 Vector__XXX
3351 SG_ MSG2Value4 : 48|16@1+ (0.01,-40) [-40|125] "C" Vector__XXX
3352 SG_ MSG2Value1 : 0|16@1+ (0.01,0) [0|100] "%" Vector__XXX
3353 SG_ MSG2Value3 : 32|16@1+ (0.01,0) [0|100] "%" Vector__XXX
3354 SG_ MSG2Value2 : 16|16@1+ (0.01,0) [0|100] "%" Vector__XXX
3355)";
3356 createDBCFile(dbcFile.fileName(), dbcContent);
3357
3358 //------------------------------------------------------------------------------------------
3359 Project project;
3360 const auto spreadsheetName = blfFileName.fileName().replace(QStringLiteral(".blf"), QStringLiteral(""));
3361 auto* sheetData = new Spreadsheet(spreadsheetName, false);
3362 project.addChild(sheetData);
3363 sheetData->setColumnCount(2);
3364 sheetData->setRowCount(10);
3365 auto* sheetDataColumn0 = sheetData->child<Column>(0);
3366 sheetDataColumn0->setName(QStringLiteral("Value6_"));
3367 sheetDataColumn0->replaceValues(0, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
3368 QVERIFY(sheetDataColumn0);
3369 auto* sheetDataColumn1 = sheetData->child<Column>(1);
3370 sheetDataColumn1->setName(QStringLiteral("Value5_%"));
3371 QVERIFY(sheetDataColumn1);
3372 sheetDataColumn1->replaceValues(0, {1, 2, 1, 2, 1, 2, 1, 2, 1, 3});
3373
3374 auto* sheetCalculations = new Spreadsheet(QStringLiteral("calculations"), false);
3375 project.addChild(sheetCalculations);
3376 sheetCalculations->setColumnCount(2);
3377 sheetCalculations->setRowCount(2);
3378
3379 auto* sheetCalculationsColumn0 = sheetCalculations->child<Column>(0);
3380 QVERIFY(sheetCalculationsColumn0);
3381 sheetCalculationsColumn0->setFormula(QStringLiteral("2*x"), {QStringLiteral("x")}, {sheetDataColumn0}, true);
3382 sheetCalculationsColumn0->updateFormula();
3383
3384 auto* sheetCalculationsColumn1 = sheetCalculations->child<Column>(1);
3385 QVERIFY(sheetCalculationsColumn1);

Callers

nothing calls this directly

Calls 15

createCANMessageFunction · 0.85
createBLFFileFunction · 0.85
createDBCFileFunction · 0.85
replaceMethod · 0.80
setLinkingMethod · 0.80
setLinkedSpreadsheetMethod · 0.80
linkedSpreadsheetPathMethod · 0.80
setTimeHandlingModeMethod · 0.80
setDBCFileMethod · 0.80
openMethod · 0.45
fileNameMethod · 0.45

Tested by

no test coverage detected