############################################################################## Conti. fixed - read fixed number of samples from the beginning of the new data ############################################################################## ! * read from the beginning of the new data, read all samples, keep all data */
| 74 | * read from the beginning of the new data, read all samples, keep all data |
| 75 | */ |
| 76 | void LiveDataTest::testReadContinuousFixed00() { |
| 77 | // create a temp file and write some data into it |
| 78 | QTemporaryFile tempFile; |
| 79 | if (!tempFile.open()) |
| 80 | QFAIL("failed to create the temp file for writing"); |
| 81 | |
| 82 | QFile file(tempFile.fileName()); |
| 83 | if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) |
| 84 | QFAIL("failed to open the temp file for writing"); |
| 85 | |
| 86 | file.write("1,2\n3,4\n"); |
| 87 | file.flush(); |
| 88 | |
| 89 | // initialize the live data source |
| 90 | LiveDataSource dataSource(QStringLiteral("test"), false); |
| 91 | dataSource.setSourceType(LiveDataSource::SourceType::FileOrPipe); |
| 92 | dataSource.setFileType(AbstractFileFilter::FileType::Ascii); |
| 93 | dataSource.setFileName(file.fileName()); |
| 94 | dataSource.setReadingType(LiveDataSource::ReadingType::ContinuousFixed); |
| 95 | dataSource.setSampleSize(100); // big number of samples, more then the new data has, meaning we read all new data |
| 96 | dataSource.setUpdateType(LiveDataSource::UpdateType::NewData); |
| 97 | |
| 98 | // initialize the ASCII filter |
| 99 | auto* filter = new AsciiFilter(); |
| 100 | auto properties = filter->defaultProperties(); |
| 101 | properties.headerEnabled = false; |
| 102 | properties.intAsDouble = false; |
| 103 | properties.columnNamesRaw = QStringLiteral("x, y"); |
| 104 | properties.columnModesString = QStringLiteral("Int, Int"); |
| 105 | properties.automaticSeparatorDetection = false; |
| 106 | properties.separator = QStringLiteral(","); |
| 107 | QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success); |
| 108 | |
| 109 | // QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success); |
| 110 | dataSource.setFilter(filter); |
| 111 | |
| 112 | // read the data and perform checks, after the initial read all data is read |
| 113 | dataSource.read(); |
| 114 | |
| 115 | QCOMPARE(dataSource.columnCount(), 2); |
| 116 | QCOMPARE(dataSource.rowCount(), 2); |
| 117 | |
| 118 | QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 119 | QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 120 | |
| 121 | QCOMPARE(dataSource.column(0)->integerAt(0), 1); |
| 122 | QCOMPARE(dataSource.column(1)->integerAt(0), 2); |
| 123 | |
| 124 | QCOMPARE(dataSource.column(0)->integerAt(1), 3); |
| 125 | QCOMPARE(dataSource.column(1)->integerAt(1), 4); |
| 126 | |
| 127 | // currently fails on Windows (waitForSignal()?) |
| 128 | #ifdef HAVE_WINDOWS |
| 129 | return; |
| 130 | #endif |
| 131 | // write out more data to the file |
| 132 | file.write("5,6\n7,8\n"); |
| 133 | file.close(); |
nothing calls this directly
no test coverage detected