summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/selftest.h
authorulf69 <ulf69>2004-09-15 17:53:22 (UTC)
committer ulf69 <ulf69>2004-09-15 17:53:22 (UTC)
commitd3925ba5bd25224bc4a60d3d6a107c464994a1ea (patch) (side-by-side diff)
tree60f69da1d2b79ee3081e7ef5c09a46470ca6eda0 /pwmanager/pwmanager/selftest.h
parentce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff)
downloadkdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2
initial revision
Diffstat (limited to 'pwmanager/pwmanager/selftest.h') (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/selftest.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/selftest.h b/pwmanager/pwmanager/selftest.h
new file mode 100644
index 0000000..4f3ea51
--- a/dev/null
+++ b/pwmanager/pwmanager/selftest.h
@@ -0,0 +1,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