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 <QtTest> 0022 #include "data/rolisteammimedata.h" 0023 #include "media/mediatype.h" 0024 #include <helper.h> 0025 #include <QSignalSpy> 0026 0027 class RolisteamMimeDataTest : public QObject 0028 { 0029 Q_OBJECT 0030 public: 0031 RolisteamMimeDataTest(); 0032 0033 private Q_SLOTS: 0034 void testGetSet(); 0035 0036 private: 0037 RolisteamMimeData m_data; 0038 }; 0039 0040 RolisteamMimeDataTest::RolisteamMimeDataTest() 0041 { 0042 0043 } 0044 0045 void RolisteamMimeDataTest::testGetSet() 0046 { 0047 QStringList list{Core::mimedata::MIME_KEY_PERSON_DATA, 0048 Core::mimedata::MIME_KEY_DICE_ALIAS_DATA, 0049 Core::mimedata::MIME_KEY_MEDIA_UUID, 0050 Core::mimedata::MIME_KEY_NPC_ID}; 0051 0052 for(auto s : list) 0053 m_data.hasFormat(s); 0054 0055 auto uuid = Helper::randomString(); 0056 QSignalSpy spy(&m_data, &RolisteamMimeData::mediaUuidChanged); 0057 m_data.setMediaUuid(uuid); 0058 m_data.setMediaUuid(uuid); 0059 QCOMPARE(m_data.mediaUuid(), uuid); 0060 QCOMPARE(spy.count(), 1); 0061 0062 uuid = Helper::randomString(); 0063 QSignalSpy spy2(&m_data, &RolisteamMimeData::npcUuidChanged); 0064 m_data.setNpcUuid(uuid); 0065 m_data.setNpcUuid(uuid); 0066 QCOMPARE(m_data.npcUuid(), uuid); 0067 QCOMPARE(spy2.count(), 1); 0068 0069 0070 0071 auto aName = Helper::randomString(); 0072 auto aCmd = Helper::randomString(); 0073 QSignalSpy spy3(&m_data, &RolisteamMimeData::aliasChanged); 0074 m_data.setAlias(aName, aCmd, true); 0075 0076 QCOMPARE(m_data.alias().command(), aCmd); 0077 QCOMPARE(spy2.count(), 1); 0078 } 0079 0080 QTEST_MAIN(RolisteamMimeDataTest); 0081 0082 #include "tst_rolisteammimedata.moc"