| 1702 | } |
| 1703 | |
| 1704 | void LiveDataTest::testLoadSaveLiveDataNoLinkedFile() { |
| 1705 | QString savePath; |
| 1706 | { |
| 1707 | // create a temp file and write some data into it |
| 1708 | QTemporaryFile tempFile; |
| 1709 | if (!tempFile.open()) |
| 1710 | QFAIL("failed to create the temp file for writing"); |
| 1711 | |
| 1712 | QFile file(tempFile.fileName()); |
| 1713 | if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text)) |
| 1714 | QFAIL("failed to open the temp file for writing"); |
| 1715 | |
| 1716 | file.write("1,2\n3,4\n"); |
| 1717 | file.flush(); |
| 1718 | |
| 1719 | Project project; |
| 1720 | |
| 1721 | CREATE_DUMMY_LIVEDATA_PROJECT(project, file.fileName()); |
| 1722 | dataSource->setFileLinked(false); // Not linked, the column data is stored in the file |
| 1723 | |
| 1724 | SAVE_PROJECT("testLoadSaveLiveDataSource"); |
| 1725 | } |
| 1726 | |
| 1727 | Project project; |
| 1728 | project.load(savePath); |
| 1729 | |
| 1730 | const auto children = project.children<LiveDataSource>(); |
| 1731 | QCOMPARE(children.count(), 1); |
| 1732 | const auto* dataSource = children.first(); |
| 1733 | |
| 1734 | QCOMPARE(dataSource->columnCount(), 2); |
| 1735 | QCOMPARE(dataSource->rowCount(), 2); |
| 1736 | |
| 1737 | QCOMPARE(dataSource->column(0)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 1738 | QCOMPARE(dataSource->column(1)->columnMode(), AbstractColumn::ColumnMode::Integer); |
| 1739 | |
| 1740 | QCOMPARE(dataSource->column(0)->integerAt(0), 1); |
| 1741 | QCOMPARE(dataSource->column(1)->integerAt(0), 2); |
| 1742 | |
| 1743 | QCOMPARE(dataSource->column(0)->integerAt(1), 3); |
| 1744 | QCOMPARE(dataSource->column(1)->integerAt(1), 4); |
| 1745 | |
| 1746 | const auto curves = project.children<XYCurve>(AbstractAspect::ChildIndexFlag::Recursive); |
| 1747 | QCOMPARE(curves.count(), 1); |
| 1748 | const auto* curve = curves.first(); |
| 1749 | QCOMPARE(curve->xColumn(), dataSource->column(0)); |
| 1750 | QCOMPARE(curve->yColumn(), dataSource->column(1)); |
| 1751 | } |
| 1752 | |
| 1753 | QTEST_MAIN(LiveDataTest) |
nothing calls this directly
no test coverage detected