Merge ssh://ssh.itsblue.dev:10040/ScStw/shared-libraries into HEAD

This commit is contained in:
Dorian Zedler 2021-07-17 17:04:46 +02:00
commit 50f1b919ad
Signed by: dorian
GPG key ID: 989DE36109AFA354
7 changed files with 308 additions and 0 deletions

View file

@ -1,6 +1,8 @@
!isEmpty(SCSTWLIBRARIES_LIB):error("ScStwLibraries.pri already included")
SCSTWLIBRARIES_LIB = 1
QT += multimedia
ScStwLibraries_QML {
QT += qml quickcontrols2
DEFINES += ScStwLibraries_QML

73
ScStwLibraries/tests/.gitignore vendored Normal file
View file

@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

View file

@ -0,0 +1,10 @@
#include "scstwtestingtimer.h"
ScStwTestingTimer::ScStwTestingTimer()
{
}
void ScStwTestingTimer::handleClimberStart(double timeOfStart) {
ScStwTimer::handleClimberStart(timeOfStart);
}

View file

@ -0,0 +1,14 @@
#ifndef SCSTWTESTINGTIMER_H
#define SCSTWTESTINGTIMER_H
#include <scstwtimer.h>
#include <QObject>
class ScStwTestingTimer : public ScStwTimer
{
public:
ScStwTestingTimer();
void handleClimberStart(double timeOfStart);
};
#endif // SCSTWTESTINGTIMER_H

View file

@ -0,0 +1,19 @@
QT += testlib
QT -= gui
CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += \
scstwtestingtimer.cpp \
tst_scstwrace.cpp \
tst_scstwtimertests.cpp
# include submodules
CONFIG += ScStwLibraries_QML ScStwLibraries_Styling ScStwLibraries_ClientLibs
include($$PWD/../ScStwLibraries.pri)
HEADERS += \
scstwtestingtimer.h

View file

@ -0,0 +1,49 @@
#include <QtTest>
#include <QDateTime>
#include "scstwrace.h"
// add necessary includes here
class ScStwRaceTests : public QObject
{
Q_OBJECT
public:
ScStwRaceTests();
~ScStwRaceTests();
private slots:
void initTestCase();
void cleanupTestCase();
void basic_cycle();
};
ScStwRaceTests::ScStwRaceTests()
{
}
ScStwRaceTests::~ScStwRaceTests()
{
}
void ScStwRaceTests::initTestCase()
{
}
void ScStwRaceTests::cleanupTestCase()
{
}
void ScStwRaceTests::basic_cycle()
{
}
#include "tst_scstwrace.moc"

View file

@ -0,0 +1,141 @@
#include <QtTest>
#include <QDateTime>
#include "scstwtimer.h"
#include "scstwtestingtimer.h"
// add necessary includes here
class ScStwTimerTests : public QObject
{
Q_OBJECT
public:
ScStwTimerTests();
~ScStwTimerTests();
private slots:
void initTestCase();
void cleanupTestCase();
void basic_cycle_cancelled();
void basic_cycle_won();
void basic_cycle_lost();
void basic_cycle_failed();
void basic_cycle_wildcard();
};
ScStwTimerTests::ScStwTimerTests()
{
}
ScStwTimerTests::~ScStwTimerTests()
{
}
void ScStwTimerTests::initTestCase()
{
}
void ScStwTimerTests::cleanupTestCase()
{
}
void ScStwTimerTests::basic_cycle_cancelled()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.cancel();
QCOMPARE(timer.getState(), ScStwTimer::CANCELLED);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_won()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.stop();
QCOMPARE(timer.getState(), ScStwTimer::WAITING);
timer.setResult(ScStwTimer::WON);
QCOMPARE(timer.getState(), ScStwTimer::WON);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_lost()
{
ScStwTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start();
QCOMPARE(timer.getState(), ScStwTimer::RUNNING);
QCOMPARE(timer.isRunning(), true);
timer.stop();
QCOMPARE(timer.getState(), ScStwTimer::WAITING);
timer.setResult(ScStwTimer::LOST);
QCOMPARE(timer.getState(), ScStwTimer::LOST);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_failed()
{
double startTime = QDateTime::currentMSecsSinceEpoch() + 1000;
ScStwTestingTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start(startTime);
QCOMPARE(timer.getState(), ScStwTimer::STARTING);
timer.handleClimberStart(startTime - 1000);
QCOMPARE(timer.getState(), ScStwTimer::FAILING);
timer.setResult(ScStwTimer::FAILED);
QCOMPARE(timer.getState(), ScStwTimer::FAILED);
QCOMPARE(timer.getReactionTime(), -1000);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
void ScStwTimerTests::basic_cycle_wildcard()
{
double startTime = QDateTime::currentMSecsSinceEpoch() + 1000;
ScStwTestingTimer timer;
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
timer.start(startTime);
QCOMPARE(timer.getState(), ScStwTimer::STARTING);
timer.handleClimberStart(startTime - 1000);
QCOMPARE(timer.getState(), ScStwTimer::FAILING);
timer.setResult(ScStwTimer::WILDCARD);
QCOMPARE(timer.getState(), ScStwTimer::WILDCARD);
QCOMPARE(timer.getReactionTime(), -1000);
timer.reset();
QCOMPARE(timer.getState(), ScStwTimer::IDLE);
QCOMPARE(timer.getReadyState(), ScStwTimer::IsReady);
}
QTEST_APPLESS_MAIN(ScStwTimerTests)
#include "tst_scstwtimertests.moc"