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

Method testUdpReadContinuousFixed00

tests/livedata/LiveDataTest.cpp:1460–1498  ·  view source on GitHub ↗

############################################################################## ################################## UDP ###################################### ##############################################################################

Source from the content-addressed store, hash-verified

1458// ################################## UDP ######################################
1459// ##############################################################################
1460void LiveDataTest::testUdpReadContinuousFixed00() {
1461 // initialize the live data source
1462 LiveDataSource dataSource(QStringLiteral("test"), false);
1463 dataSource.setSourceType(LiveDataSource::SourceType::NetworkUDPSocket);
1464 dataSource.setFileType(AbstractFileFilter::FileType::Ascii);
1465 dataSource.setHost(hostname);
1466 dataSource.setPort(UDP_PORT);
1467 dataSource.setReadingType(LiveDataSource::ReadingType::ContinuousFixed);
1468 dataSource.setSampleSize(100); // big number of samples, more then the new data has, meaning we read all new data
1469 dataSource.setUpdateType(LiveDataSource::UpdateType::TimeInterval);
1470 dataSource.setRowCount(0);
1471
1472 // initialize the ASCII filter
1473 auto* filter = new AsciiFilter();
1474 auto properties = filter->defaultProperties();
1475 properties.headerEnabled = false;
1476 properties.automaticSeparatorDetection = false;
1477 properties.separator = QStringLiteral(",");
1478 filter->setProperties(properties);
1479 dataSource.setFilter(filter);
1480
1481 dataSource.setUpdateInterval(updateIntervalMs); // Start livedata
1482
1483 // wait until livedata update time is finished and triggers a read
1484 wait(updateIntervalMs * 10);
1485 dataSource.pauseReading();
1486
1487 QCOMPARE(dataSource.columnCount(), 2);
1488 QVERIFY(dataSource.rowCount() > 0);
1489
1490 QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::Double);
1491 QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Double);
1492
1493 QCOMPARE(dataSource.column(0)->valueAt(0), 1.);
1494 QCOMPARE(dataSource.column(1)->valueAt(0), 2.);
1495
1496 QCOMPARE(dataSource.column(0)->valueAt(dataSource.rowCount() - 1), 1.);
1497 QCOMPARE(dataSource.column(1)->valueAt(dataSource.rowCount() - 1), 2.);
1498}
1499
1500#define CREATE_DUMMY_LIVEDATA_PROJECT(project, importFileName) \
1501 /* initialize the live data source */ \

Callers

nothing calls this directly

Calls 15

setSourceTypeMethod · 0.80
setFileTypeMethod · 0.80
setHostMethod · 0.80
setPortMethod · 0.80
defaultPropertiesMethod · 0.80
setPropertiesMethod · 0.80
setReadingTypeMethod · 0.45
setSampleSizeMethod · 0.45
setUpdateTypeMethod · 0.45
setRowCountMethod · 0.45
setFilterMethod · 0.45
setUpdateIntervalMethod · 0.45

Tested by

no test coverage detected