| 386 | } |
| 387 | |
| 388 | void BLFFilterTest::testTimeNative() { |
| 389 | /* open file for writing */ |
| 390 | QTemporaryFile blfFileName(QStringLiteral("XXXXXX.blf")); |
| 391 | QVERIFY(blfFileName.open()); |
| 392 | QVector<Vector::BLF::CanMessage2*> messages{ |
| 393 | createCANMessage(234, 5, {0x01, 0x02}), |
| 394 | createCANMessage(123, 6, {0xFF, 0xA2}), |
| 395 | createCANMessage(123, 8, {0x23, 0xE2}), |
| 396 | createCANMessage(234, 10, {0xD3, 0xB2}), |
| 397 | createCANMessage(234, 12, {0xE1, 0xC7}), |
| 398 | createCANMessage(234, 14, {0xD1, 0xC7}), |
| 399 | }; // time is in nanoseconds |
| 400 | createBLFFile(blfFileName.fileName(), messages); |
| 401 | |
| 402 | QTemporaryFile dbcFile(QStringLiteral("XXXXXX.dbc")); |
| 403 | QVERIFY(dbcFile.open()); |
| 404 | const auto dbcContent = R"(BO_ 234 MSG1: 8 Vector__XXX |
| 405 | SG_ Msg1Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX |
| 406 | SG_ Msg1Sig2 : 8|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX |
| 407 | BO_ 123 MSG2: 8 Vector__XXX |
| 408 | SG_ Msg2Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "mm" Vector__XXX |
| 409 | SG_ Msg2Sig2 : 8|8@0+ (1,0) [-3276.8|-3276.7] "m" Vector__XXX |
| 410 | )"; |
| 411 | createDBCFile(dbcFile.fileName(), dbcContent); |
| 412 | |
| 413 | // Start Test |
| 414 | |
| 415 | VectorBLFFilter filter; |
| 416 | filter.setConvertTimeToSeconds(false); |
| 417 | filter.setTimeHandlingMode(CANFilter::TimeHandling::ConcatNAN); |
| 418 | QCOMPARE(filter.isValid(blfFileName.fileName()), true); |
| 419 | |
| 420 | // Valid blf and valid dbc |
| 421 | filter.setDBCFile(dbcFile.fileName()); |
| 422 | Spreadsheet s(QStringLiteral("TestSpreadsheet"), false); |
| 423 | filter.readDataFromFile(blfFileName.fileName(), &s); |
| 424 | QCOMPARE(s.columnCount(), 5); // time + Msg1Sig1 + Msg1Sig2 + Msg2Sig1 + Msg2Sig2 |
| 425 | |
| 426 | { |
| 427 | // Time |
| 428 | const auto* c = s.column(0); |
| 429 | QCOMPARE(c->name(), i18n("Time_ns")); |
| 430 | QCOMPARE(c->rowCount(), 6); |
| 431 | |
| 432 | QVector<double> refData{5, 6, 8, 10, 12, 14}; |
| 433 | QCOMPARE(refData.size(), 6); |
| 434 | for (int i = 0; i < c->rowCount(); i++) { |
| 435 | QCOMPARE(c->valueAt(i), refData.at(i)); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | // Value5 is a value larger than one byte, but not exactly a multiple |
| 441 | // And is not aligned with a complete byte |
nothing calls this directly
no test coverage detected