-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpqAbstractMiscellaneousEventPlayer.cxx
More file actions
69 lines (63 loc) · 1.61 KB
/
pqAbstractMiscellaneousEventPlayer.cxx
File metadata and controls
69 lines (63 loc) · 1.61 KB
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
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
#include "pqAbstractMiscellaneousEventPlayer.h"
#include <QAbstractButton>
#include <QFile>
#include <QThread>
#include <QtDebug>
#include "pqEventDispatcher.h"
#include "pqTestUtility.h"
// Class that encapsulates the protected function QThread::msleep
class SleeperThread : public QThread
{
public:
// Allows for cross platform sleep function
static bool msleep(unsigned long msecs)
{
QThread::msleep(msecs);
return true;
}
};
pqAbstractMiscellaneousEventPlayer::pqAbstractMiscellaneousEventPlayer(
pqTestUtility* util, QObject* p)
: pqWidgetEventPlayer(p)
, TestUtility(util)
{
}
// Allows for execution of testing commands that don't merit their own class
bool pqAbstractMiscellaneousEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if (Command == "pause")
{
const int value = Arguments.toInt();
if (SleeperThread::msleep(value))
{
return true;
}
Error = true;
qCritical() << "calling pause on unhandled type " << Object;
}
if (Command == "process_events")
{
bool valid = false;
const int ms = Arguments.toInt(&valid);
if (valid)
{
pqEventDispatcher::processEventsAndWait(ms);
}
else
{
pqEventDispatcher::processEvents();
}
return true;
}
if (Command == "dashboard_mode")
{
bool toggle = QVariant(Arguments).toBool();
this->TestUtility->setDashboardMode(toggle);
return true;
}
return false;
}