on xenial help sign in
Basic test for dataChanged signal.
commit76f5c0221c7310f4cf153e18e3a2bee13d7ca078 authorPawel Stolowski <pawel.stolowski@canonical.com> dateMon 12 Aug 2013, 18:07 (13 years ago) parent80c6878
2 files changed+10−1
plugins/Unity/genericoptionsmodel.cpp+1−1 tests/plugins/Unity/filtersbindingstest.cpp+9
plugins/Unity/genericoptionsmodel.cpp+1−1
@@ -140,7 +140,7 @@ void GenericOptionsModel::onOptionChanged()
140140 int idx = indexOf(option->id());
141141 if (idx >= 0)
142142 {
143− QModelIndex optionIndex = index(idx, idx);
143+ QModelIndex optionIndex = index(idx);
144144 Q_EMIT dataChanged(optionIndex, optionIndex);
145145 }
146146 }
tests/plugins/Unity/filtersbindingstest.cpp+9
@@ -313,6 +313,7 @@ void FiltersBindingsTest::testCheckOptionFilter()
313313 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
314314 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
315315 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
316+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
316317
317318 // test active property changes
318319 QCOMPARE(opt0->active(), false);
@@ -335,6 +336,8 @@ void FiltersBindingsTest::testCheckOptionFilter()
335336 QCOMPARE(opt1->active(), true);
336337 QCOMPARE(opt2->active(), false);
337338
339+ QCOMPARE(dataChangedSpy.count(), 3);
340+
338341 delete check_filter;
339342 }
340343}
@@ -385,6 +388,7 @@ void FiltersBindingsTest::testRadioOptionFilter()
385388 QSignalSpy opt0spy(opt0, SIGNAL(activeChanged(bool)));
386389 QSignalSpy opt1spy(opt1, SIGNAL(activeChanged(bool)));
387390 QSignalSpy opt2spy(opt2, SIGNAL(activeChanged(bool)));
391+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
388392
389393 // test active property changes
390394 QCOMPARE(opt0->active(), false);
@@ -407,6 +411,8 @@ void FiltersBindingsTest::testRadioOptionFilter()
407411 QCOMPARE(opt1->active(), true);
408412 QCOMPARE(opt2->active(), false);
409413
414+ QCOMPARE(dataChangedSpy.count(), 3);
415+
410416 delete radio_filter;
411417 }
412418}
@@ -435,6 +441,7 @@ void FiltersBindingsTest::testRatingsFilter()
435441
436442 QSignalSpy opt0spy(opt[0], SIGNAL(activeChanged(bool)));
437443 QSignalSpy opt4spy(opt[4], SIGNAL(activeChanged(bool)));
444+ QSignalSpy dataChangedSpy(options, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
438445
439446 QVERIFY(qAbs(opt[0]->value() - 0.2f) <= 0.0001f);
440447 QVERIFY(qAbs(opt[1]->value() - 0.4f) <= 0.0001f);
@@ -469,6 +476,8 @@ void FiltersBindingsTest::testRatingsFilter()
469476 opt[4]->setActive(false);
470477 QVERIFY(rating_filter->rating() <= 0.0001f); // rating equals zero
471478 QCOMPARE(opt4spy.count(), 2);
479+
480+ QCOMPARE(dataChangedSpy.count(), 10);
472481 }
473482}
474483