things builds, but the test is fubar'd until i figure out how to get the

.desktop files over to the builddir

svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=458312
This commit is contained in:
Aaron J. Seigo 2005-09-07 20:23:08 +00:00
parent 7b202ba764
commit 3ce6b30e51
7 changed files with 135 additions and 65 deletions

21
Makefile.am Normal file
View File

@ -0,0 +1,21 @@
INCLUDES = $(all_includes)
lib_LTLIBRARIES = libplasma.la
libplasma_la_SOURCES = appletinfo.cpp
libplasma_la_METASOURCES = AUTO
libplasma_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -no-undefined
libplasma_la_LIBADD = $(LIB_KIO)
libplasma_la_includedir = $(includedir)/plasma
noinst_HEADERS =
libplasma_la_include_HEADERS = appletinfo.h
#kde_kcfg_DATA = plasmaSettings.kcfg extensionSettings.kcfg
messages: rc.cpp
$(XGETTEXT) *.cpp *.h -o $(podir)/libplasma.pot

11
README Normal file
View File

@ -0,0 +1,11 @@
libplasma
This directory contains the classes making up libplasma, which provides the
core framework used by Plasma and its components. This includes applet and
extension definitions and loading, common GUI elements, etc.
Domain specific sets of functionality, e.g. for network awareness or sensors,
are not found here but in one of the Plasma Engines.
Please refer to the Plasma website (http://plasma.kde.org) for API
documentation and design documents regrading this lbirary.

View File

@ -32,7 +32,7 @@ class AppletInfo::Private
{ {
public: public:
Private() Private()
unique(false), : unique(false),
hidden(false) hidden(false)
{} {}
@ -47,14 +47,13 @@ public:
bool hidden; bool hidden;
}; };
AppletInfo::AppletInfo(const QString& deskFile) AppletInfo::AppletInfo(const QString& desktopFile)
{ {
d = new Private; d = new Private;
QFileInfo fi(deskFile); QFileInfo fi(desktopFile);
d->desktopFilePath = fi.absFilePath(); d->desktopFilePath = fi.absFilePath();
d->desktopFile = fi.fileName(); d->desktopFile = fi.fileName();
KDesktopFile df(desktopFile, true);
KDesktopFile df(deskFile);
// set the appletssimple attributes // set the appletssimple attributes
setName(df.readName()); setName(df.readName());
@ -65,7 +64,7 @@ AppletInfo::AppletInfo(const QString& deskFile)
setLibrary(df.readEntry("X-KDE-Library")); setLibrary(df.readEntry("X-KDE-Library"));
// language the applet is written in // language the applet is written in
setLanguage(df.readEntry("X-KDE-LanguageBindings", "native").toLower()); setLanguageBindings(df.readEntry("X-KDE-LanguageBindings", "native").toLower());
// is it a unique applet? // is it a unique applet?
setUnique(df.readBoolEntry("X-KDE-UniqueApplet", false)); setUnique(df.readBoolEntry("X-KDE-UniqueApplet", false));
@ -112,6 +111,11 @@ QString AppletInfo::library() const
return d->lib; return d->lib;
} }
QString AppletInfo::languageBindings() const
{
return d->languageBindings;
}
QString AppletInfo::desktopFilePath() const QString AppletInfo::desktopFilePath() const
{ {
return d->desktopFilePath; return d->desktopFilePath;
@ -129,11 +133,11 @@ QString AppletInfo::generateConfigFileName() const
if (d->unique) if (d->unique)
{ {
d->configFile.append("rc"); configFile.append("rc");
} }
else else
{ {
d->configFile.append("_") configFile.append("_")
.append(kapp->randomString(20).lower()) .append(kapp->randomString(20).lower())
.append("_rc"); .append("_rc");
} }
@ -171,6 +175,11 @@ void AppletInfo::setLibrary(const QString &lib)
d->lib = lib; d->lib = lib;
} }
void AppletInfo::setLanguageBindings(const QString &language)
{
d->languageBindings = language;
}
void AppletInfo::setUnique(bool u) void AppletInfo::setUnique(bool u)
{ {
d->unique = u; d->unique = u;
@ -178,12 +187,12 @@ void AppletInfo::setUnique(bool u)
bool AppletInfo::operator!=(const AppletInfo& rhs) const bool AppletInfo::operator!=(const AppletInfo& rhs) const
{ {
return configFile() != rhs.configFile(); return library() != rhs.library();
} }
bool AppletInfo::operator==(const AppletInfo& rhs) const bool AppletInfo::operator==(const AppletInfo& rhs) const
{ {
return configFile() == rhs.configFile(); return library() == rhs.library();
} }
bool AppletInfo::operator<(const AppletInfo& rhs) const bool AppletInfo::operator<(const AppletInfo& rhs) const

View File

@ -136,12 +136,12 @@ class KDE_EXPORT AppletInfo
bool operator<=(const AppletInfo& rhs) const; bool operator<=(const AppletInfo& rhs) const;
/** /**
* Inequality operator, for sorting by name in lists * Inequality operator. Compares the library used by each.
*/ */
bool operator!=(const AppletInfo& rhs) const; bool operator!=(const AppletInfo& rhs) const;
/** /**
* Less than operator, for sorting by name in lists * Less than operator. Compares the library used by each.
*/ */
bool operator==(const AppletInfo& rhs) const; bool operator==(const AppletInfo& rhs) const;
@ -150,6 +150,7 @@ class KDE_EXPORT AppletInfo
void setComment(const QString& comment); void setComment(const QString& comment);
void setIcon(const QString& icon); void setIcon(const QString& icon);
void setLibrary(const QString& lib); void setLibrary(const QString& lib);
void setLanguageBindings(const QString& language);
void setUnique(bool u); void setUnique(bool u);
class Private; class Private;

11
tests/Makefile.am Normal file
View File

@ -0,0 +1,11 @@
INCLUDES = -I$(top_srcdir)/workspace/plasma/lib $(all_includes)
AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH)
noinst_PROGRAMS = testAppletInfo
noinst_HEADERS = testAppletInfo.h
METASOURCES = AUTO
LDADD = ../libplasma.la -lQtTest_debug
testAppletInfo_SOURCES = testAppletInfo.cpp

View File

@ -20,12 +20,17 @@ Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QDir> #include <QDir>
#include <kaboutdata.h>
#include <kinstance.h>
#include "appletinfo.h"
#include "testAppletInfo.h" #include "testAppletInfo.h"
#include "appletInfo.h"
TestAppletInfo::TestAppletInfo(QObject* parent) TestAppletInfo::TestAppletInfo(QObject* parent)
: QObject(parent) : QObject(parent)
{ {
m_aboutData = new KAboutData("Test Applet Info", "testappletinfo", "1");
m_instance = new KInstance("testappletinfo");
QString pwd = QDir::currentPath(); QString pwd = QDir::currentPath();
notUniqueNative = new Plasma::AppletInfo(pwd + "/nativeApplet.desktop"); notUniqueNative = new Plasma::AppletInfo(pwd + "/nativeApplet.desktop");
uniqueJavascript = new Plasma::AppletInfo(pwd + "/uniqueJavaScriptApplet.desktop"); uniqueJavascript = new Plasma::AppletInfo(pwd + "/uniqueJavaScriptApplet.desktop");
@ -36,9 +41,9 @@ void TestAppletInfo::name_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.name() *t.newData("Non-Unique Native Applet") << notUniqueNative->name()
<< "Non-Unique Native Applet"; << "Non-Unique Native Applet";
*t.newData("Unique Javascript Applet") << t.name() *t.newData("Unique Javascript Applet") << uniqueJavascript->name()
<< "Unique Javascript Applet"; << "Unique Javascript Applet";
} }
@ -55,9 +60,9 @@ void TestAppletInfo::comment_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.comment() *t.newData("Non-Unique Native Applet") << notUniqueNative->comment()
<< "A natively compiled applet"; << "A natively compiled applet";
*t.newData("Unique Javascript Applet") << t.comment() *t.newData("Unique Javascript Applet") << uniqueJavascript->comment()
<< "An applet written in JavaScript"; << "An applet written in JavaScript";
} }
@ -74,9 +79,9 @@ void TestAppletInfo::icon_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.icon() *t.newData("Non-Unique Native Applet") << notUniqueNative->icon()
<< "native"; << "native";
*t.newData("Unique Javascript Applet") << t.icon() *t.newData("Unique Javascript Applet") << uniqueJavascript->icon()
<< "javascript"; << "javascript";
} }
@ -93,9 +98,9 @@ void TestAppletInfo::library_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.library() *t.newData("Non-Unique Native Applet") << notUniqueNative->library()
<< "plasma_applet_native"; << "plasma_applet_native";
*t.newData("Unique Javascript Applet") << t.library() *t.newData("Unique Javascript Applet") << uniqueJavascript->library()
<< "plasma_applet_javascript"; << "plasma_applet_javascript";
} }
@ -112,9 +117,9 @@ void TestAppletInfo::languageBindings_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.languageBindings() *t.newData("Non-Unique Native Applet") << notUniqueNative->languageBindings()
<< "native"; << "native";
*t.newData("Unique Javascript Applet") << t.languageBindings() *t.newData("Unique Javascript Applet") << uniqueJavascript->languageBindings()
<< "javascript"; << "javascript";
} }
@ -133,9 +138,9 @@ void TestAppletInfo::desktopFilePath_data(QtTestTable &t)
QString pwd = QDir::currentPath(); QString pwd = QDir::currentPath();
*t.newData("Non-Unique Native Applet") << t.desktopFilePath() *t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFilePath()
<< pwd + "/nativeApplet.desktop"; << pwd + "/nativeApplet.desktop";
*t.newData("Unique Javascript Applet") << t.desktopFilePath() *t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFilePath()
<< pwd + "/uniqueJavaScriptApplet.desktop"; << pwd + "/uniqueJavaScriptApplet.desktop";
} }
@ -152,9 +157,9 @@ void TestAppletInfo::desktopFile_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.desktopFile() *t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFile()
<< "nativeApplet.desktop"; << "nativeApplet.desktop";
*t.newData("Unique Javascript Applet") << t.desktopFile() *t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFile()
<< "uniqueJavaScriptApplet.desktop"; << "uniqueJavaScriptApplet.desktop";
} }
@ -166,14 +171,14 @@ void TestAppletInfo::desktopFile()
COMPARE(expected, actual); COMPARE(expected, actual);
} }
void TestAppletInfo::desktopFile_data(QtTestTable &t) void TestAppletInfo::unique_data(QtTestTable &t)
{ {
t.defineElement("QString", "expected"); t.defineElement("bool", "expected");
t.defineElement("QString", "actual"); t.defineElement("bool", "actual");
*t.newData("Non-Unique Native Applet") << t.unique() *t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
<< "nativeApplet.desktop"; << "nativeApplet.desktop";
*t.newData("Unique Javascript Applet") << t.unique() *t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
<< "uniqueJavaScriptApplet.desktop"; << "uniqueJavaScriptApplet.desktop";
} }
@ -190,9 +195,9 @@ void TestAppletInfo::hidden_data(QtTestTable &t)
t.defineElement("QString", "expected"); t.defineElement("QString", "expected");
t.defineElement("QString", "actual"); t.defineElement("QString", "actual");
*t.newData("Non-Unique Native Applet") << t.unique() *t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
<< "nativeApplet.desktop"; << "nativeApplet.desktop";
*t.newData("Unique Javascript Applet") << t.unique() *t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
<< "uniqueJavaScriptApplet.desktop"; << "uniqueJavaScriptApplet.desktop";
} }
@ -204,5 +209,5 @@ void TestAppletInfo::hidden()
COMPARE(expected, actual); COMPARE(expected, actual);
} }
QTTEST_MAIN(TestQString) QTTEST_MAIN(TestAppletInfo)
#include "testAppletInfo.moc" #include "testAppletInfo.moc"

View File

@ -18,9 +18,17 @@ Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#include <QtTest> #ifndef testappletinfo_h_
#define testappletinfo_h_
class Plasma::AppletInfo; #include <QtTest/QtTest>
namespace Plasma
{
class AppletInfo;
}
class KAboutData;
class KInstance;
class TestAppletInfo: public QObject class TestAppletInfo: public QObject
{ {
@ -29,26 +37,30 @@ class TestAppletInfo: public QObject
TestAppletInfo(QObject* parent = 0); TestAppletInfo(QObject* parent = 0);
private slots: private slots:
void name_data(QTestTable& t); void name_data(QtTestTable& t);
void name(); void name();
void comment_data(QTestTable& t); void comment_data(QtTestTable& t);
void comment(); void comment();
void icon_data(QTestTable& t); void icon_data(QtTestTable& t);
void icon(); void icon();
void library_data(QTestTable& t); void library_data(QtTestTable& t);
void library(); void library();
void languageBindings_data(QTestTable& t); void languageBindings_data(QtTestTable& t);
void languageBindings(); void languageBindings();
void desktopFilePath_data(QTestTable& t); void desktopFilePath_data(QtTestTable& t);
void desktopFilePath(); void desktopFilePath();
void desktopFile_data(QTestTable& t); void desktopFile_data(QtTestTable& t);
void desktopFile(); void desktopFile();
void unique_data(QTestTable& t); void unique_data(QtTestTable& t);
void unique(); void unique();
void hidden_data(QTestTable& t); void hidden_data(QtTestTable& t);
void hidden(); void hidden();
private: private:
Plasma::AppletInfo* notUniqueNative; Plasma::AppletInfo* notUniqueNative;
Plasma::AppletInfo* uniqueJavascript; Plasma::AppletInfo* uniqueJavascript;
KAboutData* m_aboutData;
KInstance* m_instance;
}; };
#endif