blob: 4f3ea51f95a57e1d35e614dfcdc12976955dd76a (
plain)
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
|
/***************************************************************************
* *
* copyright (C) 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
#ifndef __SELFTEST_H
#define __SELFTEST_H
#include <qthread.h>
#include <qtimer.h>
#include <qobject.h>
// timeout in seconds
#define SCHEDULE_TIMEOUT 3
/* internal wrapper to workaround MOC issues */
class __SelfTest : public QThread
, public QObject
{
public:
__SelfTest() {}
};
/** PwManager algorithm selftest */
class SelfTest : public __SelfTest
{
Q_OBJECT
public:
SelfTest();
~SelfTest();
/** schedule a new test. Only one test can run at once! */
static void schedule();
/** cancel the running test (if there is one) */
static void cancel();
protected:
/** start the sched timer */
void startTimer()
{ schedTimer.start(SCHEDULE_TIMEOUT * 1000, true); }
/** stop the sched timer */
void stopTimer()
{ schedTimer.stop(); }
protected slots:
void doSelfTest()
{ start(); }
void doCancel();
protected:
/** print the "failed" message and exit the app */
void failed(const char *algo);
/** worker thread */
void run();
protected:
/** schedule timer */
QTimer schedTimer;
};
#endif
|