tests: Add keyboard shortcuts to launch the demos

F7, F8 and F9 directly invoke the appropriate demos.

Fixes: #1121

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2024-08-19 14:19:15 +02:00
parent 104e4b976c
commit dee4501d7e
4 changed files with 20 additions and 9 deletions

View file

@ -383,11 +383,15 @@ void MainWindow::keyPressEvent(QKeyEvent * ev)
int k = ev->key();
record(sim_keys, "Key press %d", k);
if (k == Qt::Key_F11 || k == Qt::Key_F12)
if (k == Qt::Key_F7 || k == Qt::Key_F8 || k == Qt::Key_F9 ||
k == Qt::Key_F11 || k == Qt::Key_F12)
{
if (!tests.isRunning())
{
tests.onlyCurrent = k == Qt::Key_F11;
tests.demo1 = k == Qt::Key_F7;
tests.demo2 = k == Qt::Key_F8;
tests.demo3 = k == Qt::Key_F9;
tests.start();
}
else

View file

@ -59,7 +59,9 @@ class TestsThread : public QThread
// ----------------------------------------------------------------------------
{
public:
TestsThread(QObject *parent): QThread(parent), onlyCurrent() {}
TestsThread(QObject *parent)
: QThread(parent), onlyCurrent(), demo1(), demo2(), demo3()
{}
~TestsThread()
{
if (isRunning())
@ -69,9 +71,10 @@ public:
void run()
{
tests TestSuite;
TestSuite.run(onlyCurrent);
TestSuite.run(onlyCurrent + 2*demo1 + 4*demo2 + 8*demo3);
}
bool onlyCurrent;
bool demo1, demo2, demo3;
};

View file

@ -150,7 +150,7 @@ EXTRA(settings, "Recall and activate every RPL setting");
EXTRA(commands, "Parse every single RPL command");
void tests::run(bool onlyCurrent)
void tests::run(uint onlyCurrent)
// ----------------------------------------------------------------------------
// Run all test categories
// ----------------------------------------------------------------------------
@ -168,10 +168,14 @@ void tests::run(bool onlyCurrent)
if (onlyCurrent)
{
here().begin("Current");
// eqnlib_columns_and_beams();
demo_ui();
demo_math();
demo_pgm();
if (onlyCurrent & 1)
eqnlib_columns_and_beams();
if (onlyCurrent & 2)
demo_ui();
if (onlyCurrent & 4)
demo_math();
if (onlyCurrent & 8)
demo_pgm();
}
else
{

View file

@ -55,7 +55,7 @@ struct tests
{ }
// Run all tests
void run(bool onlyCurrent);
void run(uint onlyCurrent);
// Individual test categories
void reset_settings();