Back to index

nux  3.0.0
Classes | Functions | Variables
xtest-mouse-buttons.cpp File Reference
#include "Nux/Nux.h"
#include "Nux/WindowThread.h"
#include "Nux/VLayout.h"
#include "Nux/Layout.h"
#include "Nux/ProgramFramework/ProgramTemplate.h"
#include "Nux/ProgramFramework/TestView.h"
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
#include "nux_automated_test_framework.h"

Go to the source code of this file.

Classes

class  ButtonEventsTest

Functions

void TestingThread (nux::NThread *thread, void *user_data)
int main (int argc, char **argv)

Variables

ButtonEventsTestbutton_event_test = NULL

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 155 of file xtest-mouse-buttons.cpp.

{
  int xstatus = XInitThreads();
  nuxAssertMsg(xstatus > 0, "XInitThreads has failed");

  button_event_test = new ButtonEventsTest("Events Test", 300, 300, 30000);
  button_event_test->Startup();
  button_event_test->UserInterfaceSetup();

  nux::SystemThread* test_thread = nux::CreateSystemThread(button_event_test->GetWindowThread(), &TestingThread, button_event_test->GetWindowThread());

  test_thread->Start(button_event_test);

  button_event_test->Run();

  delete test_thread;
  delete button_event_test;

  return 0;
}

Here is the call graph for this function:

void TestingThread ( nux::NThread thread,
void *  user_data 
)

Definition at line 80 of file xtest-mouse-buttons.cpp.

{
  while (button_event_test->ReadyToGo() == false)
  {
    nuxDebugMsg("Waiting to start");
    nux::SleepForMilliseconds(300);
  }

  nux::SleepForMilliseconds(1000);

  nux::WindowThread* wnd_thread = static_cast<nux::WindowThread*>(user_data);

  NuxAutomatedTestFramework test(wnd_thread);

  test.Startup();

  // Set the mouse at coordinates (0, 0) (top-left corner) on the display
  test.PutMouseAt(0, 0);

  test.TestReportMsg(button_event_test->test_view_, "TestView created");

  
  // Move mouse to center of the view
  test.ViewSendMouseMotionToCenter(button_event_test->test_view_);

  // Mouse click with button 1
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 1);
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_down_, "Mouse button 1 down");
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_up_, "Mouse button 1 up");

  // Mouse click with button 2
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 2);
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_down_, "Mouse button 2 down");
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_up_, "Mouse button 2 up");

  // Mouse click with button 3
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 3);
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_down_, "Mouse button 3 down");
  test.TestReportMsg(button_event_test->test_view_->registered_mouse_up_, "Mouse button 3 up");

  // Mouse click with button 4
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 4);
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_down_, "Mouse button 4 down");
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_up_, "Mouse button 4 up");

  // Mouse click with button 5
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 5);
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_down_, "Mouse button 5 down");
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_up_, "Mouse button 5 up");

  // Mouse click with button 6
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 6);
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_down_, "Mouse button 6 down");
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_up_, "Mouse button 6 up");

  // Mouse click with button 7
  button_event_test->ResetEvents();
  test.ViewSendMouseClick(button_event_test->test_view_, 7);
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_down_, "Mouse button 7 down");
  test.TestReportMsg(!button_event_test->test_view_->registered_mouse_up_, "Mouse button 7 up");

  if (test.WhenDoneTerminateProgram())
  {
    nux::SleepForMilliseconds(1000);
    wnd_thread->ExitMainLoop();
  }
  nuxDebugMsg("Exit testing thread");
}

Here is the call graph for this function:


Variable Documentation

Definition at line 78 of file xtest-mouse-buttons.cpp.