summaryrefslogtreecommitdiff
path: root/rockworkd/platformintegration/testing
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
committerAndrew Branson <andrew.branson@cern.ch>2016-02-11 23:55:16 +0100
commit29aaea2d80a9eb1715b6cddfac2d2aacf76358bd (patch)
tree012795b6bec16c72f38d33cff46324c9a0225868 /rockworkd/platformintegration/testing
launchpad ~mzanetti/rockwork/trunk r87
Diffstat (limited to 'rockworkd/platformintegration/testing')
-rw-r--r--rockworkd/platformintegration/testing/testingplatform.cpp63
-rw-r--r--rockworkd/platformintegration/testing/testingplatform.h31
-rw-r--r--rockworkd/platformintegration/testing/testui.qrc6
-rw-r--r--rockworkd/platformintegration/testing/testui/Main.qml87
-rw-r--r--rockworkd/platformintegration/testing/testui/PebbleController.qml44
5 files changed, 231 insertions, 0 deletions
diff --git a/rockworkd/platformintegration/testing/testingplatform.cpp b/rockworkd/platformintegration/testing/testingplatform.cpp
new file mode 100644
index 0000000..aa0c45a
--- /dev/null
+++ b/rockworkd/platformintegration/testing/testingplatform.cpp
@@ -0,0 +1,63 @@
+#include "testingplatform.h"
+
+#include <QQuickView>
+#include <QDebug>
+#include <QQmlContext>
+
+TestingPlatform::TestingPlatform(QObject *parent):
+ PlatformInterface(parent)
+{
+ m_view = new QQuickView();
+ m_view->rootContext()->setContextProperty("handler", this);
+ qmlRegisterUncreatableType<Pebble>("PebbleTest", 1, 0, "Pebble", "Dont");
+ m_view->setSource(QUrl("qrc:///testui/Main.qml"));
+ m_view->show();
+}
+
+void TestingPlatform::sendMusicControlCommand(MusicControlButton command)
+{
+ qDebug() << "Testing platform received music command from pebble" << command;
+}
+
+MusicMetaData TestingPlatform::musicMetaData() const
+{
+ return MusicMetaData("TestArtist", "TestAlbum", "TestTitle");
+}
+
+void TestingPlatform::sendNotification(int type, const QString &from, const QString &subject, const QString &text)
+{
+ qDebug() << "Injecting mock notification" << type;
+ Notification n("test_app_" + QString::number(type));
+ n.setSourceName("Test button " + QString::number(type));
+ n.setSender(from);
+ n.setSubject(subject);
+ n.setBody(text);
+ n.setActToken("tralala");
+ emit notificationReceived(n);
+}
+
+void TestingPlatform::fakeIncomingCall(uint cookie, const QString &number, const QString &name)
+{
+ emit incomingCall(cookie, number, name);
+}
+
+void TestingPlatform::endCall(uint cookie, bool missed)
+{
+ emit callEnded(cookie, missed);
+}
+
+void TestingPlatform::hangupCall(uint cookie)
+{
+ qDebug() << "Testing platform received a hangup call event";
+ emit callEnded(cookie, false);
+}
+
+QList<CalendarEvent> TestingPlatform::organizerItems() const
+{
+ return QList<CalendarEvent>();
+}
+
+void TestingPlatform::actionTriggered(const QString &actToken)
+{
+ qDebug() << "action triggered" << actToken;
+}
diff --git a/rockworkd/platformintegration/testing/testingplatform.h b/rockworkd/platformintegration/testing/testingplatform.h
new file mode 100644
index 0000000..8c820a0
--- /dev/null
+++ b/rockworkd/platformintegration/testing/testingplatform.h
@@ -0,0 +1,31 @@
+#ifndef TESTINGPLATFORM_H
+#define TESTINGPLATFORM_H
+
+#include "libpebble/platforminterface.h"
+
+class QQuickView;
+
+class TestingPlatform : public PlatformInterface
+{
+ Q_OBJECT
+public:
+ explicit TestingPlatform(QObject *parent = 0);
+
+ void sendMusicControlCommand(MusicControlButton command) override;
+ MusicMetaData musicMetaData() const override;
+
+ Q_INVOKABLE void sendNotification(int type, const QString &from, const QString &subject, const QString &text);
+ Q_INVOKABLE void fakeIncomingCall(uint cookie, const QString &number, const QString &name);
+ Q_INVOKABLE void endCall(uint cookie, bool missed);
+
+ void hangupCall(uint cookie) override;
+
+ QList<CalendarEvent> organizerItems() const override;
+ void actionTriggered(const QString &actToken) override;
+signals:
+
+private:
+ QQuickView *m_view;
+};
+
+#endif // TESTINGPLATFORM_H
diff --git a/rockworkd/platformintegration/testing/testui.qrc b/rockworkd/platformintegration/testing/testui.qrc
new file mode 100644
index 0000000..bc0a45f
--- /dev/null
+++ b/rockworkd/platformintegration/testing/testui.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>testui/Main.qml</file>
+ <file>testui/PebbleController.qml</file>
+ </qresource>
+</RCC>
diff --git a/rockworkd/platformintegration/testing/testui/Main.qml b/rockworkd/platformintegration/testing/testui/Main.qml
new file mode 100644
index 0000000..e520ca4
--- /dev/null
+++ b/rockworkd/platformintegration/testing/testui/Main.qml
@@ -0,0 +1,87 @@
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import PebbleTest 1.0
+
+Row {
+ Column {
+ spacing: 10
+ Button {
+ text: "Generic Notification"
+ onClicked: {
+ handler.sendNotification(0, "Bro Coly", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "Email Notification"
+ onClicked: {
+ handler.sendNotification(1, "Tom Ato", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "SMS with no subject"
+ onClicked: {
+ handler.sendNotification(2, "Tom Ato", "", "TestText")
+ }
+ }
+
+ Button {
+ text: "Facebook Notification"
+ onClicked: {
+ handler.sendNotification(3, "Cole Raby", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "Twitter Notification"
+ onClicked: {
+ handler.sendNotification(4, "Horse Reddish", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "Telegram Notification"
+ onClicked: {
+ handler.sendNotification(5, "Horse Reddish", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "WhatsApp Notification"
+ onClicked: {
+ handler.sendNotification(6, "Horse Reddish", "TestSubject", "TestText")
+ }
+ }
+ Button {
+ text: "Hangout Notification"
+ onClicked: {
+ handler.sendNotification(7, "Horse Reddish", "TestSubject", "TestText")
+ }
+ }
+
+ }
+
+ Column {
+ spacing: 10
+ Button {
+ text: "Fake incoming phone call"
+ onClicked: {
+ handler.fakeIncomingCall(1, "123456789", "TestCaller")
+ }
+ }
+ Button {
+ text: "pick up incoming phone call"
+ onClicked: {
+ handler.callStarted(1)
+ }
+ }
+ Button {
+ text: "hang up incoming phone call"
+ onClicked: {
+ handler.endCall(1, false)
+ }
+ }
+ Button {
+ text: "miss incoming phone call"
+ onClicked: {
+ handler.endCall(1, true)
+ }
+ }
+ }
+}
diff --git a/rockworkd/platformintegration/testing/testui/PebbleController.qml b/rockworkd/platformintegration/testing/testui/PebbleController.qml
new file mode 100644
index 0000000..78861d8
--- /dev/null
+++ b/rockworkd/platformintegration/testing/testui/PebbleController.qml
@@ -0,0 +1,44 @@
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import PebbleTest 1.0
+
+Column {
+ spacing: 10
+ Label {
+ text: pebble.name
+ width: parent.width
+ }
+
+ Button {
+ text: "Insert Timeline Pin"
+ onClicked: {
+ pebble.insertTimelinePin();
+ }
+ }
+ Button {
+ text: "Create Reminder"
+ onClicked: {
+ pebble.insertReminder();
+ }
+ }
+ Button {
+ text: "Clear Timeline"
+ onClicked: {
+ pebble.clearTimeline();
+ }
+ }
+ Button {
+ text: "take screenshot"
+ onClicked: {
+ pebble.requestScreenshot();
+ }
+ }
+
+ Button {
+ text: "dump logs"
+ onClicked: {
+ pebble.dumpLogs();
+ }
+ }
+}
+