Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-03-29 11:27:38 +0300
committerHannah von Reth <vonreth@kde.org>2021-04-26 15:34:48 +0300
commitb4955076d6f69f4161ed98ffcc191ff81c70e11e (patch)
treeb8206dacbb61d912b2f94fc12b6d3ebd20c2fc15 /test
parent453f0f36f283e8855518c124c6018616c4add19e (diff)
Refactor protocol and issue widget
Diffstat (limited to 'test')
-rw-r--r--test/modeltests/CMakeLists.txt1
-rw-r--r--test/modeltests/testactivitymodel.cpp2
-rw-r--r--test/modeltests/testprotocolmodel.cpp48
3 files changed, 50 insertions, 1 deletions
diff --git a/test/modeltests/CMakeLists.txt b/test/modeltests/CMakeLists.txt
index c7f4bc693..e2e5d5934 100644
--- a/test/modeltests/CMakeLists.txt
+++ b/test/modeltests/CMakeLists.txt
@@ -1 +1,2 @@
owncloud_add_test(ActivityModel)
+owncloud_add_test(ProtocolModel)
diff --git a/test/modeltests/testactivitymodel.cpp b/test/modeltests/testactivitymodel.cpp
index 63cec088b..066a9c9b8 100644
--- a/test/modeltests/testactivitymodel.cpp
+++ b/test/modeltests/testactivitymodel.cpp
@@ -23,7 +23,7 @@ private Q_SLOTS:
{
auto model = new ActivityListModel(this);
- auto tester = new QAbstractItemModelTester(model, this);
+ new QAbstractItemModelTester(model, this);
auto manager = AccountManager::instance();
diff --git a/test/modeltests/testprotocolmodel.cpp b/test/modeltests/testprotocolmodel.cpp
new file mode 100644
index 000000000..2462827cc
--- /dev/null
+++ b/test/modeltests/testprotocolmodel.cpp
@@ -0,0 +1,48 @@
+
+/*
+ * This software is in the public domain, furnished "as is", without technical
+ * support, and with no warranty, express or implied, as to its usefulness for
+ * any purpose.
+ *
+ */
+
+#include "gui/protocolitemmodel.h"
+
+#include <QTest>
+#include <QAbstractItemModelTester>
+
+namespace OCC {
+
+class TestProtocolModel : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void testInsertAndRemove()
+ {
+ // no need to test with 20000 lines
+ const auto TestBacklogSize = 111;
+ auto model = new ProtocolItemModel(this, false, TestBacklogSize);
+
+ new QAbstractItemModelTester(model, this);
+
+ // populate with dummy data
+ auto item = SyncFileItemPtr::create();
+ for (int i = 0; i < TestBacklogSize * 1.1; ++i) {
+ model->addProtocolItem({ ProtocolItem(QStringLiteral("foo") + QString::number(i), item) });
+ }
+
+ const auto oldSize = model->rowCount();
+ QCOMPARE(oldSize, TestBacklogSize);
+ // pick one from the middle
+ const auto toBeRemoved = model->protocolItem(model->index(TestBacklogSize / 2, 0));
+ model->remove([&toBeRemoved](const ProtocolItem &pi) {
+ return pi.folderName() == toBeRemoved.folderName();
+ });
+ QCOMPARE(oldSize - 1, model->rowCount());
+ }
+};
+}
+
+QTEST_GUILESS_MAIN(OCC::TestProtocolModel)
+#include "testprotocolmodel.moc"