diff options
author | Alex Merry <dev@randomguy3.me.uk> | 2011-10-24 23:57:34 +0100 |
---|---|---|
committer | Alex Merry <dev@randomguy3.me.uk> | 2011-10-24 23:57:34 +0100 |
commit | 8d241d7fdb1ede91fbc144d90c8ce2eacff06d71 (patch) | |
tree | 8f405d40cbed8d1b26f36295dc3be1ec8fd2fe5d | |
parent | f64502e37be2864f8dcbb859fc5d81afe6f58275 (diff) |
Add widgets for displaying test information
-rw-r--r-- | mpris2/rootinterfacetest.cpp | 2 | ||||
-rw-r--r-- | mpris2/rootinterfacetest.h | 2 | ||||
-rw-r--r-- | mpris2/roottestwidget.cpp | 92 | ||||
-rw-r--r-- | mpris2/roottestwidget.h | 51 | ||||
-rw-r--r-- | mpris2/testconsole.cpp | 75 | ||||
-rw-r--r-- | mpris2/testconsole.h | 46 | ||||
-rw-r--r-- | mpristester.pro | 10 | ||||
-rw-r--r-- | ui/roottest.ui | 159 |
8 files changed, 432 insertions, 5 deletions
diff --git a/mpris2/rootinterfacetest.cpp b/mpris2/rootinterfacetest.cpp index 014bde6..095d375 100644 --- a/mpris2/rootinterfacetest.cpp +++ b/mpris2/rootinterfacetest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011 Alex Merry <alex.merry@kdemail.net> + * Copyright 2011 Alex Merry <dev@randomguy3.me.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/mpris2/rootinterfacetest.h b/mpris2/rootinterfacetest.h index 3064ab4..5e4481a 100644 --- a/mpris2/rootinterfacetest.h +++ b/mpris2/rootinterfacetest.h @@ -1,5 +1,5 @@ /* - * Copyright 2011 Alex Merry <alex.merry@kdemail.net> + * Copyright 2011 Alex Merry <dev@randomguy3.me.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/mpris2/roottestwidget.cpp b/mpris2/roottestwidget.cpp new file mode 100644 index 0000000..08685a6 --- /dev/null +++ b/mpris2/roottestwidget.cpp @@ -0,0 +1,92 @@ +/* + Copyright (C) 2011 Alex Merry <dev@randomguy3.me.uk> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#include "roottestwidget.h" +#include "rootinterfacetest.h" + +using namespace Mpris2; + +RootTestWidget::RootTestWidget(RootInterfaceTest *test, QWidget *parent) + : QWidget(parent) +{ + ui.setupUi(this); + this->test = test; + connect(ui.raiseBtn, SIGNAL(clicked(bool)), + this->test, SLOT(testRaise())); + connect(ui.quitBtn, SIGNAL(clicked(bool)), + this->test, SLOT(testQuit())); +} + +RootTestWidget::~RootTestWidget() +{ +} + +void RootTestWidget::runInitialTest() +{ + test->initialTest(); + ui.raiseBtn->setEnabled(true); + ui.quitBtn->setEnabled(true); + updateProperties(); +} + +void RootTestWidget::runIncrementalTest() +{ + test->incrementalTest(); +} + +void RootTestWidget::propertiesChanged(const QStringList& properties) +{ + Q_UNUSED(properties) + updateProperties(); +} + +void RootTestWidget::updateProperties() +{ + if (test->properties().contains("Identity")) { + ui.identityLbl->setText(test->properties().value("Identity").toString()); + ui.identityLbl->setEnabled(true); + } + if (test->properties().contains("DesktopEntry")) { + ui.desktopFileLbl->setText(test->properties().value("DesktopEntry").toString()); + ui.desktopFileLbl->setEnabled(true); + } + if (test->properties().contains("CanRaise")) { + ui.canRaiseLbl->setText(test->properties().value("CanRaise").toBool() ? "Yes" : "No"); + ui.canRaiseLbl->setEnabled(true); + } + if (test->properties().contains("CanQuit")) { + ui.canQuitLbl->setText(test->properties().value("CanQuit").toBool() ? "Yes" : "No"); + ui.canQuitLbl->setEnabled(true); + } + if (test->properties().contains("HasTrackList")) { + ui.hasTracklistLbl->setText(test->properties().value("HasTrackList").toBool() ? "Yes" : "No"); + ui.hasTracklistLbl->setEnabled(true); + } + if (test->properties().contains("SupportedUriSchemes")) { + QStringList uriSchemes = test->properties().value("SupportedUriSchemes").toStringList(); + ui.uriSchemesList->addItems(uriSchemes); + ui.uriSchemesList->setEnabled(true); + } + if (test->properties().contains("SupportedMimeTypes")) { + QStringList mimetypes = test->properties().value("SupportedMimeTypes").toStringList(); + ui.mimetypesList->addItems(mimetypes); + ui.mimetypesList->setEnabled(true); + } +} + diff --git a/mpris2/roottestwidget.h b/mpris2/roottestwidget.h new file mode 100644 index 0000000..0dac1e5 --- /dev/null +++ b/mpris2/roottestwidget.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2011 Alex Merry <dev@randomguy3.me.uk> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#ifndef ROOTTESTWIDGET_H +#define ROOTTESTWIDGET_H + +#include <QWidget> +#include "ui_roottest.h" + +namespace Mpris2 +{ + class RootInterfaceTest; + class RootTestWidget : public QWidget + { + + public: + RootTestWidget(RootInterfaceTest *test, QWidget *parent = 0); + virtual ~RootTestWidget(); + + public slots: + void runInitialTest(); + void runIncrementalTest(); + + private slots: + void propertiesChanged(const QStringList& properties); + + private: + void updateProperties(); + + Ui_RootTestForm ui; + RootInterfaceTest* test; + }; +} + +#endif // ROOTTESTWIDGET_H diff --git a/mpris2/testconsole.cpp b/mpris2/testconsole.cpp new file mode 100644 index 0000000..fce6dd2 --- /dev/null +++ b/mpris2/testconsole.cpp @@ -0,0 +1,75 @@ +/* + Copyright (C) 2011 Alex Merry <dev@randomguy3.me.uk> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#include "testconsole.h" +#include <QTextEdit> +#include <QVBoxLayout> + +using namespace Mpris2; + +TestConsole::TestConsole(QWidget* parent) + : QWidget(parent) +{ + QVBoxLayout* layout = new QVBoxLayout(this); + edit = new QTextEdit(); + layout->addWidget(edit); + edit->setReadOnly(true); +} + +TestConsole::~TestConsole() +{ +} + +static QString locationName(InterfaceTest::LocationType locType, const QString& location) +{ + switch (locType) { + case InterfaceTest::Method: + return "method " + location; + case InterfaceTest::Property: + return "property " + location; + case InterfaceTest::Signal: + return "signal " + location; + default: + return location; + } +} + +void TestConsole::interfaceError(InterfaceTest::LocationType locType, const QString& location, const QString& desc) +{ + if (locType == Mpris2::InterfaceTest::Other && location.isEmpty()) + edit->append("Error: " + desc + "\n"); + else + edit->append("Error at " + locationName(locType, location) + ": " + desc + "\n"); +} + +void TestConsole::interfaceWarning(InterfaceTest::LocationType locType, const QString& location, const QString& desc) +{ + if (locType == Mpris2::InterfaceTest::Other && location.isEmpty()) + edit->append("Warning: " + desc + "\n"); + else + edit->append("Warning at " + locationName(locType, location) + ": " + desc + "\n"); +} + +void TestConsole::interfaceInfo(InterfaceTest::LocationType locType, const QString& location, const QString& desc) +{ + if (locType == Mpris2::InterfaceTest::Other && location.isEmpty()) + edit->append("Info: " + desc + "\n"); + else + edit->append("Info at " + locationName(locType, location) + ": " + desc + "\n"); +} diff --git a/mpris2/testconsole.h b/mpris2/testconsole.h new file mode 100644 index 0000000..46f621f --- /dev/null +++ b/mpris2/testconsole.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2011 Alex Merry <dev@randomguy3.me.uk> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + + +#ifndef TESTCONSOLE_H +#define TESTCONSOLE_H + +#include <QtGui/QWidget> +#include "interfacetest.h" + +class QTextEdit; +namespace Mpris2 +{ + class TestConsole : public QWidget + { + + public: + TestConsole(QWidget* parent = 0); + virtual ~TestConsole(); + + public slots: + void interfaceError(InterfaceTest::LocationType locType, const QString& location, const QString& desc); + void interfaceWarning(InterfaceTest::LocationType locType, const QString& location, const QString& desc); + void interfaceInfo(InterfaceTest::LocationType locType, const QString& location, const QString& desc); + + private: + QTextEdit* edit; + }; +} + +#endif // TESTCONSOLE_H diff --git a/mpristester.pro b/mpristester.pro index 3ce6062..a4d891f 100644 --- a/mpristester.pro +++ b/mpristester.pro @@ -4,15 +4,19 @@ QT += dbus HEADERS += window.h \ metadatamodel.h \ mpris2/interfacetest.h \ - mpris2/rootinterfacetest.h + mpris2/rootinterfacetest.h \ + mpris2/roottestwidget.h \ + mpris2/testconsole.h SOURCES += main.cpp \ window.cpp \ metadatamodel.cpp \ mpris2/interfacetest.cpp \ - mpris2/rootinterfacetest.cpp + mpris2/rootinterfacetest.cpp \ + mpris2/roottestwidget.cpp \ + mpris2/testconsole.cpp -FORMS += ui/window.ui +FORMS += ui/roottest.ui OTHER_FILES += \ dbus/2.0/TrackList_Node.xml \ diff --git a/ui/roottest.ui b/ui/roottest.ui new file mode 100644 index 0000000..5909cae --- /dev/null +++ b/ui/roottest.ui @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>RootTestForm</class> + <widget class="QWidget" name="RootTestForm"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>491</width> + <height>458</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="labelAppName"> + <property name="text"> + <string>Identity:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="identityLbl"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string><unknown></string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Desktop file:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="desktopFileLbl"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string><unknown></string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Can raise:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="canRaiseLbl"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string><unknown></string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="raiseBtn"> + <property name="text"> + <string>Raise</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Can quit</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QLabel" name="canQuitLbl"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string><unknown></string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="quitBtn"> + <property name="text"> + <string>Quit</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Has tracklist:</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="hasTracklistLbl"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string><unknown></string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_9"> + <property name="text"> + <string>Supported URI schemes:</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Supported mimetypes:</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QListWidget" name="uriSchemesList"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QListWidget" name="mimetypesList"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |