File indexing completed on 2024-05-12 05:40:50
0001 /*************************************************************************** 0002 * Copyright (C) 2011 by Renaud Guezennec * 0003 * renaud@rolisteam.org * 0004 * * 0005 * Rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #include <QDir> 0022 #include <QString> 0023 #include <QtTest> 0024 #include <data/cleveruri.h> 0025 #include <data/cleverurimimedata.h> 0026 #include <helper.h> 0027 0028 class DataCleverURITest : public QObject 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 DataCleverURITest(); 0034 0035 private Q_SLOTS: 0036 void testCleverURISetGet(); 0037 void testMime(); 0038 void initTestCase(); 0039 void cleanupTestCase(); 0040 0041 private: 0042 CleverURI* m_cleverURI; 0043 }; 0044 0045 DataCleverURITest::DataCleverURITest() {} 0046 0047 void DataCleverURITest::initTestCase() 0048 { 0049 m_cleverURI= new CleverURI(Core::ContentType::CHARACTERSHEET); 0050 } 0051 0052 void DataCleverURITest::cleanupTestCase() 0053 { 0054 delete m_cleverURI; 0055 } 0056 void DataCleverURITest::testCleverURISetGet() 0057 { 0058 m_cleverURI->setContentType(Core::ContentType::CHARACTERSHEET); 0059 QVERIFY2(m_cleverURI->contentType() == Core::ContentType::CHARACTERSHEET, "CHARACTERSHEET is not the current type"); 0060 0061 m_cleverURI->setContentType(Core::ContentType::PICTURE); 0062 QVERIFY2(m_cleverURI->contentType() == Core::ContentType::PICTURE, "PICTURE is not the current type"); 0063 0064 /* m_cleverURI->setContentType(Core::ContentType::SONG); 0065 QVERIFY2(m_cleverURI->contentType() == Core::ContentType::SONG, "SONG is not the current type"); 0066 0067 m_cleverURI->setContentType(Core::ContentType::CHAT); 0068 QVERIFY2(m_cleverURI->contentType() == Core::ContentType::CHAT, "TCHAT is not the current type");*/ 0069 0070 m_cleverURI->setContentType(Core::ContentType::NOTES); 0071 QVERIFY2(m_cleverURI->contentType() == Core::ContentType::NOTES, "TEXT is not the current type"); 0072 0073 QString path("/foo/bar/file.map"); 0074 m_cleverURI->setPath(path); 0075 m_cleverURI->setName(QStringLiteral("file")); 0076 QVERIFY2(m_cleverURI->path() == path, "URI is wrong!"); 0077 0078 QVERIFY2(m_cleverURI->getData(ResourcesNode::NAME).toString() == "file", "ShortName is wrong!"); 0079 0080 QVERIFY2(m_cleverURI->hasChildren() == false, "CleverURI has children, that should not be!"); 0081 } 0082 0083 void DataCleverURITest::testMime() 0084 { 0085 CleverUriMimeData data; 0086 0087 data.addResourceNode(nullptr); 0088 QCOMPARE(data.getList().size(), 0); 0089 data.addResourceNode(m_cleverURI); 0090 QCOMPARE(data.getList().size(), 1); 0091 QVERIFY(!data.hasFormat(Helper::randomString())); 0092 QVERIFY(data.hasFormat("rolisteam/cleverurilist")); 0093 } 0094 0095 QTEST_MAIN(DataCleverURITest); 0096 0097 #include "tst_datacleveruritest.moc"