############################################################################## ############# Till the End - all newly received data is processed ############ ############################################################################## ! * read till the end of the new data, read all data, keep all data */
| 907 | * read till the end of the new data, read all data, keep all data |
| 908 | */ |
| 909 | void LiveDataTest::testReadTillEnd00() { |
| 910 | // create a temp file and write some data into it |
| 911 | QTemporaryFile tempFile; |
| 912 | if (!tempFile.open()) |
| 913 | QFAIL("failed to create the temp file for writing"); |
| 914 | |
| 915 | QFile file(tempFile.fileName()); |
| 916 | if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) |
| 917 | QFAIL("failed to open the temp file for writing"); |
| 918 | |
| 919 | file.write("1,2\n3,4\n"); |
| 920 | file.flush(); |
| 921 | |
| 922 | // initialize the live data source |
| 923 | LiveDataSource dataSource(QStringLiteral("test"), false); |
| 924 | dataSource.setSourceType(LiveDataSource::SourceType::FileOrPipe); |
| 925 | dataSource.setFileType(AbstractFileFilter::FileType::Ascii); |
| 926 | dataSource.setFileName(file.fileName()); |
| 927 | dataSource.setReadingType(LiveDataSource::ReadingType::TillEnd); |
| 928 | dataSource.setUpdateType(LiveDataSource::UpdateType::NewData); |
| 929 | |
| 930 | // initialize the ASCII filter |
| 931 | auto* filter = new AsciiFilter(); |
| 932 | auto properties = filter->defaultProperties(); |
| 933 | properties.headerEnabled = false; |
| 934 | properties.intAsDouble = false; |
| 935 | properties.columnNamesRaw = QStringLiteral("x, y"); |
| 936 | properties.columnModesString = QStringLiteral("Int, Int"); |
| 937 | properties.automaticSeparatorDetection = false; |
| 938 | properties.separator = QStringLiteral(","); |
| 939 | QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success); |
| 940 | dataSource.setFilter(filter); |
| 941 | |
| 942 | // read the data and perform checks |
| 943 | dataSource.read(); |
| 944 | |
| 945 | QCOMPARE(dataSource.columnCount(), 2); |
| 946 | QCOMPARE(dataSource.rowCount(), 2); |
| 947 | |
| 948 | QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 949 | QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 950 | |
| 951 | QCOMPARE(dataSource.column(0)->integerAt(0), 1); |
| 952 | QCOMPARE(dataSource.column(1)->integerAt(0), 2); |
| 953 | |
| 954 | QCOMPARE(dataSource.column(0)->integerAt(1), 3); |
| 955 | QCOMPARE(dataSource.column(1)->integerAt(1), 4); |
| 956 | |
| 957 | // currently fails on Windows (waitForSignal()?) |
| 958 | #ifdef HAVE_WINDOWS |
| 959 | return; |
| 960 | #endif |
| 961 | // write out more data to the file |
| 962 | file.write("5,6\n7,8\n"); |
| 963 | file.close(); |
| 964 | waitForSignal(&dataSource, &LiveDataSource::readOnUpdateCalled); |
| 965 | |
| 966 | // checks |
nothing calls this directly
no test coverage detected