File: testcalibration.cpp

package info (click to toggle)
antimicro 3.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,532 kB
  • sloc: cpp: 50,526; makefile: 59; xml: 9
file content (111 lines) | stat: -rw-r--r-- 4,100 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* antimicrox Gamepad to KB+M event mapper
 * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
 * Copyright (C) 2020 Jagoda Górska <juliagoda.pl@protonmail>
 * Copyright (C) 2020 Paweł Kotiuk <kotiuk@zohomail.eu>
 *
 * This program 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.

 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "calibration.h"

#include <QtTest/QtTest>

/*
resetBtn should be enabled when !stick->wasCalibrated()
resetBtn should be disabled when stick->wasCalibrated()
Calibration->findChildren<QProgressBar*>() count is equal to 2
startButton cannot be disabled
cancelBtn cannot be disabled
saveBtn is enabled when ui->steps->text() == tr("\n---Calibration done!---\n") && stick->setCalibrationSummary != ui->Information->text() || this->text != stick->setCalibrationSummary
saveBtn is disabled when ui->steps->text() != tr("\n---Calibration done!---\n") && stick->setCalibrationSummary == ui->Information->text() || this->text == stick->setCalibrationSummary
controllersBox->count() == this->joysticks->count

int currContrBoxIndex = ui->controllersBox->currentIndex();
QList<JoyControlStick*> sticksList = joysticks->value(currContrBoxIndex)->getSetJoystick(currContrBoxIndex)->getSticks().values();
QList<JoyControlStick*> currStick(sticksList);
ui->axesBox->count == currStick->count

// test for other controllers and sticks too at the same time

if each controlstick.data()->thread()->priority() != InheritPriority  // if each thread is running, otherwise show priority

if window title == tr("Calibration")

if ui->stickStatusBoxWidget->getStick == ui->axesBox at 0


// ACTIONS


if there are ui->axesBox->count > 1 choose the next one and check if ui->stickStatusBoxWidget->getStick == ui->axesBox at 0 &&

joyAxisX = controlstick->getAxisX();
joyAxisY = controlstick->getAxisY();

if progressBarsLayout->->itemAt(0)->widget() == tr("Axis %1").arg(joyAxisX->getRealJoyIndex())
and
progressBarsLayout->->itemAt(2)->widget() == tr("Axis %1").arg(joyAxisY->getRealJoyIndex())


check results of
connect(joyAxisX, &JoyAxis::moved, this, &Calibration::checkX);
connect(joyAxisY, &JoyAxis::moved, this, &Calibration::checkY);

test methods
1) no values
2) various expected values
3) various unexpected values
4) really big values
5) values below 0

int Calibration::chooseMinMax(QString min_max_sign, QList<int> ax_values)
Calibration::checkX(int value)
Calibration::checkY(int value)
Calibration::setController(QString controllerName)
Calibration::setProgressBars(int inputDevNr, int setJoyNr, int stickNr)
Calibration::setProgressBars(JoyControlStick* controlstick)
bool Calibration::enoughProb(int x_count, int y_count, QString character)
int Calibration::calibratedDeadZone(int center, int deadzone)
void Calibration::summarizeValues(int &numbFromList, const int &mappednumb)
void Calibration::getMinVal(int &numbFromList, const int &mappednumb)
void Calibration::getMaxVal(int &numbFromList, const int &mappednumb)
void Calibration::setQuadraticZoneCalibrated(int &max_axis_val_x, int &min_axis_val_x, int &max_axis_val_y, int &min_axis_val_y)
void Calibration::restoreCalValues() -> if all local variables are default again


*/

class TestCalibration: public QObject
{
    Q_OBJECT

public:
    TestCalibration(QObject* parent = 0);

private slots:

private:
    TestCalibration calibrationDialog;
};

TestCalibration::TestCalibration(QObject* parent) :
    QObject(parent),
    Calibration()
{
    QTestEventLoop::instance().enterLoop(1);
}

// QTEST_MAIN(TestAdvanceButtonDialog)
#include "testcalibration.moc"