2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* version 3 along with this program. If not, see
15
* <http://www.gnu.org/licenses/>
17
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
21
#include <X11/extensions/XTest.h>
22
#include <X11/keysym.h>
24
#ifndef NUX_AUTOMATED_TEST_FRAMEWORK_H
25
#define NUX_AUTOMATED_TEST_FRAMEWORK_H
27
class NuxAutomatedTestFramework
30
NuxAutomatedTestFramework(nux::WindowThread *window_thread);
31
virtual ~NuxAutomatedTestFramework();
33
//! Initialize the testing framework.
36
//! Simulate a mouse click event on a view.
38
Move the mouse to the middle of the view (if it isn't there already) and perform a click event.
40
void ViewSendMouseClick(nux::View *view, int button);
41
//! Simulate a mouse double click event on a view.
43
Move the mouse to the middle of the view (if it isn't there already) and perform a double click event.
45
void ViewSendMouseDoubleClick(nux::View *view, int button);
46
//! Simulate a mouse down event on a view.
47
void ViewSendMouseDown(nux::View *view, int button);
48
//! Simulate a mouse up event on a view.
49
void ViewSendMouseUp(nux::View *view, int button);
50
//! Simulate a drag event on a view from (x0, y0) to (x1, y1).
51
void ViewSendMouseDrag(nux::View *view, int button, int x0, int y0, int x1, int y1);
52
//! Simulate mouse motion to (x, y).
53
void ViewSendMouseMotionTo(nux::View *view, int x, int y);
54
//! Simulate mouse motion to the center of a view.
55
void ViewSendMouseMotionToCenter(nux::View *view);
56
//! Simulate mouse motion to the top left corner of a view.
57
void ViewSendMouseMotionToTopLeft(nux::View *view);
58
//! Simulate mouse motion to the top right corner of a view.
59
void ViewSendMouseMotionToTopRight(nux::View *view);
60
//! Simulate mouse motion to the bottom left corner of a view.
61
void ViewSendMouseMotionToBottomLeft(nux::View *view);
62
//! Simulate mouse motion to the bottom right corner of a view.
63
void ViewSendMouseMotionToBottomRight(nux::View *view);
65
//! Simulate a key event.
66
void ViewSendChar(const char c);
67
//! Simulate a succession of key events.
68
void ViewSendString(const std::string &str);
69
//! Simulate a key combo.
70
void ViewSendKeyCombo(KeySym modsym0, KeySym modsym1, KeySym modsym2, const char c);
73
//! Simulate Delete key.
74
void ViewSendDelete();
75
//! Simulate Backspace key.
76
void ViewSendBackspace();
77
//! Simulate Escape key.
78
void ViewSendEscape();
81
//! Simulate Return key.
82
void ViewSendReturn();
84
//! Put the mouse pointer anywhere on the display.
85
void PutMouseAt(int x, int y);
87
//! Simulate a mouse event.
88
void SendFakeMouseEvent(int mouse_button_index, bool pressed);
89
//! Simulate a key event.
90
void SendFakeKeyEvent(KeySym keysym, KeySym modsym);
91
//! Simulate a mouse motion event.
92
void SendFakeMouseMotionEvent(int x, int y, int ms_delay);
95
Set the test thread to terminae the program when testing is over.
97
void SetTerminateProgramWhenDone(bool terminate);
99
Return true if the test thread is allowed to terminate the program after testing is over.
101
bool WhenDoneTerminateProgram();
104
Print a report message to the console.
106
void TestReportMsg(bool b, const char* msg);
109
void WindowConfigSignal(int x, int y, int width, int height);
111
bool ready_to_start_;
113
nux::WindowThread *window_thread_;
118
bool terminate_when_test_over_;
120
static int mouse_motion_time_span; // in milliseconds
121
static int mouse_click_time_span; // in milliseconds
122
static int minimum_sleep_time; // in milliseconds
123
static int safety_border_inside_view; // in pixels
126
#endif // NUX_AUTOMATED_TEST_FRAMEWORK_H