Test important properties in testfiletagmodel
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 25 Apr 2023 14:18:36 +0000 (22:18 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 16 May 2023 10:23:33 +0000 (18:23 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
test/testfiletagmodel.cpp

index 2cc7f28eba3f133e54d7d0028f54691db4884b8f..581dec61e3d5949c3c6b7acc32833652116ab56f 100644 (file)
@@ -104,6 +104,28 @@ private slots:
         };
     }
 
+    void testModelMainProps()
+    {
+        auto fileTagModel = FileTagModel(testFilePath, _account);
+        const auto fileTagModelTester = QAbstractItemModelTester(&fileTagModel);
+        QSignalSpy fileTagsChanged(&fileTagModel, &FileTagModel::totalTagsChanged);
+        fileTagsChanged.wait(1000);
+
+        QCOMPARE(fileTagModel.serverRelativePath(), testFilePath);
+        QCOMPARE(fileTagModel.account(), _account);
+
+        QSignalSpy serverRelativePathChangedSpy(&fileTagModel, &FileTagModel::serverRelativePathChanged);
+        fileTagModel.setServerRelativePath("");
+        QCOMPARE(serverRelativePathChangedSpy.count(), 1);
+        QCOMPARE(fileTagModel.serverRelativePath(), "");
+
+        QSignalSpy accountChangedSpy(&fileTagModel, &FileTagModel::accountChanged);
+        const AccountPtr testAccount;
+        fileTagModel.setAccount(testAccount);
+        QCOMPARE(accountChangedSpy.count(), 1);
+        QCOMPARE(fileTagModel.account(), testAccount);
+    }
+
     void testModelTagFetch()
     {
         auto fileTagModel = FileTagModel(testFilePath, _account);