Subversion Repositories tpanel

Rev

Rev 333 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 333 Rev 334
Line 24... Line 24...
24
#include <atomic>
24
#include <atomic>
25
#include <vector>
25
#include <vector>
26
 
26
 
27
#include <QtGlobal>
27
#include <QtGlobal>
28
 
28
 
29
extern std::atomic<bool> __success;
29
extern bool __success;
30
extern std::atomic<bool> __done;
30
extern bool __done;
-
 
31
extern bool _test_screen;
31
extern bool _testmode;
32
extern bool _testmode;
32
extern bool _run_test_ready;
33
extern bool _run_test_ready;
33
 
34
 
34
class _TestMode
35
class _TestMode
35
{
36
{
36
    public:
37
    public:
37
        _TestMode(const std::string& path);
38
        _TestMode(const std::string& path);
38
        ~_TestMode();
39
        ~_TestMode();
39
 
40
 
40
        void run();
41
        void run();
-
 
42
        void setMouseClick(int x, int y, bool pressed);
41
        void setResult(const std::string& res) { verify = res; }
43
        void setResult(const std::string& res) { mVerify = res; }
42
 
44
 
43
    private:
45
    private:
44
        typedef struct _TESTCMD
46
        typedef struct _TESTCMD
45
        {
47
        {
46
            std::string command;    // The command to execute
48
            std::string command;    // The command to execute
47
            std::string result;     // The expected result
49
            std::string result;     // The expected result
48
            bool compare{false};    // TRUE: Compare expected result with real result
50
            bool compare{false};    // TRUE: Compare expected result with real result
49
            bool nowait{false};     // TRUE: Don't wait until the command finished (no compare!)
51
            bool nowait{false};     // TRUE: Don't wait until the command finished (no compare!)
-
 
52
            bool reverse{false};    // TRUE: This changes the meaning of success and failure.
50
        }_TESTCMD;
53
        }_TESTCMD;
51
 
54
 
52
        void inject(int port, const std::string& c);
55
        void inject(int port, const std::string& c);
53
        void testSuccess(_TESTCMD& tc);
56
        void testSuccess(_TESTCMD& tc);
54
        void start();
57
        void start();
Line 56... Line 59...
56
 
59
 
57
        std::thread mThread;
60
        std::thread mThread;
58
        bool isRunning{false};
61
        bool isRunning{false};
59
        std::string mPath;
62
        std::string mPath;
60
        std::vector<std::string> mCmdFiles;
63
        std::vector<std::string> mCmdFiles;
61
        std::string verify;         // The real result
64
        std::string mVerify;         // The real result
-
 
65
        int mX{0};
-
 
66
        int mY{0};
-
 
67
        bool mPressed{false};
-
 
68
        int mCaseNumber{0};         // The number of the test case
62
};
69
};
63
 
70
 
64
extern _TestMode *_gTestMode;
71
extern _TestMode *_gTestMode;
65
 
72
 
-
 
73
#define setDone()       __done = true;
-
 
74
#define setScreenDone() _test_screen = true;
-
 
75
#define setAllDone()    _test_screen = true; __done = true;
-
 
76
 
66
#ifndef TESTMODE
77
#ifndef TESTMODE
67
extern bool _testmode;
78
extern bool _testmode;
68
#elif TESTMODE != 1
79
#elif TESTMODE != 1
69
extern bool _testmode;
80
extern bool _testmode;
70
#endif  // TESTMODE
81
#endif  // TESTMODE