MCPcopy Create free account
hub / github.com/KDE/labplot / testStatisticsSpreadsheetChangeMetrics

Method testStatisticsSpreadsheetChangeMetrics

tests/spreadsheet/SpreadsheetTest.cpp:3184–3206  ·  view source on GitHub ↗

! * change the statistics metrics and check the presense of the corresponding columns */

Source from the content-addressed store, hash-verified

3182 * change the statistics metrics and check the presense of the corresponding columns
3183 */
3184void SpreadsheetTest::testStatisticsSpreadsheetChangeMetrics() {
3185 Project project;
3186 auto* sheet = new Spreadsheet(QStringLiteral("test"), false);
3187 project.addChild(sheet);
3188
3189 new SpreadsheetModel(sheet);
3190
3191 // toggle on the statistics spreadsheet and count the available columns
3192 sheet->toggleStatisticsSpreadsheet(true);
3193 auto* statisticsSpreadsheet = sheet->children<StatisticsSpreadsheet>().constFirst();
3194 auto metrics = statisticsSpreadsheet->metrics();
3195 int colCount = 1; // column "Column Name" is always available
3196 for (const auto& metric : statisticsSpreadsheet->m_metricValues) {
3197 if (metrics.testFlag(metric))
3198 ++colCount;
3199 }
3200 QCOMPARE(statisticsSpreadsheet->children<Column>().size(), colCount);
3201
3202 // deactivate Count and check the available columns again
3203 metrics.setFlag(StatisticsSpreadsheet::Metric::Count, false);
3204 statisticsSpreadsheet->setMetrics(metrics);
3205 QCOMPARE(statisticsSpreadsheet->children<Column>().size(), colCount - 1);
3206}
3207
3208/*!
3209 * check the position of the statistics spreadsheet in the list of children of the parent

Callers

nothing calls this directly

Calls 5

metricsMethod · 0.80
setMetricsMethod · 0.80
addChildMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected