2010-08-18 10:22:48 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 or (at your option)
|
|
|
|
* version 3 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-11-21 17:06:30 -05:00
|
|
|
#include "TestEntryModel.h"
|
|
|
|
|
2013-10-03 09:18:16 -04:00
|
|
|
#include <QSignalSpy>
|
2021-07-11 22:10:29 -04:00
|
|
|
#include <QTest>
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2021-03-13 14:07:49 -05:00
|
|
|
#include "core/Entry.h"
|
2010-08-18 10:22:48 -04:00
|
|
|
#include "core/Group.h"
|
2012-05-10 07:59:54 -04:00
|
|
|
#include "crypto/Crypto.h"
|
2021-03-13 14:07:49 -05:00
|
|
|
#include "gui/DatabaseIcons.h"
|
2012-05-10 07:59:54 -04:00
|
|
|
#include "gui/IconModels.h"
|
2012-07-22 15:56:31 -04:00
|
|
|
#include "gui/SortFilterHideProxyModel.h"
|
2012-07-16 11:39:20 -04:00
|
|
|
#include "gui/entry/AutoTypeAssociationsModel.h"
|
2012-05-16 04:16:32 -04:00
|
|
|
#include "gui/entry/EntryAttachmentsModel.h"
|
|
|
|
#include "gui/entry/EntryAttributesModel.h"
|
2018-03-31 16:01:30 -04:00
|
|
|
#include "gui/entry/EntryModel.h"
|
|
|
|
#include "modeltest.h"
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2014-05-16 06:32:52 -04:00
|
|
|
QTEST_GUILESS_MAIN(TestEntryModel)
|
|
|
|
|
2010-09-18 11:15:22 -04:00
|
|
|
void TestEntryModel::initTestCase()
|
2010-08-18 10:22:48 -04:00
|
|
|
{
|
|
|
|
qRegisterMetaType<QModelIndex>("QModelIndex");
|
2014-06-15 05:17:40 -04:00
|
|
|
QVERIFY(Crypto::init());
|
2010-09-18 11:15:22 -04:00
|
|
|
}
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2010-09-18 11:15:22 -04:00
|
|
|
void TestEntryModel::test()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto group1 = new Group();
|
|
|
|
auto group2 = new Group();
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entry1 = new Entry();
|
2010-08-18 10:22:48 -04:00
|
|
|
entry1->setGroup(group1);
|
|
|
|
entry1->setTitle("testTitle1");
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entry2 = new Entry();
|
2010-08-18 10:22:48 -04:00
|
|
|
entry2->setGroup(group1);
|
|
|
|
entry2->setTitle("testTitle2");
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new EntryModel(this);
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2020-05-21 21:43:00 -04:00
|
|
|
QSignalSpy spyAboutToBeMoved(model, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));
|
|
|
|
QSignalSpy spyMoved(model, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)));
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto modelTest = new ModelTest(model, this);
|
2010-08-18 10:22:48 -04:00
|
|
|
|
|
|
|
model->setGroup(group1);
|
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 2);
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyDataChanged(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
|
2010-08-18 10:22:48 -04:00
|
|
|
entry1->setTitle("changed");
|
|
|
|
QCOMPARE(spyDataChanged.count(), 1);
|
|
|
|
|
2012-05-12 07:22:41 -04:00
|
|
|
QModelIndex index1 = model->index(0, 1);
|
|
|
|
QModelIndex index2 = model->index(1, 1);
|
2010-08-18 10:22:48 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->data(index1).toString(), entry1->title());
|
|
|
|
QCOMPARE(model->data(index2).toString(), entry2->title());
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyAboutToAdd(model, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAdded(model, SIGNAL(rowsInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAboutToRemove(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
|
2010-08-18 10:22:48 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entry3 = new Entry();
|
2010-08-18 10:22:48 -04:00
|
|
|
entry3->setGroup(group1);
|
|
|
|
|
2020-05-21 21:43:00 -04:00
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 0);
|
|
|
|
QCOMPARE(spyMoved.count(), 0);
|
|
|
|
|
|
|
|
entry1->moveDown();
|
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 1);
|
|
|
|
QCOMPARE(spyMoved.count(), 1);
|
|
|
|
|
|
|
|
entry1->moveDown();
|
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 2);
|
|
|
|
QCOMPARE(spyMoved.count(), 2);
|
|
|
|
|
|
|
|
entry1->moveDown();
|
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 2);
|
|
|
|
QCOMPARE(spyMoved.count(), 2);
|
|
|
|
|
|
|
|
entry3->moveUp();
|
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 3);
|
|
|
|
QCOMPARE(spyMoved.count(), 3);
|
|
|
|
|
|
|
|
entry3->moveUp();
|
|
|
|
QCOMPARE(spyAboutToBeMoved.count(), 3);
|
|
|
|
QCOMPARE(spyMoved.count(), 3);
|
|
|
|
|
2010-08-18 10:22:48 -04:00
|
|
|
QCOMPARE(spyAboutToAdd.count(), 1);
|
|
|
|
QCOMPARE(spyAdded.count(), 1);
|
|
|
|
QCOMPARE(spyAboutToRemove.count(), 0);
|
|
|
|
QCOMPARE(spyRemoved.count(), 0);
|
|
|
|
|
|
|
|
entry2->setGroup(group2);
|
|
|
|
|
|
|
|
QCOMPARE(spyAboutToAdd.count(), 1);
|
|
|
|
QCOMPARE(spyAdded.count(), 1);
|
|
|
|
QCOMPARE(spyAboutToRemove.count(), 1);
|
|
|
|
QCOMPARE(spyRemoved.count(), 1);
|
|
|
|
|
|
|
|
QSignalSpy spyReset(model, SIGNAL(modelReset()));
|
|
|
|
model->setGroup(group2);
|
|
|
|
QCOMPARE(spyReset.count(), 1);
|
|
|
|
|
|
|
|
delete group1;
|
|
|
|
delete group2;
|
2011-06-29 12:40:26 -04:00
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
2010-08-18 10:22:48 -04:00
|
|
|
}
|
|
|
|
|
2012-04-14 09:41:57 -04:00
|
|
|
void TestEntryModel::testAttachmentsModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entryAttachments = new EntryAttachments(this);
|
2012-04-14 09:41:57 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new EntryAttachmentsModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2012-04-14 09:41:57 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
model->setEntryAttachments(entryAttachments);
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyDataChanged(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
|
|
|
|
QSignalSpy spyAboutToAdd(model, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAdded(model, SIGNAL(rowsInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAboutToRemove(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
|
2012-04-14 09:41:57 -04:00
|
|
|
|
|
|
|
entryAttachments->set("first", QByteArray("123"));
|
|
|
|
|
|
|
|
entryAttachments->set("2nd", QByteArray("456"));
|
2017-12-16 16:26:51 -05:00
|
|
|
entryAttachments->set("2nd", QByteArray("7890"));
|
2012-04-14 09:41:57 -04:00
|
|
|
|
2017-12-16 16:26:51 -05:00
|
|
|
const int firstRow = 0;
|
|
|
|
QCOMPARE(model->data(model->index(firstRow, EntryAttachmentsModel::NameColumn)).toString(), QString("2nd"));
|
|
|
|
QCOMPARE(model->data(model->index(firstRow, EntryAttachmentsModel::SizeColumn), Qt::EditRole).toInt(), 4);
|
2012-04-14 09:41:57 -04:00
|
|
|
|
|
|
|
entryAttachments->remove("first");
|
|
|
|
|
|
|
|
QCOMPARE(spyDataChanged.count(), 1);
|
|
|
|
QCOMPARE(spyAboutToAdd.count(), 2);
|
|
|
|
QCOMPARE(spyAdded.count(), 2);
|
|
|
|
QCOMPARE(spyAboutToRemove.count(), 1);
|
|
|
|
QCOMPARE(spyRemoved.count(), 1);
|
|
|
|
|
|
|
|
QSignalSpy spyReset(model, SIGNAL(modelReset()));
|
|
|
|
entryAttachments->clear();
|
2022-04-11 21:14:57 -04:00
|
|
|
model->setEntryAttachments(nullptr);
|
2012-04-14 09:41:57 -04:00
|
|
|
QCOMPARE(spyReset.count(), 2);
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
|
|
|
delete entryAttachments;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestEntryModel::testAttributesModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entryAttributes = new EntryAttributes(this);
|
2012-04-14 09:41:57 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new EntryAttributesModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2012-04-14 09:41:57 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
model->setEntryAttributes(entryAttributes);
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyDataChanged(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
|
|
|
|
QSignalSpy spyAboutToAdd(model, SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAdded(model, SIGNAL(rowsInserted(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyAboutToRemove(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
|
|
|
|
QSignalSpy spyRemoved(model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
|
2012-04-14 09:41:57 -04:00
|
|
|
|
|
|
|
entryAttributes->set("first", "123");
|
|
|
|
|
|
|
|
entryAttributes->set("2nd", "456");
|
|
|
|
entryAttributes->set("2nd", "789");
|
|
|
|
|
|
|
|
QCOMPARE(model->data(model->index(0, 0)).toString(), QString("2nd"));
|
|
|
|
|
|
|
|
entryAttributes->remove("first");
|
|
|
|
|
|
|
|
// make sure these don't generate messages
|
|
|
|
entryAttributes->set("Title", "test");
|
|
|
|
entryAttributes->set("Notes", "test");
|
|
|
|
|
|
|
|
QCOMPARE(spyDataChanged.count(), 1);
|
|
|
|
QCOMPARE(spyAboutToAdd.count(), 2);
|
|
|
|
QCOMPARE(spyAdded.count(), 2);
|
|
|
|
QCOMPARE(spyAboutToRemove.count(), 1);
|
|
|
|
QCOMPARE(spyRemoved.count(), 1);
|
|
|
|
|
2017-03-07 22:38:18 -05:00
|
|
|
// test attribute protection
|
|
|
|
QString value = entryAttributes->value("2nd");
|
|
|
|
entryAttributes->set("2nd", value, true);
|
|
|
|
QVERIFY(entryAttributes->isProtected("2nd"));
|
|
|
|
QCOMPARE(entryAttributes->value("2nd"), value);
|
|
|
|
|
2012-04-14 09:41:57 -04:00
|
|
|
QSignalSpy spyReset(model, SIGNAL(modelReset()));
|
|
|
|
entryAttributes->clear();
|
2022-04-11 21:14:57 -04:00
|
|
|
model->setEntryAttributes(nullptr);
|
2012-04-14 09:41:57 -04:00
|
|
|
QCOMPARE(spyReset.count(), 2);
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
|
|
|
}
|
|
|
|
|
2012-05-10 07:59:54 -04:00
|
|
|
void TestEntryModel::testDefaultIconModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new DefaultIconModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2012-05-10 07:59:54 -04:00
|
|
|
|
2020-05-29 10:00:07 -04:00
|
|
|
QCOMPARE(model->rowCount(), databaseIcons()->count());
|
2012-05-10 07:59:54 -04:00
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestEntryModel::testCustomIconModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new CustomIconModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2012-05-10 07:59:54 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
2018-03-22 17:56:05 -04:00
|
|
|
QHash<QUuid, QPixmap> icons;
|
|
|
|
QList<QUuid> iconsOrder;
|
2012-05-13 14:50:41 -04:00
|
|
|
|
2018-03-23 06:18:06 -04:00
|
|
|
QUuid iconUuid = QUuid::fromRfc4122(QByteArray(16, '2'));
|
2016-01-24 13:03:50 -05:00
|
|
|
icons.insert(iconUuid, QPixmap());
|
2012-05-13 14:50:41 -04:00
|
|
|
iconsOrder << iconUuid;
|
|
|
|
|
2018-03-23 06:18:06 -04:00
|
|
|
QUuid iconUuid2 = QUuid::fromRfc4122(QByteArray(16, '1'));
|
2016-01-24 13:03:50 -05:00
|
|
|
icons.insert(iconUuid2, QPixmap());
|
2012-05-13 14:50:41 -04:00
|
|
|
iconsOrder << iconUuid2;
|
2012-05-10 07:59:54 -04:00
|
|
|
|
2012-05-13 14:50:41 -04:00
|
|
|
model->setIcons(icons, iconsOrder);
|
2012-05-10 07:59:54 -04:00
|
|
|
QCOMPARE(model->uuidFromIndex(model->index(0, 0)), iconUuid);
|
2012-05-13 14:50:41 -04:00
|
|
|
QCOMPARE(model->uuidFromIndex(model->index(1, 0)), iconUuid2);
|
2012-05-10 07:59:54 -04:00
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
|
|
|
}
|
|
|
|
|
2012-07-16 11:39:20 -04:00
|
|
|
void TestEntryModel::testAutoTypeAssociationsModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new AutoTypeAssociationsModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2012-07-16 11:39:20 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto associations = new AutoTypeAssociations(this);
|
2016-12-01 22:48:07 -05:00
|
|
|
model->setAutoTypeAssociations(associations);
|
2012-07-16 11:39:20 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
|
|
|
AutoTypeAssociations::Association assoc;
|
|
|
|
assoc.window = "1";
|
|
|
|
assoc.sequence = "2";
|
2016-12-01 22:48:07 -05:00
|
|
|
associations->add(assoc);
|
2012-07-16 11:39:20 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 1);
|
|
|
|
QCOMPARE(model->data(model->index(0, 0)).toString(), QString("1"));
|
|
|
|
QCOMPARE(model->data(model->index(0, 1)).toString(), QString("2"));
|
|
|
|
|
|
|
|
assoc.window = "3";
|
|
|
|
assoc.sequence = "4";
|
2016-12-01 22:48:07 -05:00
|
|
|
associations->update(0, assoc);
|
2012-07-16 11:39:20 -04:00
|
|
|
QCOMPARE(model->data(model->index(0, 0)).toString(), QString("3"));
|
|
|
|
QCOMPARE(model->data(model->index(0, 1)).toString(), QString("4"));
|
|
|
|
|
2016-12-01 22:48:07 -05:00
|
|
|
associations->add(assoc);
|
|
|
|
associations->remove(0);
|
2012-07-16 11:39:20 -04:00
|
|
|
QCOMPARE(model->rowCount(), 1);
|
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
2016-12-01 22:48:07 -05:00
|
|
|
delete associations;
|
2012-07-16 11:39:20 -04:00
|
|
|
}
|
|
|
|
|
2012-07-22 15:56:31 -04:00
|
|
|
void TestEntryModel::testProxyModel()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto modelSource = new EntryModel(this);
|
|
|
|
auto modelProxy = new SortFilterHideProxyModel(this);
|
2012-07-22 15:56:31 -04:00
|
|
|
modelProxy->setSourceModel(modelSource);
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto modelTest = new ModelTest(modelProxy, this);
|
2012-07-22 15:56:31 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto db = new Database();
|
|
|
|
auto entry = new Entry();
|
2012-07-22 15:56:31 -04:00
|
|
|
entry->setTitle("Test Title");
|
|
|
|
entry->setGroup(db->rootGroup());
|
|
|
|
|
|
|
|
modelSource->setGroup(db->rootGroup());
|
|
|
|
|
2017-12-19 05:10:32 -05:00
|
|
|
/**
|
|
|
|
* @author Fonic <https://github.com/fonic>
|
|
|
|
* Update comparison value of modelProxy->columnCount() to account for
|
|
|
|
* additional columns 'Password', 'Notes', 'Expires', 'Created', 'Modified',
|
2018-09-05 16:20:57 -04:00
|
|
|
* 'Accessed', 'Paperclip', 'Attachments', and TOTP
|
2017-12-19 05:10:32 -05:00
|
|
|
*/
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyColumnRemove(modelProxy, SIGNAL(columnsAboutToBeRemoved(QModelIndex, int, int)));
|
2012-07-22 15:56:31 -04:00
|
|
|
modelProxy->hideColumn(0, true);
|
2021-02-26 16:43:23 -05:00
|
|
|
QCOMPARE(modelProxy->columnCount(), 14);
|
2019-10-31 16:44:40 -04:00
|
|
|
QVERIFY(!spyColumnRemove.isEmpty());
|
2012-07-22 15:56:31 -04:00
|
|
|
|
|
|
|
int oldSpyColumnRemoveSize = spyColumnRemove.size();
|
|
|
|
modelProxy->hideColumn(0, true);
|
|
|
|
QCOMPARE(spyColumnRemove.size(), oldSpyColumnRemoveSize);
|
|
|
|
|
|
|
|
modelProxy->hideColumn(100, true);
|
|
|
|
QCOMPARE(spyColumnRemove.size(), oldSpyColumnRemoveSize);
|
|
|
|
|
|
|
|
QList<Entry*> entryList;
|
|
|
|
entryList << entry;
|
2018-03-21 21:52:57 -04:00
|
|
|
modelSource->setEntries(entryList);
|
2012-07-22 15:56:31 -04:00
|
|
|
|
2017-12-19 05:10:32 -05:00
|
|
|
/**
|
|
|
|
* @author Fonic <https://github.com/fonic>
|
|
|
|
* Update comparison value of modelProxy->columnCount() to account for
|
|
|
|
* additional columns 'Password', 'Notes', 'Expires', 'Created', 'Modified',
|
2018-09-05 16:20:57 -04:00
|
|
|
* 'Accessed', 'Paperclip', 'Attachments', and TOTP
|
2017-12-19 05:10:32 -05:00
|
|
|
*/
|
2018-03-31 16:01:30 -04:00
|
|
|
QSignalSpy spyColumnInsert(modelProxy, SIGNAL(columnsAboutToBeInserted(QModelIndex, int, int)));
|
2012-07-22 15:56:31 -04:00
|
|
|
modelProxy->hideColumn(0, false);
|
2021-02-26 16:43:23 -05:00
|
|
|
QCOMPARE(modelProxy->columnCount(), 15);
|
2019-10-31 16:44:40 -04:00
|
|
|
QVERIFY(!spyColumnInsert.isEmpty());
|
2012-07-22 15:56:31 -04:00
|
|
|
|
|
|
|
int oldSpyColumnInsertSize = spyColumnInsert.size();
|
|
|
|
modelProxy->hideColumn(0, false);
|
|
|
|
QCOMPARE(spyColumnInsert.size(), oldSpyColumnInsertSize);
|
|
|
|
|
|
|
|
delete modelTest;
|
|
|
|
delete modelProxy;
|
|
|
|
delete modelSource;
|
|
|
|
delete db;
|
|
|
|
}
|
|
|
|
|
2013-03-22 16:00:06 -04:00
|
|
|
void TestEntryModel::testDatabaseDelete()
|
|
|
|
{
|
2022-04-11 20:06:50 -04:00
|
|
|
auto model = new EntryModel(this);
|
|
|
|
auto modelTest = new ModelTest(model, this);
|
2013-03-22 16:00:06 -04:00
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto db1 = new Database();
|
|
|
|
auto group1 = new Group();
|
2013-03-22 16:00:06 -04:00
|
|
|
group1->setParent(db1->rootGroup());
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto entry1 = new Entry();
|
2013-03-22 16:00:06 -04:00
|
|
|
entry1->setGroup(group1);
|
|
|
|
|
2022-04-11 20:06:50 -04:00
|
|
|
auto db2 = new Database();
|
|
|
|
auto entry2 = new Entry();
|
2013-03-22 16:00:06 -04:00
|
|
|
entry2->setGroup(db2->rootGroup());
|
|
|
|
|
2018-03-21 21:52:57 -04:00
|
|
|
model->setEntries(QList<Entry*>() << entry1 << entry2);
|
2013-03-22 16:00:06 -04:00
|
|
|
|
|
|
|
QCOMPARE(model->rowCount(), 2);
|
|
|
|
|
|
|
|
delete db1;
|
|
|
|
QCOMPARE(model->rowCount(), 1);
|
|
|
|
|
|
|
|
delete entry2;
|
|
|
|
QCOMPARE(model->rowCount(), 0);
|
|
|
|
|
|
|
|
delete db2;
|
|
|
|
delete modelTest;
|
|
|
|
delete model;
|
|
|
|
}
|