on xenial help sign in
Basic test for dataChanged signal.
76f5c02Pawel Stolowski
plugins/Unity/genericoptionsmodel.cpp+1−1
@@ -140,7 +140,7 @@ void GenericOptionsModel::onOptionChanged()
140 int idx = indexOf(option->id());
140 int idx = indexOf(option->id());
141 if (idx >= 0)
141 if (idx >= 0)
142 {
142 {
143− QModelIndex optionIndex = index(idx, idx);
143+ QModelIndex optionIndex = index(idx);
144 Q_EMIT dataChanged(optionIndex, optionIndex);
144 Q_EMIT dataChanged(optionIndex, optionIndex);
145 }
145 }
146 }
146 }
tests/plugins/Unity/filtersbindingstest.cpp+9
@@ -313,6 +313,7 @@ void FiltersBindingsTest::testCheckOptionFilter()
313 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
313 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
314 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
314 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
315 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
315 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
316+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
316
317
317 // test active property changes
318 // test active property changes
318 QCOMPARE(opt0->active(), false);
319 QCOMPARE(opt0->active(), false);
@@ -335,6 +336,8 @@ void FiltersBindingsTest::testCheckOptionFilter()
335 QCOMPARE(opt1->active(), true);
336 QCOMPARE(opt1->active(), true);
336 QCOMPARE(opt2->active(), false);
337 QCOMPARE(opt2->active(), false);
337
338
339+ QCOMPARE(dataChangedSpy.count(), 3);
340+
338 delete check_filter;
341 delete check_filter;
339 }
342 }
340}
343}
@@ -385,6 +388,7 @@ void FiltersBindingsTest::testRadioOptionFilter()
385 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
388 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
386 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
389 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
387 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
390 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
391+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
388
392
389 // test active property changes
393 // test active property changes
390 QCOMPARE(opt0->active(), false);
394 QCOMPARE(opt0->active(), false);
@@ -407,6 +411,8 @@ void FiltersBindingsTest::testRadioOptionFilter()
407 QCOMPARE(opt1->active(), true);
411 QCOMPARE(opt1->active(), true);
408 QCOMPARE(opt2->active(), false);
412 QCOMPARE(opt2->active(), false);
409
413
414+ QCOMPARE(dataChangedSpy.count(), 3);
415+
410 delete radio_filter;
416 delete radio_filter;
411 }
417 }
412}
418}
@@ -435,6 +441,7 @@ void FiltersBindingsTest::testRatingsFilter()
435
441
436 QSignalSpy opt0spy(opt[0], SIGNAL(activeChanged(bool)));
442 QSignalSpy opt0spy(opt[0], SIGNAL(activeChanged(bool)));
437 QSignalSpy opt4spy(opt[4], SIGNAL(activeChanged(bool)));
443 QSignalSpy opt4spy(opt[4], SIGNAL(activeChanged(bool)));
444+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
438
445
439 QVERIFY(qAbs(opt[0]->value() - 0.2f) <= 0.0001f);
446 QVERIFY(qAbs(opt[0]->value() - 0.2f) <= 0.0001f);
440 QVERIFY(qAbs(opt[1]->value() - 0.4f) <= 0.0001f);
447 QVERIFY(qAbs(opt[1]->value() - 0.4f) <= 0.0001f);
@@ -469,6 +476,8 @@ void FiltersBindingsTest::testRatingsFilter()
469 opt[4]->setActive(false);
476 opt[4]->setActive(false);
470 QVERIFY(rating_filter->rating() <= 0.0001f); // rating equals zero
477 QVERIFY(rating_filter->rating() <= 0.0001f); // rating equals zero
471 QCOMPARE(opt4spy.count(), 2);
478 QCOMPARE(opt4spy.count(), 2);
479+
480+ QCOMPARE(dataChangedSpy.count(), 10);
472 }
481 }
473}
482}
474
483