void DataModelTest::parseFile() { const QString path = QFINDTESTDATA("/data/massif.out.kate"); QFile file(path); QVERIFY(file.open(QIODevice::ReadOnly)); Parser parser; QScopedPointer<FileData> scopedData(parser.parse(&file)); FileData* data = scopedData.data(); QVERIFY(data); { TotalCostModel* model = new TotalCostModel(this); new ModelTest(model, this); model->setSource(data); QVERIFY(model->rowCount() == data->snapshots().size()); for ( int r = 0; r < model->rowCount(); ++r ) { for ( int c = 0; c < model->columnCount(); ++c ) { qDebug() << r << c << model->data(model->index(r, c)); } } // remove data model->setSource(0); } { DetailedCostModel* model = new DetailedCostModel(this); new ModelTest(model, this); model->setSource(data); for ( int r = 0; r < model->rowCount(); ++r ) { for ( int c = 0; c < model->columnCount(); ++c ) { qDebug() << r << c << model->data(model->index(r, c)); } if ( r ) { // we want that the snapshots are ordered properly QVERIFY(model->data(model->index(r, 0)).toDouble() > model->data(model->index(r - 1, 0)).toDouble()); } } // remove data model->setSource(0); } { DataTreeModel* model = new DataTreeModel(this); new ModelTest(model, this); model->setSource(data); QVERIFY(model->rowCount() == data->snapshots().size()); // remove data model->setSource(0); } }
void DataModelTest::bigMem() { // see also: https://bugs.kde.org/show_bug.cgi?id=294108 const QString path = QFINDTESTDATA("/data/massif.out.huge"); QFile file(path); QVERIFY(file.open(QIODevice::ReadOnly)); Parser parser; QScopedPointer<FileData> scopedData(parser.parse(&file)); FileData* data = scopedData.data(); QVERIFY(data); QCOMPARE(data->snapshots().count(), 1); QCOMPARE(data->peak()->memHeap(), quint64(5021305210)); QCOMPARE(data->peak()->memHeapExtra(), quint64(5021305211)); QCOMPARE(data->peak()->memStacks(), quint64(5021305212)); }