2
* Copyright (C) 2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
18
#include "MediaPlayerMprisMockInterface.h"
22
QMap<QString, QString> getPropertiesMap()
24
QMap<QString, QString> retMap;
26
retMap["CANPLAY"] = "setCanPlay";
27
retMap["CANPAUSE"] = "setCanPause";
28
retMap["CANGONEXT"] = "setCanGoNext";
29
retMap["CANGOPREVIOUS"] = "setCanGoPrevious";
34
bool getBoolValue(QString const & str)
43
QTextStream& qStdErr()
45
static QTextStream ts( stderr );
49
int main(int argc, char **argv)
51
QCoreApplication app(argc, argv);
55
qStdErr() << "usage: " << argv[0] << "TEST_PLAYER_NAME PropertyName true|false\n";
59
QString state = QString(argv[3]).toUpper();
60
QString property = QString(argv[2]).toUpper();
61
QString playerName = QString(argv[1]);
63
auto propertiesMap = getPropertiesMap();
65
std::shared_ptr<MediaPlayerMprisMockInterface> iface(
66
new MediaPlayerMprisMockInterface("org.mpris.MediaPlayer2." + playerName,
67
"/org/mpris/MediaPlayer2",
68
QDBusConnection::sessionBus()));
71
qWarning() << argv[0] << ": error creating interface";
75
QMap<QString, QString>::iterator iter = propertiesMap.find(property);
76
if (iter == propertiesMap.end())
78
qWarning() << argv[0] << ": property " << property << " was not found.";
82
QDBusReply<void> set_prop = iface->call(QLatin1String((*iter).toStdString().c_str()),
83
QVariant::fromValue(getBoolValue(state)));
85
if (!set_prop.isValid())
87
qWarning() << argv[0] << ": D-Bus error: " << set_prop.error().message();