Skip to content

Commit

Permalink
Merge branch 'master' into qt6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Jul 24, 2023
2 parents 8439073 + af3403b commit ce879e0
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/source/developer/_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Developer notes
internationalization.rst
penetration_testing.rst
server_testing.rst
client_testing.rst
9 changes: 9 additions & 0 deletions docs/source/developer/building_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ Linux
sudo apt install libdrm-dev libxcb-glx0-dev
- Ubuntu 22.04 / gcc 11.3.0 (tested Jul 2023). Requires the following
extra packages:

.. code-block:: bash
sudo apt install libdrm-dev libxcb-glx0-dev libudev-dev \
libwayland-dev \ libx11-xcb-dev libgbm-dev libxcomposite-dev \
libxkbcommon-x11-dev libegl-dev libdbus-1-dev
Android (with a Linux build host)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
70 changes: 70 additions & 0 deletions docs/source/developer/client_testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. docs/source/developer/client_testing.rst
.. Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
.
This file is part of CamCOPS.
.
CamCOPS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
CamCOPS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.
.. _Qt Test: https://doc.qt.io/qt-5/qtest-overview.html


Testing the client code
=======================

The C++ client code on the server is tested with:

- `Qt Test`_ C++ tests
- the in-app tests under :menuselection:`Settings --> CamCOPS self-tests`
- the :ref:`Demonstration task <demoquestionnaire>`

The `Qt Test`_ C++ tests are kept separate to the code they are testing in the ``tests/auto`` sub-folder of ``tablet_qt``.
So for example, the tests for ``tablet_qt/lib/convert.cpp`` are tested by ``tablet_qt/tests/auto/lib/testconvert.cpp``.


To build all of the tests:

.. code-block:: bash
cd /path/to/camcops
mkdir build-qt6-tests
cd build-qt6-tests
/path/to/qt_install/bin/qmake ../tablet_qt/tests
make
Then for example to run the lib/convert tests:

.. code-block:: bash
auto/lib/convert/bin/test_convert
To run all the tests:

.. code-block:: bash
find . -path '*/bin/*' -type f -exec {} \;
If Qt reports missing dependencies, try:

.. code-block:: bash
export QT_DEBUG_PLUGINS=1
A handy one-liner for building and running a test, reporting success or failure:

.. code-block:: bash
/path/to/qt_install/bin/qmake ../tablet_qt/tests && make && auto/lib/convert/bin/test_convert; if [ "$?" == "0" ]; then notify-send "Passed"; else notify-send "Failed"; fi
1 change: 1 addition & 0 deletions tablet_qt/camcops.pro
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ SOURCES += \
lib/css.cpp \
lib/datetime.cpp \
lib/debugfunc.cpp \
lib/errorfunc.cpp \
lib/filefunc.cpp \
lib/flagguard.cpp \
lib/idpolicy.cpp \
Expand Down
5 changes: 0 additions & 5 deletions tablet_qt/lib/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,6 @@ QString toSqlLiteral(const QVariant& value)
return sqlQuoteString(numericVectorToCsvString(intvec));
}
errorfunc::fatalError(QStringLiteral("toSqlLiteral: Unknown user type"));
#ifdef COMPILER_WANTS_RETURN_AFTER_NORETURN
// We'll never get here, but to stop compilers complaining:
return NULL_STR;
#endif

#ifdef COMPILER_WANTS_RETURN_AFTER_NORETURN
// We'll never get here, but to stop compilers complaining:
return NULL_STR;
Expand Down
1 change: 1 addition & 0 deletions tablet_qt/lib/widgetfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <QByteArray>
#include <QColor>
#include <QDebug>
#include <QLayout>
#include <QLayoutItem>
#include <QPlainTextEdit>
Expand Down
1 change: 1 addition & 0 deletions tablet_qt/menulib/menuwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// #define DEBUG_SELECTIONS
// #define OFFER_LAYOUT_DEBUG_BUTTON
// #define SHOW_PID_TO_DEBUG_STREAM // should be disabled for production
#include "lib/widgetfunc.h"
#define SHOW_TASK_TIMING

#include "menuwindow.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void TestNameValueOptions::testInitializedWithList()
{"C", 3},
};

QVERIFY(options.nameFromPosition(0) == "A");
QVERIFY(options.valueFromPosition(0) == 1);
QVERIFY(options.nameFromPosition(1) == "B");
QVERIFY(options.valueFromPosition(1) == 2);
QVERIFY(options.nameFromPosition(2) == "C");
QVERIFY(options.valueFromPosition(2) == 3);
QCOMPARE(options.nameFromPosition(0), "A");
QCOMPARE(options.valueFromPosition(0), 1);
QCOMPARE(options.nameFromPosition(1), "B");
QCOMPARE(options.valueFromPosition(1), 2);
QCOMPARE(options.nameFromPosition(2), "C");
QCOMPARE(options.valueFromPosition(2), 3);
}

QTEST_MAIN(TestNameValueOptions)
Expand Down

0 comments on commit ce879e0

Please sign in to comment.