summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2012-04-20 19:41:37 +0100
committerAlex Merry <dev@randomguy3.me.uk>2012-04-20 19:41:37 +0100
commit33f84c4e17f353a6c36a4af29d561b56b36fe3f9 (patch)
treea3ca1425043b0e8818d59973a7d10d7bc6037d8c
parenta6fda32752feb31a6272010b7cd530b6901bb0f2 (diff)
Fullscreen property support
We now check for the Fullscreen and CanSetFullscreen properties (MPRIS 2.2).
-rw-r--r--mpris2/interfacetest.cpp20
-rw-r--r--mpris2/interfacetest.h5
-rw-r--r--mpris2/playertestwidget.cpp106
-rw-r--r--mpris2/playertestwidget.h4
-rw-r--r--mpris2/rootinterfacetest.cpp24
-rw-r--r--mpris2/rootinterfacetest.h9
-rw-r--r--mpris2/roottestwidget.cpp67
-rw-r--r--mpris2/roottestwidget.h5
-rw-r--r--ui/roottest.ui70
9 files changed, 228 insertions, 82 deletions
diff --git a/mpris2/interfacetest.cpp b/mpris2/interfacetest.cpp
index 592ac61..76aaf59 100644
--- a/mpris2/interfacetest.cpp
+++ b/mpris2/interfacetest.cpp
@@ -203,11 +203,18 @@ bool InterfaceTest::setProp(const QString& propName, const QDBusVariant& propVal
}
}
-
bool InterfaceTest::checkPropValid(const QString& propName, QVariant::Type expType, const QVariantMap& oldProps) {
if (!props.contains(propName)) {
emit interfaceError(Property, propName, "Property " + propName + " is missing");
return false;
+ } else {
+ return checkOptionalPropValid(propName, expType, oldProps);
+ }
+}
+
+bool InterfaceTest::checkOptionalPropValid(const QString& propName, QVariant::Type expType, const QVariantMap& oldProps) {
+ if (!props.contains(propName)) {
+ return false;
} else if (props.value(propName).type() != expType) {
// FIXME: generate D-Bus type description
const char * gotTypeCh = QDBusMetaType::typeToSignature(props.value(propName).userType());
@@ -234,6 +241,17 @@ bool InterfaceTest::checkPropValid(const QString& propName, QVariant::Type expTy
return true;
}
+bool InterfaceTest::checkOptionalNonEmptyStringPropValid(const QString& propName, const QVariantMap& oldProps) {
+ if (checkOptionalPropValid(propName, QVariant::String, oldProps)) {
+ if (props[propName].toString().isEmpty()) {
+ emit interfaceError(Property, propName, "Property " + propName + " is present, but empty");
+ } else {
+ return true;
+ }
+ }
+ return false;
+}
+
bool InterfaceTest::checkNonEmptyStringPropValid(const QString& propName, const QVariantMap& oldProps) {
if (checkPropValid(propName, QVariant::String, oldProps)) {
if (props[propName].toString().isEmpty()) {
diff --git a/mpris2/interfacetest.h b/mpris2/interfacetest.h
index 39f0fd6..d48128b 100644
--- a/mpris2/interfacetest.h
+++ b/mpris2/interfacetest.h
@@ -134,8 +134,13 @@ namespace Mpris2
bool checkPropValid(const QString& propName,
QVariant::Type expType,
const QVariantMap& oldProps = QVariantMap());
+ bool checkOptionalPropValid(const QString& propName,
+ QVariant::Type expType,
+ const QVariantMap& oldProps = QVariantMap());
bool checkNonEmptyStringPropValid(const QString& propName,
const QVariantMap& oldProps = QVariantMap());
+ bool checkOptionalNonEmptyStringPropValid(const QString& propName,
+ const QVariantMap& oldProps = QVariantMap());
void checkMetadata(const QVariantMap& metadata,
QStringList* errors,
QStringList* warnings,
diff --git a/mpris2/playertestwidget.cpp b/mpris2/playertestwidget.cpp
index 187919a..a208424 100644
--- a/mpris2/playertestwidget.cpp
+++ b/mpris2/playertestwidget.cpp
@@ -102,67 +102,34 @@ void PlayerTestWidget::propertiesChanged(const QStringList& properties)
{
Q_UNUSED(properties)
- if (test->properties().contains("PlaybackStatus")) {
- ui.playbackStatusLbl->setText(test->properties().value("PlaybackStatus").toString());
- ui.playbackStatusLbl->setEnabled(true);
- }
- if (test->properties().contains("LoopStatus")) {
- ui.loopStatusLbl->setText(test->properties().value("LoopStatus").toString());
- ui.loopStatusLbl->setEnabled(true);
- }
- if (test->properties().contains("CanGoNext")) {
- ui.canGoNextLbl->setText(test->properties().value("CanGoNext").toBool() ? "Yes" : "No");
- ui.canGoNextLbl->setEnabled(true);
- }
- if (test->properties().contains("CanGoPrevious")) {
- ui.canGoPrevLbl->setText(test->properties().value("CanGoPrevious").toBool() ? "Yes" : "No");
- ui.canGoPrevLbl->setEnabled(true);
- }
- if (test->properties().contains("CanPlay")) {
- ui.canPlayLbl->setText(test->properties().value("CanPlay").toBool() ? "Yes" : "No");
- ui.canPlayLbl->setEnabled(true);
- }
- if (test->properties().contains("CanPause")) {
- ui.canPauseLbl->setText(test->properties().value("CanPause").toBool() ? "Yes" : "No");
- ui.canPauseLbl->setEnabled(true);
- }
- if (test->properties().contains("CanSeek")) {
- ui.canSeekLbl->setText(test->properties().value("CanSeek").toBool() ? "Yes" : "No");
- ui.canSeekLbl->setEnabled(true);
- }
- if (test->properties().contains("CanControl")) {
- ui.canControlLbl->setText(test->properties().value("CanControl").toBool() ? "Yes" : "No");
- ui.canControlLbl->setEnabled(true);
- }
- if (test->properties().contains("Shuffle")) {
- ui.shuffleLbl->setText(test->properties().value("Shuffle").toBool() ? "Yes" : "No");
- ui.shuffleLbl->setEnabled(true);
- }
- if (test->properties().contains("Rate")) {
- ui.rateLbl->setText(QString::number(test->properties().value("Rate").toDouble(), 'g', 2));
- ui.rateLbl->setEnabled(true);
- }
- if (test->properties().contains("MinimumRate")) {
- ui.minRateLbl->setText(QString::number(test->properties().value("MinimumRate").toDouble(), 'g', 2));
- ui.minRateLbl->setEnabled(true);
- }
- if (test->properties().contains("MaximumRate")) {
- ui.maxRateLbl->setText(QString::number(test->properties().value("MaximumRate").toDouble(), 'g', 2));
- ui.maxRateLbl->setEnabled(true);
- }
- if (test->properties().contains("Volume")) {
- ui.volumeLbl->setText(QString::number(test->properties().value("Volume").toDouble(), 'g', 2));
- ui.volumeLbl->setEnabled(true);
- }
+ updateStringPropLabel("PlaybackStatus", ui.playbackStatusLbl);
+ updateStringPropLabel("LoopStatus", ui.loopStatusLbl);
+ updateBoolPropLabel("CanGoNext", ui.canGoNextLbl);
+ updateBoolPropLabel("CanGoPrevious", ui.canGoPrevLbl);
+ updateBoolPropLabel("CanPlay", ui.canPlayLbl);
+ updateBoolPropLabel("CanPause", ui.canPauseLbl);
+ updateBoolPropLabel("CanSeek", ui.canSeekLbl);
+ updateBoolPropLabel("CanControl", ui.canControlLbl);
+ updateBoolPropLabel("Shuffle", ui.shuffleLbl);
+ updateDoublePropLabel("Rate", ui.rateLbl);
+ updateDoublePropLabel("MinimumRate", ui.minRateLbl);
+ updateDoublePropLabel("MaximumRate", ui.maxRateLbl);
+ updateDoublePropLabel("Volume", ui.volumeLbl);
if (test->properties().contains("Position")) {
ui.lastKnownPosLbl->setText(QString::number(test->properties().value("Position").toLongLong()) + "ns");
ui.lastKnownPosLbl->setEnabled(true);
+ } else {
+ ui.lastKnownPosLbl->setText("<unknown>");
+ ui.lastKnownPosLbl->setEnabled(false);
}
if (test->predictedPosition() >= 0) {
ui.estPosLbl->setText(QString::number(test->predictedPosition()) + "ns");
ui.estPosLbl->setEnabled(true);
if (!estPosTimer->isActive())
estPosTimer->start();
+ } else {
+ ui.estPosLbl->setText("<unknown>");
+ ui.estPosLbl->setEnabled(false);
}
if (test->properties().contains("Metadata")) {
if (test->properties().value("Metadata").type() != QVariant::Map) {
@@ -178,6 +145,8 @@ void PlayerTestWidget::propertiesChanged(const QStringList& properties)
ui.setPosTrackIdEdit->setText(trackId);
lastSetTrackId = trackId;
}
+ } else {
+ ui.metadataTableView->setEnabled(false);
}
}
@@ -242,4 +211,37 @@ void PlayerTestWidget::testSetRate()
test->testSetRate(ui.rateSpinBox->value());
}
+void PlayerTestWidget::updateBoolPropLabel(const QString& name, QLabel *label)
+{
+ if (test->properties().contains(name)) {
+ label->setText(test->properties().value(name).toBool() ? "Yes" : "No");
+ label->setEnabled(true);
+ } else {
+ label->setText("<unknown>");
+ label->setEnabled(false);
+ }
+}
+
+void PlayerTestWidget::updateStringPropLabel(const QString& name, QLabel *label)
+{
+ if (test->properties().contains(name)) {
+ label->setText(test->properties().value(name).toString());
+ label->setEnabled(true);
+ } else {
+ label->setText("<unknown>");
+ label->setEnabled(false);
+ }
+}
+
+void PlayerTestWidget::updateDoublePropLabel(const QString& name, QLabel *label)
+{
+ if (test->properties().contains(name)) {
+ label->setText(QString::number(test->properties().value(name).toDouble(), 'g', 2));
+ label->setEnabled(true);
+ } else {
+ label->setText("<unknown>");
+ label->setEnabled(false);
+ }
+}
+
// vim:et:sw=4:sts=4
diff --git a/mpris2/playertestwidget.h b/mpris2/playertestwidget.h
index 92a26e9..c3f9b0f 100644
--- a/mpris2/playertestwidget.h
+++ b/mpris2/playertestwidget.h
@@ -56,6 +56,10 @@ namespace Mpris2 {
void updateEstPos();
private:
+ void updateBoolPropLabel(const QString& name, QLabel *label);
+ void updateStringPropLabel(const QString& name, QLabel *label);
+ void updateDoublePropLabel(const QString& name, QLabel *label);
+
Ui_PlayerTestForm ui;
PlayerInterfaceTest *test;
QTimer *estPosTimer;
diff --git a/mpris2/rootinterfacetest.cpp b/mpris2/rootinterfacetest.cpp
index b73eba0..eddcf5f 100644
--- a/mpris2/rootinterfacetest.cpp
+++ b/mpris2/rootinterfacetest.cpp
@@ -195,6 +195,18 @@ void RootInterfaceTest::checkProps(const QVariantMap& oldProps)
checkPropValid("CanQuit", QVariant::Bool, oldProps);
checkPropValid("CanRaise", QVariant::Bool, oldProps);
checkPropValid("HasTrackList", QVariant::Bool, oldProps);
+ if (props.contains("Fullscreen") || props.contains("CanSetFullscreen")) {
+ if (!props.contains("Fullscreen")) {
+ emit interfaceError(Property, "Fullscreen", "If you provide CanSetFullscreen, you must also provide Fullscreen");
+ } else {
+ checkPropValid("Fullscreen", QVariant::Bool, oldProps);
+ }
+ if (!props.contains("CanSetFullscreen")) {
+ emit interfaceError(Property, "CanSetFullscreen", "If you provide Fullscreen, you must also provide CanSetFullscreen");
+ } else {
+ checkPropValid("CanSetFullscreen", QVariant::Bool, oldProps);
+ }
+ }
checkPropertyIdentity(oldProps);
checkPropertyDesktopEntry(oldProps);
checkPropertySupportedUriSchemes(oldProps);
@@ -207,6 +219,10 @@ void RootInterfaceTest::checkUpdatedProperty(const QString& propName)
checkPropValid("CanQuit", QVariant::Bool);
} else if (propName == "CanRaise") {
checkPropValid("CanRaise", QVariant::Bool);
+ } else if (propName == "CanSetFullscreen") {
+ checkPropValid("CanSetFullscreen", QVariant::Bool);
+ } else if (propName == "Fullscreen") {
+ checkPropValid("Fullscreen", QVariant::Bool);
} else if (propName == "HasTrackList") {
checkPropValid("HasTrackList", QVariant::Bool);
} else if (propName == "Identity") {
@@ -249,6 +265,14 @@ void RootInterfaceTest::testRaise()
}
}
+void RootInterfaceTest::testSetFullscreen(bool value)
+{
+ setProp("Fullscreen", QDBusVariant(QVariant(value)),
+ props["CanSetFullscreen"].toBool()
+ ? PropDisallowErrors
+ : PropAllowErrors);
+}
+
void RootInterfaceTest::checkConsistency(const QVariantMap& oldProps)
{
}
diff --git a/mpris2/rootinterfacetest.h b/mpris2/rootinterfacetest.h
index 80f328b..8ca99f8 100644
--- a/mpris2/rootinterfacetest.h
+++ b/mpris2/rootinterfacetest.h
@@ -55,6 +55,15 @@ namespace Mpris2
*/
void testRaise();
+ /**
+ * Attempt to set the Fullscreen property
+ *
+ * There is no reasonable way to automatically test that this was
+ * successful. However, if CanSetFullscreen is true and the method
+ * was not found, an error will be reported.
+ */
+ void testSetFullscreen(bool value);
+
protected:
virtual void checkProps(const QVariantMap& oldProps = QVariantMap());
virtual void checkUpdatedProperty(const QString& propName);
diff --git a/mpris2/roottestwidget.cpp b/mpris2/roottestwidget.cpp
index 0ac728d..992e0ce 100644
--- a/mpris2/roottestwidget.cpp
+++ b/mpris2/roottestwidget.cpp
@@ -31,6 +31,10 @@ RootTestWidget::RootTestWidget(RootInterfaceTest *test, QWidget *parent)
this->test, SLOT(testRaise()));
connect(ui.quitBtn, SIGNAL(clicked(bool)),
this->test, SLOT(testQuit()));
+ connect(ui.fullscreenOnBtn, SIGNAL(clicked(bool)),
+ this, SLOT(testSetFullScreenOn()));
+ connect(ui.fullscreenOffBtn, SIGNAL(clicked(bool)),
+ this, SLOT(testSetFullScreenOff()));
connect(test, SIGNAL(propertiesChanged(QStringList)),
this, SLOT(propertiesChanged(QStringList)));
}
@@ -49,42 +53,65 @@ void RootTestWidget::runIncrementalTest()
test->incrementalTest();
}
+void RootTestWidget::updateBoolPropLabel(const QString& name, QLabel *label)
+{
+ if (test->properties().contains(name)) {
+ label->setText(test->properties().value(name).toBool() ? "Yes" : "No");
+ label->setEnabled(true);
+ } else {
+ label->setText("<unknown>");
+ label->setEnabled(false);
+ }
+}
+
+void RootTestWidget::updateStringPropLabel(const QString& name, QLabel *label)
+{
+ if (test->properties().contains(name)) {
+ label->setText(test->properties().value(name).toString());
+ label->setEnabled(true);
+ } else {
+ label->setText("<unknown>");
+ label->setEnabled(false);
+ }
+}
+
void RootTestWidget::propertiesChanged(const QStringList& properties)
{
Q_UNUSED(properties)
- 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);
- }
+ updateStringPropLabel("Identity", ui.identityLbl);
+ updateStringPropLabel("DesktopEntry", ui.desktopFileLbl);
+ updateBoolPropLabel("CanRaise", ui.canRaiseLbl);
+ updateBoolPropLabel("CanQuit", ui.canQuitLbl);
+ updateBoolPropLabel("CanSetFullscreen", ui.canSetFullscreenLbl);
+ updateBoolPropLabel("Fullscreen", ui.fullscreenLbl);
+ updateBoolPropLabel("HasTrackList", ui.hasTracklistLbl);
if (test->properties().contains("SupportedUriSchemes")) {
QStringList uriSchemes = test->properties().value("SupportedUriSchemes").toStringList();
ui.uriSchemesList->clear();
ui.uriSchemesList->addItems(uriSchemes);
ui.uriSchemesList->setEnabled(true);
+ } else {
+ ui.uriSchemesList->setEnabled(false);
}
if (test->properties().contains("SupportedMimeTypes")) {
QStringList mimetypes = test->properties().value("SupportedMimeTypes").toStringList();
ui.mimetypesList->clear();
ui.mimetypesList->addItems(mimetypes);
ui.mimetypesList->setEnabled(true);
+ } else {
+ ui.mimetypesList->setEnabled(false);
}
}
+void RootTestWidget::testSetFullScreenOn()
+{
+ test->testSetFullscreen(true);
+}
+
+void RootTestWidget::testSetFullScreenOff()
+{
+ test->testSetFullscreen(false);
+}
+
// vim:et:sw=4:sts=4
diff --git a/mpris2/roottestwidget.h b/mpris2/roottestwidget.h
index 00a7269..09d5c7d 100644
--- a/mpris2/roottestwidget.h
+++ b/mpris2/roottestwidget.h
@@ -40,8 +40,13 @@ namespace Mpris2
private slots:
void propertiesChanged(const QStringList& properties);
+ void testSetFullScreenOn();
+ void testSetFullScreenOff();
private:
+ void updateBoolPropLabel(const QString& name, QLabel *label);
+ void updateStringPropLabel(const QString& name, QLabel *label);
+
Ui_RootTestForm ui;
RootInterfaceTest* test;
};
diff --git a/ui/roottest.ui b/ui/roottest.ui
index 5909cae..9e471d4 100644
--- a/ui/roottest.ui
+++ b/ui/roottest.ui
@@ -82,7 +82,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
- <string>Can quit</string>
+ <string>Can quit:</string>
</property>
</widget>
</item>
@@ -107,14 +107,21 @@
</item>
</layout>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Fullscreen:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Has tracklist:</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="7" column="1">
<widget class="QLabel" name="hasTracklistLbl">
<property name="enabled">
<bool>false</bool>
@@ -124,32 +131,77 @@
</property>
</widget>
</item>
- <item row="5" column="0">
+ <item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Supported URI schemes:</string>
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="8" column="1">
+ <widget class="QListWidget" name="uriSchemesList">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="9" 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">
+ <item row="9" column="1">
+ <widget class="QListWidget" name="mimetypesList">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="6" column="1">
- <widget class="QListWidget" name="mimetypesList">
+ <item row="5" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="fullscreenLbl">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&lt;unknown&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="fullscreenOnBtn">
+ <property name="text">
+ <string>On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="fullscreenOffBtn">
+ <property name="text">
+ <string>Off</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Can Set Fullscreen</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="canSetFullscreenLbl">
<property name="enabled">
<bool>false</bool>
</property>
+ <property name="text">
+ <string>&lt;unknown&gt;</string>
+ </property>
</widget>
</item>
</layout>