2005-09-07 00:51:35 +02:00
|
|
|
/*
|
|
|
|
Unit tests for Plasma::AppletInfo
|
|
|
|
|
|
|
|
Copyright (C) 2005 Aaron Seigo <aseigo@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License version 2 as published by
|
|
|
|
the Free Software Foundation.
|
|
|
|
|
|
|
|
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, write to the Free Software
|
2005-10-05 10:44:32 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-09-07 00:51:35 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QDir>
|
2005-10-05 22:44:14 +02:00
|
|
|
#include <QMimeData>
|
2005-09-07 00:51:35 +02:00
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
#include <kaboutdata.h>
|
|
|
|
#include <kinstance.h>
|
|
|
|
|
|
|
|
#include "appletinfo.h"
|
2005-09-07 00:51:35 +02:00
|
|
|
#include "testAppletInfo.h"
|
|
|
|
|
|
|
|
TestAppletInfo::TestAppletInfo(QObject* parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
m_aboutData = new KAboutData("Test Applet Info", "testappletinfo", "1");
|
|
|
|
m_instance = new KInstance("testappletinfo");
|
2005-09-07 00:51:35 +02:00
|
|
|
QString pwd = QDir::currentPath();
|
|
|
|
notUniqueNative = new Plasma::AppletInfo(pwd + "/nativeApplet.desktop");
|
|
|
|
uniqueJavascript = new Plasma::AppletInfo(pwd + "/uniqueJavaScriptApplet.desktop");
|
|
|
|
}
|
|
|
|
|
2005-09-07 22:49:49 +02:00
|
|
|
TestAppletInfo::~TestAppletInfo()
|
|
|
|
{
|
|
|
|
delete m_instance;
|
|
|
|
delete m_aboutData;
|
|
|
|
}
|
|
|
|
|
2005-09-07 00:51:35 +02:00
|
|
|
void TestAppletInfo::name_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->name()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "Non-Unique Native Applet";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->name()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "Unique Javascript Applet";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::name()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::comment_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->comment()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "A natively compiled applet";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->comment()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "An applet written in JavaScript";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::comment()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::icon_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->icon()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "native";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->icon()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "javascript";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::icon()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::library_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->library()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "plasma_applet_native";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->library()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "plasma_applet_javascript";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::library()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::languageBindings_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->languageBindings()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "native";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->languageBindings()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "javascript";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::languageBindings()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::desktopFilePath_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
|
|
|
QString pwd = QDir::currentPath();
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFilePath()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< pwd + "/nativeApplet.desktop";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFilePath()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< pwd + "/uniqueJavaScriptApplet.desktop";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::desktopFilePath()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::desktopFile_data(QtTestTable &t)
|
|
|
|
{
|
|
|
|
t.defineElement("QString", "expected");
|
|
|
|
t.defineElement("QString", "actual");
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFile()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "nativeApplet.desktop";
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFile()
|
2005-09-07 00:51:35 +02:00
|
|
|
<< "uniqueJavaScriptApplet.desktop";
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::desktopFile()
|
|
|
|
{
|
|
|
|
FETCH(QString, expected);
|
|
|
|
FETCH(QString, actual);
|
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
void TestAppletInfo::unique_data(QtTestTable &t)
|
2005-09-07 00:51:35 +02:00
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
t.defineElement("bool", "expected");
|
|
|
|
t.defineElement("bool", "actual");
|
2005-09-07 00:51:35 +02:00
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
|
2005-09-07 22:49:49 +02:00
|
|
|
<< false;
|
2005-09-07 22:23:08 +02:00
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
|
2005-09-07 22:49:49 +02:00
|
|
|
<< true;
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::unique()
|
|
|
|
{
|
2005-09-07 22:49:49 +02:00
|
|
|
FETCH(bool, expected);
|
|
|
|
FETCH(bool, actual);
|
2005-09-07 00:51:35 +02:00
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::hidden_data(QtTestTable &t)
|
|
|
|
{
|
2005-09-07 22:49:49 +02:00
|
|
|
t.defineElement("bool", "expected");
|
|
|
|
t.defineElement("bool", "actual");
|
2005-09-07 00:51:35 +02:00
|
|
|
|
2005-09-07 22:49:49 +02:00
|
|
|
*t.newData("Non-Unique Native Applet") << notUniqueNative->hidden()
|
|
|
|
<< false;
|
|
|
|
*t.newData("Unique Javascript Applet") << uniqueJavascript->hidden()
|
|
|
|
<< true;
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::hidden()
|
|
|
|
{
|
2005-09-07 22:49:49 +02:00
|
|
|
FETCH(bool, expected);
|
|
|
|
FETCH(bool, actual);
|
2005-09-07 00:51:35 +02:00
|
|
|
|
|
|
|
COMPARE(expected, actual);
|
|
|
|
}
|
|
|
|
|
2005-10-03 19:37:22 +02:00
|
|
|
void TestAppletInfo::assignment()
|
|
|
|
{
|
|
|
|
Plasma::AppletInfo assigned = *notUniqueNative;
|
|
|
|
COMPARE(assigned.name(), notUniqueNative->name());
|
|
|
|
COMPARE(assigned.comment(), notUniqueNative->comment());
|
|
|
|
COMPARE(assigned.icon(), notUniqueNative->icon());
|
|
|
|
COMPARE(assigned.library(), notUniqueNative->library());
|
|
|
|
COMPARE(assigned.languageBindings(), notUniqueNative->languageBindings());
|
|
|
|
COMPARE(assigned.desktopFilePath(), notUniqueNative->desktopFilePath());
|
|
|
|
COMPARE(assigned.desktopFile(), notUniqueNative->desktopFile());
|
|
|
|
COMPARE(assigned.unique(), notUniqueNative->unique());
|
|
|
|
COMPARE(assigned.hidden(), notUniqueNative->hidden());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestAppletInfo::copyConstructor()
|
|
|
|
{
|
|
|
|
Plasma::AppletInfo* tempCopy = new Plasma::AppletInfo(*notUniqueNative);
|
|
|
|
Plasma::AppletInfo copied(*tempCopy);
|
|
|
|
delete tempCopy;
|
|
|
|
COMPARE(copied.name(), notUniqueNative->name());
|
|
|
|
COMPARE(copied.comment(), notUniqueNative->comment());
|
|
|
|
COMPARE(copied.icon(), notUniqueNative->icon());
|
|
|
|
COMPARE(copied.library(), notUniqueNative->library());
|
|
|
|
COMPARE(copied.languageBindings(), notUniqueNative->languageBindings());
|
|
|
|
COMPARE(copied.desktopFilePath(), notUniqueNative->desktopFilePath());
|
|
|
|
COMPARE(copied.desktopFile(), notUniqueNative->desktopFile());
|
|
|
|
COMPARE(copied.unique(), notUniqueNative->unique());
|
|
|
|
COMPARE(copied.hidden(), notUniqueNative->hidden());
|
|
|
|
}
|
|
|
|
|
2005-10-05 22:44:14 +02:00
|
|
|
void TestAppletInfo::dragAndDrop()
|
|
|
|
{
|
|
|
|
QMimeData* data = new QMimeData;
|
|
|
|
notUniqueNative->populateMimeData(data);
|
|
|
|
VERIFY(Plasma::AppletInfo::canDecode(data));
|
|
|
|
Plasma::AppletInfo dropped = Plasma::AppletInfo::fromMimeData(data);
|
|
|
|
COMPARE(dropped.desktopFile(), notUniqueNative->desktopFile());
|
|
|
|
delete data;
|
|
|
|
}
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
QTTEST_MAIN(TestAppletInfo)
|
2005-09-07 00:51:35 +02:00
|
|
|
#include "testAppletInfo.moc"
|