##// END OF EJS Templates
Added modelUpdated() test to xy model mapper
Marek Rosa -
r1399:fe0b2743f054
parent child
Show More
@@ -52,6 +52,7 private Q_SLOTS:
52 52 void horizontalMapperCustomMapping_data();
53 53 void horizontalMapperCustomMapping();
54 54 void seriesUpdated();
55 void modelUpdated();
55 56
56 57 private:
57 58 QStandardItemModel *m_model;
@@ -121,6 +122,8 void tst_qxymodelmapper::verticalMapper()
121 122 QFETCH(int, expectedCount);
122 123
123 124 QVXYModelMapper *mapper = new QVXYModelMapper;
125 QVERIFY(mapper->model() == 0);
126
124 127 mapper->setXColumn(xColumn);
125 128 mapper->setYColumn(yColumn);
126 129 mapper->setModel(m_model);
@@ -283,6 +286,43 void tst_qxymodelmapper::seriesUpdated()
283 286 QCOMPARE(m_series->count(), m_modelRowCount);
284 287 QCOMPARE(mapper->count(), -1); // the value should not change as it indicates 'all' items there are in the model
285 288
289 delete mapper;
290 mapper = 0;
291
292 otherModel->clear();
293 delete otherModel;
294 otherModel = 0;
295 }
296
297 void tst_qxymodelmapper::modelUpdated()
298 {
299 QStandardItemModel *otherModel = new QStandardItemModel;
300 for (int row = 0; row < m_modelRowCount; ++row) {
301 for (int column = 0; column < m_modelColumnCount; column++) {
302 QStandardItem *item = new QStandardItem(row * column);
303 otherModel->setItem(row, column, item);
304 }
305 }
306
307 QVXYModelMapper *mapper = new QVXYModelMapper;
308 QVERIFY(mapper->model() == 0);
309 mapper->setXColumn(0);
310 mapper->setYColumn(1);
311 mapper->setModel(otherModel);
312 mapper->setSeries(m_series);
313 QCOMPARE(m_series->count(), m_modelRowCount);
314
315 QVERIFY(mapper->model() != 0);
316
317 if (otherModel->insertRows(3, 4))
318 QCOMPARE(m_series->count(), m_modelRowCount + 4);
319
320 if (otherModel->removeRows(1, 5))
321 QCOMPARE(m_series->count(), m_modelRowCount - 1);
322
323 delete mapper;
324 mapper = 0;
325
286 326 otherModel->clear();
287 327 delete otherModel;
288 328 otherModel = 0;
General Comments 0
You need to be logged in to leave comments. Login now