Back to index

nux  3.0.0
nux_automated_test_framework.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00018  *
00019  */
00020 
00021 #include <X11/extensions/XTest.h>
00022 #include <X11/keysym.h> 
00023 
00024 #ifndef NUX_AUTOMATED_TEST_FRAMEWORK_H
00025 #define NUX_AUTOMATED_TEST_FRAMEWORK_H
00026 
00027 class NuxAutomatedTestFramework
00028 {
00029 public:
00030   NuxAutomatedTestFramework(nux::WindowThread *window_thread);
00031   virtual ~NuxAutomatedTestFramework();
00032 
00034   void Startup();
00035 
00037 
00040   void ViewSendMouseClick(nux::View *view, int button);
00042 
00045   void ViewSendMouseDoubleClick(nux::View *view, int button);
00047   void ViewSendMouseDown(nux::View *view, int button);
00049   void ViewSendMouseUp(nux::View *view, int button);
00051   void ViewSendMouseDrag(nux::View *view, int button, int x0, int y0, int x1, int y1);
00053   void ViewSendMouseMotionTo(nux::View *view, int x, int y);
00055   void ViewSendMouseMotionToCenter(nux::View *view);
00057   void ViewSendMouseMotionToTopLeft(nux::View *view);
00059   void ViewSendMouseMotionToTopRight(nux::View *view);
00061   void ViewSendMouseMotionToBottomLeft(nux::View *view);
00063   void ViewSendMouseMotionToBottomRight(nux::View *view);
00064 
00066   void ViewSendChar(const char c);
00068   void ViewSendString(const std::string &str);
00070   void ViewSendKeyCombo(KeySym modsym0, KeySym modsym1, KeySym modsym2, const char c);
00072   void ViewSendCtrlA();
00074   void ViewSendDelete();
00076   void ViewSendBackspace();
00078   void ViewSendEscape();
00080   void ViewSendTab();
00082   void ViewSendReturn();
00084   void ViewSendLeft();
00086   void ViewSendRight();
00088   void ViewSendUp();
00090   void ViewSendDown();
00092   void ViewSendCompositionKeys(const std::string &str);
00093 
00094   void ViewSendIBusToggle();
00095 
00097   void PutMouseAt(int x, int y);
00098 
00100   void SendFakeMouseEvent(int mouse_button_index, bool pressed);
00102   void SendFakeKeyEvent(KeySym keysym, KeySym modsym);
00104   void SendFakeMouseMotionEvent(int x, int y, int ms_delay);
00105 
00109   void SetTerminateProgramWhenDone(bool terminate);
00113   bool WhenDoneTerminateProgram();
00114 
00118   void TestReportMsg(bool b, const char* msg);
00119 
00120 private:
00121   void WindowConfigSignal(int x, int y, int width, int height);
00122   
00123   bool ready_to_start_;
00124   Display* display_;
00125   nux::WindowThread *window_thread_;
00126   int window_x_;
00127   int window_y_;
00128   int window_width_;
00129   int window_height_;
00130   bool terminate_when_test_over_;
00131 
00132   static int mouse_motion_time_span;    // in milliseconds
00133   static int mouse_click_time_span;     // in milliseconds
00134   static int minimum_sleep_time;        // in milliseconds   
00135   static int safety_border_inside_view; // in pixels
00136 };
00137 
00138 #endif // NUX_AUTOMATED_TEST_FRAMEWORK_H
00139