From 29aaea2d80a9eb1715b6cddfac2d2aacf76358bd Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 11 Feb 2016 23:55:16 +0100 Subject: launchpad ~mzanetti/rockwork/trunk r87 --- .../testing/testingplatform.cpp | 63 ++++++++++++++++ .../platformintegration/testing/testingplatform.h | 31 ++++++++ rockworkd/platformintegration/testing/testui.qrc | 6 ++ .../platformintegration/testing/testui/Main.qml | 87 ++++++++++++++++++++++ .../testing/testui/PebbleController.qml | 44 +++++++++++ 5 files changed, 231 insertions(+) create mode 100644 rockworkd/platformintegration/testing/testingplatform.cpp create mode 100644 rockworkd/platformintegration/testing/testingplatform.h create mode 100644 rockworkd/platformintegration/testing/testui.qrc create mode 100644 rockworkd/platformintegration/testing/testui/Main.qml create mode 100644 rockworkd/platformintegration/testing/testui/PebbleController.qml (limited to 'rockworkd/platformintegration/testing') 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 +#include +#include + +TestingPlatform::TestingPlatform(QObject *parent): + PlatformInterface(parent) +{ + m_view = new QQuickView(); + m_view->rootContext()->setContextProperty("handler", this); + qmlRegisterUncreatableType("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 TestingPlatform::organizerItems() const +{ + return QList(); +} + +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 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 @@ + + + testui/Main.qml + testui/PebbleController.qml + + 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(); + } + } +} + -- cgit v1.2.3