| 1552 | curve->setYColumn(dataSource->column(1)); |
| 1553 | |
| 1554 | void LiveDataTest::testLoadSaveLiveDataLinkedFile_FileExists() { |
| 1555 | // create a temp file and write some data into it |
| 1556 | QTemporaryFile tempFile; |
| 1557 | if (!tempFile.open()) |
| 1558 | QFAIL("failed to create the temp file for writing"); |
| 1559 | |
| 1560 | QFile file(tempFile.fileName()); |
| 1561 | if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) |
| 1562 | QFAIL("failed to open the temp file for writing"); |
| 1563 | |
| 1564 | file.write("1,2\n3,4\n"); |
| 1565 | file.flush(); |
| 1566 | |
| 1567 | QString savePath; |
| 1568 | { |
| 1569 | Project project; |
| 1570 | |
| 1571 | CREATE_DUMMY_LIVEDATA_PROJECT(project, file.fileName()); |
| 1572 | dataSource->setFileLinked(true); // Linked file, no column data stored |
| 1573 | |
| 1574 | SAVE_PROJECT("testLoadSaveLiveDataSource"); |
| 1575 | } |
| 1576 | |
| 1577 | Project project; |
| 1578 | project.load(savePath); |
| 1579 | |
| 1580 | const auto children = project.children<LiveDataSource>(); |
| 1581 | QCOMPARE(children.count(), 1); |
| 1582 | const auto* dataSource = children.first(); |
| 1583 | |
| 1584 | QCOMPARE(dataSource->columnCount(), 2); |
| 1585 | QCOMPARE(dataSource->rowCount(), 2); |
| 1586 | |
| 1587 | QCOMPARE(dataSource->column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 1588 | QCOMPARE(dataSource->column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 1589 | |
| 1590 | QCOMPARE(dataSource->column(0)->integerAt(0), 1); |
| 1591 | QCOMPARE(dataSource->column(1)->integerAt(0), 2); |
| 1592 | |
| 1593 | QCOMPARE(dataSource->column(0)->integerAt(1), 3); |
| 1594 | QCOMPARE(dataSource->column(1)->integerAt(1), 4); |
| 1595 | |
| 1596 | const auto curves = project.children<XYCurve>(AbstractAspect::ChildIndexFlag::Recursive); |
| 1597 | QCOMPARE(curves.count(), 1); |
| 1598 | const auto* curve = curves.first(); |
| 1599 | QCOMPARE(curve->xColumn(), dataSource->column(0)); |
| 1600 | QCOMPARE(curve->yColumn(), dataSource->column(1)); |
| 1601 | } |
| 1602 | |
| 1603 | void LiveDataTest::testLoadSaveLiveDataLinkedFile_FileNotExists() { |
| 1604 | QString savePath; |
nothing calls this directly
no test coverage detected