Add signal for changes in Group.

This commit is contained in:
Felix Geyer
2010-08-15 15:03:47 +02:00
parent bfb75da123
commit e28ed4891b
10 changed files with 94 additions and 22 deletions

View File

@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest/QSignalSpy>
#include <QtTest/QTest>
#include "core/Database.h"
@@ -65,6 +66,15 @@ void TestGroup::testParenting()
QVERIFY(g1->children().at(0) == g2);
QVERIFY(g1->children().at(1) == g3);
QVERIFY(g3->children().contains(g4));
QSignalSpy spy(db, SIGNAL(groupChanged(const Group*)));
g2->setName("test");
g4->setName("test");
g3->setName("test");
g1->setName("test");
g3->setIcon(Uuid::random());
g1->setIcon(2);
QVERIFY(spy.count() == 6);
}
QTEST_MAIN(TestGroup);

View File

@@ -15,9 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtTest/QSignalSpy>
#include <QtTest/QTest>
#include "modeltest.h"
#include "core/Database.h"
#include "core/Group.h"
#include "gui/GroupModel.h"
@@ -31,7 +33,10 @@ private Q_SLOTS:
void TestGroupModel::test()
{
Database* db = new Database();
Group* groupRoot = new Group();
groupRoot->setParent(db);
groupRoot->setName("groupRoot");
Group* group1 = new Group();
@@ -54,7 +59,7 @@ void TestGroupModel::test()
group2->setName("group2");
group2->setParent(groupRoot);
GroupModel* model = new GroupModel(groupRoot, this);
GroupModel* model = new GroupModel(db, this);
new ModelTest(model, this);
@@ -72,7 +77,13 @@ void TestGroupModel::test()
QVERIFY(model->data(index121) == "group121");
QVERIFY(model->data(index2) == "group2");
QSignalSpy spy(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)));
group11->setName("test");
group121->setIcon(4);
QVERIFY(spy.count() == 2);
delete groupRoot;
delete db;
}
QTEST_MAIN(TestGroupModel);