From 2bb003b7b158890e87731b1a85f3b71008d6284f Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 11 Dec 2018 10:31:42 +0100 Subject: Add ability to visually log position updates in test app This makes it much easier to check received positions outside of debug/console output. Regular updates cannot be received inside a building which means a device can be taken out of the office for further testing without the need to have a developer machine attached. Change-Id: I1a54a1b2fa269ec4ab75aacc4531158a02345382 Reviewed-by: Oliver Wolff --- .../applications/positioning_backend/logwidget.cpp | 46 +++++++++++++++++++++ tests/applications/positioning_backend/logwidget.h | 47 ++++++++++++++++++++++ tests/applications/positioning_backend/main.cpp | 7 +++- .../positioning_backend/positioning_backend.pro | 6 ++- tests/applications/positioning_backend/widget.cpp | 5 ++- tests/applications/positioning_backend/widget.h | 5 ++- 6 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 tests/applications/positioning_backend/logwidget.cpp create mode 100644 tests/applications/positioning_backend/logwidget.h (limited to 'tests') diff --git a/tests/applications/positioning_backend/logwidget.cpp b/tests/applications/positioning_backend/logwidget.cpp new file mode 100644 index 00000000..5ec47230 --- /dev/null +++ b/tests/applications/positioning_backend/logwidget.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtPositioning module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "logwidget.h" +#include + +LogWidget::LogWidget(QWidget *parent) : QWidget(parent) +{ + QVBoxLayout *verticalLayout = new QVBoxLayout(this); + verticalLayout->setSpacing(6); + verticalLayout->setContentsMargins(11, 11, 11, 11); + verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + + editor = new QPlainTextEdit(this); + verticalLayout->addWidget(editor); +} + +void LogWidget::appendLog(const QString &line) +{ + editor->appendPlainText(line); +} diff --git a/tests/applications/positioning_backend/logwidget.h b/tests/applications/positioning_backend/logwidget.h new file mode 100644 index 00000000..f6a3eb44 --- /dev/null +++ b/tests/applications/positioning_backend/logwidget.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtPositioning module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LOGWIDGET_H +#define LOGWIDGET_H + +#include +#include + +class LogWidget : public QWidget +{ + Q_OBJECT +public: + explicit LogWidget(QWidget *parent = nullptr); + + void appendLog(const QString &line); + +private: + QPlainTextEdit *editor; +}; + +#endif // LOGWIDGET_H diff --git a/tests/applications/positioning_backend/main.cpp b/tests/applications/positioning_backend/main.cpp index 930f1c9c..52115556 100644 --- a/tests/applications/positioning_backend/main.cpp +++ b/tests/applications/positioning_backend/main.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ #include "widget.h" +#include "logwidget.h" #include #include @@ -34,14 +35,16 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - Widget *w1 = new Widget; - Widget *w2 = new Widget; + LogWidget *log = new LogWidget; + Widget *w1 = new Widget(log); + Widget *w2 = new Widget(log); QTabWidget tabWidget; tabWidget.setTabPosition(QTabWidget::South); tabWidget.addTab(w1, "Instance 1"); tabWidget.addTab(w2, "Instance 2"); + tabWidget.addTab(log, "Logs"); tabWidget.show(); return a.exec(); diff --git a/tests/applications/positioning_backend/positioning_backend.pro b/tests/applications/positioning_backend/positioning_backend.pro index 410dbc86..4ba9e7c8 100644 --- a/tests/applications/positioning_backend/positioning_backend.pro +++ b/tests/applications/positioning_backend/positioning_backend.pro @@ -5,9 +5,11 @@ TEMPLATE = app SOURCES += main.cpp\ - widget.cpp + widget.cpp \ + logwidget.cpp -HEADERS += widget.h +HEADERS += widget.h \ + logwidget.h FORMS += widget.ui diff --git a/tests/applications/positioning_backend/widget.cpp b/tests/applications/positioning_backend/widget.cpp index 93a42a80..ae39187d 100644 --- a/tests/applications/positioning_backend/widget.cpp +++ b/tests/applications/positioning_backend/widget.cpp @@ -30,8 +30,9 @@ #include #include -Widget::Widget(QWidget *parent) : +Widget::Widget(LogWidget *logWidget, QWidget *parent) : QWidget(parent), + log(logWidget), ui(new Ui::Widget) { ui->setupUi(this); @@ -81,6 +82,8 @@ void Widget::positionUpdated(QGeoPositionInfo gpsPos) ui->labelSpeed->setText(QString::number(gpsPos.attribute(QGeoPositionInfo::GroundSpeed))); else ui->labelSpeed->setText(QStringLiteral("N/A")); + + log->appendLog(coord.toString()); } void Widget::positionTimedOut() diff --git a/tests/applications/positioning_backend/widget.h b/tests/applications/positioning_backend/widget.h index fc04c423..b67e53b8 100644 --- a/tests/applications/positioning_backend/widget.h +++ b/tests/applications/positioning_backend/widget.h @@ -28,6 +28,8 @@ #ifndef WIDGET_H #define WIDGET_H +#include "logwidget.h" + #include #include @@ -40,7 +42,7 @@ class Widget : public QWidget Q_OBJECT public: - explicit Widget(QWidget *parent = 0); + explicit Widget(LogWidget *log, QWidget *parent = nullptr); ~Widget(); public slots: @@ -59,6 +61,7 @@ private slots: void on_buttonUpdateSupported_clicked(); private: + LogWidget *log = nullptr; Ui::Widget *ui; QGeoPositionInfoSource *m_posSource; }; -- cgit v1.2.1 From 420128331deef9dd963c9455cab6ef47a8f20a5c Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 20 Dec 2018 15:48:59 +0100 Subject: Enable testing of QGeoPositionSourceInfo::supportedPositioningMethodsChanged() This signal is new and is observable as part of the test application now. Task-number: QTBUG-66427 Change-Id: I3859381f4804112cbf44a365d0c9bb357d068119 Reviewed-by: Oliver Wolff --- tests/applications/positioning_backend/widget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/applications/positioning_backend/widget.cpp b/tests/applications/positioning_backend/widget.cpp index ae39187d..efdaebdd 100644 --- a/tests/applications/positioning_backend/widget.cpp +++ b/tests/applications/positioning_backend/widget.cpp @@ -54,6 +54,15 @@ Widget::Widget(LogWidget *logWidget, QWidget *parent) : connect(m_posSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(errorChanged(QGeoPositionInfoSource::Error))); + connect(m_posSource, &QGeoPositionInfoSource::supportedPositioningMethodsChanged, + this, [this]() { + auto methods = m_posSource->supportedPositioningMethods(); + const QString status = QStringLiteral("Satellite: %1 ").arg(bool(methods & QGeoPositionInfoSource::SatellitePositioningMethods)) + + QStringLiteral("Non-Satellite: %1").arg(bool(methods & QGeoPositionInfoSource::NonSatellitePositioningMethods)); + + qDebug() << "Available Positioning Methods Changed" << status; + log->appendLog(status); + }); } void Widget::positionUpdated(QGeoPositionInfo gpsPos) -- cgit v1.2.1