! * test save and restore of the project with the deactivated option "save calculations", * the results are recalculated after the project was loaded. */
| 245 | * the results are recalculated after the project was loaded. |
| 246 | */ |
| 247 | void CommonAnalysisTest::saveRestoreWithoutCalculations() { |
| 248 | QString savePath; |
| 249 | |
| 250 | // save |
| 251 | { |
| 252 | Project project; |
| 253 | project.setSaveCalculations(false); |
| 254 | auto* ws = new Worksheet(QStringLiteral("Worksheet")); |
| 255 | project.addChild(ws); |
| 256 | |
| 257 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 258 | ws->addChild(plot); |
| 259 | |
| 260 | auto* sheet = new Spreadsheet(QStringLiteral("sheet")); |
| 261 | project.addChild(sheet); |
| 262 | sheet->setColumnCount(2); |
| 263 | sheet->setRowCount(2); |
| 264 | sheet->column(0)->setValueAt(0, 1); |
| 265 | sheet->column(0)->setValueAt(1, 2); |
| 266 | sheet->column(1)->setValueAt(0, 1); |
| 267 | sheet->column(1)->setValueAt(1, 2); |
| 268 | |
| 269 | auto* fitCurve = new XYFitCurve(QStringLiteral("fit")); |
| 270 | plot->addChild(fitCurve); |
| 271 | fitCurve->setDataSourceType(XYAnalysisCurve::DataSourceType::Spreadsheet); |
| 272 | fitCurve->setXDataColumn(sheet->column(0)); |
| 273 | fitCurve->setYDataColumn(sheet->column(1)); |
| 274 | |
| 275 | // perform the fit |
| 276 | XYFitCurve::FitData fitData = fitCurve->fitData(); |
| 277 | fitData.modelCategory = nsl_fit_model_basic; |
| 278 | fitData.modelType = nsl_fit_model_polynomial; |
| 279 | fitData.degree = 1; |
| 280 | XYFitCurve::initFitData(fitData); |
| 281 | fitCurve->setFitData(fitData); |
| 282 | fitCurve->recalculate(); |
| 283 | |
| 284 | SAVE_PROJECT("saveRestoreWithoutCalculations"); |
| 285 | } |
| 286 | |
| 287 | // load the project and verify the columns in the analysis curve have valid data |
| 288 | { |
| 289 | Project project; |
| 290 | QCOMPARE(project.load(savePath), true); |
| 291 | |
| 292 | const auto* ws = project.child<Worksheet>(0); |
| 293 | QVERIFY(ws); |
| 294 | const auto* plot = ws->child<CartesianPlot>(0); |
| 295 | QVERIFY(plot); |
| 296 | const auto* curve = plot->child<XYCurve>(0); |
| 297 | QVERIFY(curve); |
| 298 | const auto* fitCurve = plot->child<XYFitCurve>(0); |
| 299 | QVERIFY(fitCurve); |
| 300 | |
| 301 | // TODO: check to make sure recalculate() was called. |
| 302 | |
| 303 | // the number of valid (non-empty) values should be greater than 0 |
| 304 | QVERIFY(fitCurve->xColumn()); |
nothing calls this directly
no test coverage detected