summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@digia.com>2014-05-21 12:57:57 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-23 10:48:15 +0200
commit5d6f97ed9450b88098e425d4cf963655b3508248 (patch)
treededbfe2e243198300c0db79fe98d8eb7a0d2f453
parentccda0ec5e288140899bd14955b078563387b63df (diff)
Add snippet app to verify plugin implementation
Useful when creating a new backend to verify behavior. Change-Id: I7a417aabad4d6dbbe494dcd384ca7af57bd78050 Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--tests/applications/positioning_backend/main.cpp61
-rw-r--r--tests/applications/positioning_backend/positioning_backend.pro14
-rw-r--r--tests/applications/positioning_backend/widget.cpp168
-rw-r--r--tests/applications/positioning_backend/widget.h79
-rw-r--r--tests/applications/positioning_backend/widget.ui295
5 files changed, 617 insertions, 0 deletions
diff --git a/tests/applications/positioning_backend/main.cpp b/tests/applications/positioning_backend/main.cpp
new file mode 100644
index 00000000..2ca4a0aa
--- /dev/null
+++ b/tests/applications/positioning_backend/main.cpp
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "widget.h"
+#include <QLabel>
+
+#include <QApplication>
+#include <QtWidgets>
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ Widget w1;
+ Widget w2;
+
+ QTabWidget tabWidget;
+ tabWidget.setTabPosition(QTabWidget::South);
+
+ tabWidget.addTab(&w1, "Instance 1");
+ tabWidget.addTab(&w2, "Instance 2");
+
+ tabWidget.show();
+ return a.exec();
+}
diff --git a/tests/applications/positioning_backend/positioning_backend.pro b/tests/applications/positioning_backend/positioning_backend.pro
new file mode 100644
index 00000000..410dbc86
--- /dev/null
+++ b/tests/applications/positioning_backend/positioning_backend.pro
@@ -0,0 +1,14 @@
+QT += core gui positioning widgets
+
+TARGET = posbackendtesting
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ widget.cpp
+
+HEADERS += widget.h
+
+FORMS += widget.ui
+
+winrt: WINRT_MANIFEST.capabilities_device += location
diff --git a/tests/applications/positioning_backend/widget.cpp b/tests/applications/positioning_backend/widget.cpp
new file mode 100644
index 00000000..0624a837
--- /dev/null
+++ b/tests/applications/positioning_backend/widget.cpp
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "widget.h"
+#include "ui_widget.h"
+#include <QGeoPositionInfoSource>
+#include <QDebug>
+
+Widget::Widget(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::Widget)
+{
+ ui->setupUi(this);
+ qDebug() << "Available:" << QGeoPositionInfoSource::availableSources();
+ m_posSource = QGeoPositionInfoSource::createDefaultSource(this);
+ if (!m_posSource)
+ qFatal("No Position Source created!");
+ connect(m_posSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
+ this, SLOT(positionUpdated(QGeoPositionInfo)));
+
+ connect(ui->horizontalSlider, SIGNAL(valueChanged(int)),
+ this, SLOT(setInterval(int)));
+ connect(m_posSource, SIGNAL(updateTimeout()),
+ this, SLOT(positionTimedOut()));
+
+ ui->groupBox->setLayout(ui->gridLayout);
+ ui->horizontalSlider->setMinimum(m_posSource->minimumUpdateInterval());
+ ui->labelTimeOut->setVisible(false);
+
+ connect(m_posSource, SIGNAL(error(QGeoPositionInfoSource::Error)),
+ this, SLOT(errorChanged(QGeoPositionInfoSource::Error)));
+}
+
+void Widget::positionUpdated(QGeoPositionInfo gpsPos)
+{
+ QGeoCoordinate coord = gpsPos.coordinate();
+ ui->labelLatitude->setText(QString::number(coord.latitude()));
+ ui->labelLongitude->setText(QString::number(coord.longitude()));
+ ui->labelAltitude->setText(QString::number(coord.altitude()));
+ ui->labelTimeStamp->setText(gpsPos.timestamp().toString());
+ if (gpsPos.hasAttribute(QGeoPositionInfo::HorizontalAccuracy))
+ ui->labelHAccuracy->setText(QString::number(gpsPos.attribute(QGeoPositionInfo::HorizontalAccuracy)));
+ else
+ ui->labelHAccuracy->setText(QStringLiteral("N/A"));
+
+ if (gpsPos.hasAttribute(QGeoPositionInfo::VerticalAccuracy))
+ ui->labelVAccuracy->setText(QString::number(gpsPos.attribute(QGeoPositionInfo::VerticalAccuracy)));
+ else
+ ui->labelVAccuracy->setText(QStringLiteral("N/A"));
+}
+
+void Widget::positionTimedOut()
+{
+ ui->labelTimeOut->setVisible(true);
+}
+
+void Widget::errorChanged(QGeoPositionInfoSource::Error err)
+{
+ ui->labelErrorState->setText(err == 3 ? QStringLiteral("OK") : QString::number(err));
+}
+
+Widget::~Widget()
+{
+ delete ui;
+}
+
+void Widget::setInterval(int msec)
+{
+ m_posSource->setUpdateInterval(msec);
+}
+
+void Widget::on_buttonRetrieve_clicked()
+{
+ // Requesting current position for _one_ time
+ m_posSource->requestUpdate(10000);
+}
+
+void Widget::on_buttonStart_clicked()
+{
+ // Either start or stop the current position info source
+ bool running = ui->checkBox->isChecked();
+ if (running) {
+ m_posSource->stopUpdates();
+ ui->checkBox->setChecked(false);
+ } else {
+ m_posSource->startUpdates();
+ ui->checkBox->setChecked(true);
+ }
+}
+
+void Widget::on_radioButton_clicked()
+{
+ m_posSource->setPreferredPositioningMethods(QGeoPositionInfoSource::NoPositioningMethods);
+}
+
+void Widget::on_radioButton_2_clicked()
+{
+ m_posSource->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
+}
+
+void Widget::on_radioButton_3_clicked()
+{
+ m_posSource->setPreferredPositioningMethods(QGeoPositionInfoSource::NonSatellitePositioningMethods);
+}
+
+void Widget::on_radioButton_4_clicked()
+{
+ m_posSource->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
+}
+
+void Widget::on_buttonUpdateSupported_clicked()
+{
+ QGeoPositionInfoSource::PositioningMethods m = m_posSource->supportedPositioningMethods();
+ QString text;
+ switch (m) {
+ case QGeoPositionInfoSource::NoPositioningMethods:
+ text = QStringLiteral("None");
+ break;
+ case QGeoPositionInfoSource::SatellitePositioningMethods:
+ text = QStringLiteral("Satellite");
+ break;
+ case QGeoPositionInfoSource::NonSatellitePositioningMethods:
+ text = QStringLiteral("Non Satellite");
+ break;
+ case QGeoPositionInfoSource::AllPositioningMethods:
+ text = QStringLiteral("All");
+ break;
+ }
+
+ ui->labelSupported->setText(text);
+}
diff --git a/tests/applications/positioning_backend/widget.h b/tests/applications/positioning_backend/widget.h
new file mode 100644
index 00000000..94ccceef
--- /dev/null
+++ b/tests/applications/positioning_backend/widget.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtPositioning module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+#include <QGeoPositionInfoSource>
+
+namespace Ui {
+ class Widget;
+}
+
+class Widget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit Widget(QWidget *parent = 0);
+ ~Widget();
+
+public slots:
+ void positionUpdated(QGeoPositionInfo gpsPos);
+ void setInterval(int msec);
+ void positionTimedOut();
+ void errorChanged(QGeoPositionInfoSource::Error err);
+private slots:
+ void on_buttonRetrieve_clicked();
+ void on_buttonStart_clicked();
+ void on_radioButton_2_clicked();
+ void on_radioButton_clicked();
+ void on_radioButton_3_clicked();
+ void on_radioButton_4_clicked();
+
+ void on_buttonUpdateSupported_clicked();
+
+private:
+ Ui::Widget *ui;
+ QGeoPositionInfoSource *m_posSource;
+};
+
+#endif // WIDGET_H
diff --git a/tests/applications/positioning_backend/widget.ui b/tests/applications/positioning_backend/widget.ui
new file mode 100644
index 00000000..d19497d2
--- /dev/null
+++ b/tests/applications/positioning_backend/widget.ui
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget</class>
+ <widget class="QWidget" name="Widget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>276</width>
+ <height>467</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Widget</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Latitude:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="labelLatitude">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Longitude:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelLongitude">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Altitude:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="labelAltitude">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>TimeStamp:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="labelTimeStamp">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Horizontal Accuracy:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="labelHAccuracy">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Vertical Accuracy:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="labelVAccuracy">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>TimeOut:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLabel" name="labelTimeOut">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>!!!!!TimeOut!!!!!</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Supported Methods:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Error State:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="QLabel" name="labelErrorState">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="labelSupported">
+ <property name="text">
+ <string>N/A</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonUpdateSupported">
+ <property name="text">
+ <string>Update</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Method</string>
+ </property>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>43</x>
+ <y>21</y>
+ <width>243</width>
+ <height>71</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="radioButton">
+ <property name="text">
+ <string>None</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QRadioButton" name="radioButton_2">
+ <property name="text">
+ <string>Satelite</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QRadioButton" name="radioButton_3">
+ <property name="text">
+ <string>Non-Satelite</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QRadioButton" name="radioButton_4">
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Interval:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="minimum">
+ <number>50</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelInterval">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Running</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QPushButton" name="buttonStart">
+ <property name="text">
+ <string>Start/Stop</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonRetrieve">
+ <property name="text">
+ <string>Retrieve</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>horizontalSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>labelInterval</receiver>
+ <slot>setNum(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>217</x>
+ <y>137</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>386</x>
+ <y>138</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>