Back to index

nux  3.0.0
Classes | Functions | Variables
xtest-mouse-events.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  EventsTest

Functions

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

Variables

EventsTestevent_test = NULL

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 137 of file xtest-mouse-events.cpp.

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

  event_test = new EventsTest("Events Test", 300, 300, 20000);
  event_test->Startup();
  event_test->UserInterfaceSetup();

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

  test_thread->Start(event_test);

  event_test->Run();

  delete test_thread;
  delete event_test;

  return 0;
}

Here is the call graph for this function:

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

Definition at line 81 of file xtest-mouse-events.cpp.

{
  while (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(event_test->test_view_, "TestView created");

  event_test->ResetEvents();
  test.ViewSendMouseMotionToCenter(event_test->test_view_);

  test.TestReportMsg(event_test->test_view_->registered_mouse_move_, "Mouse move event");
  test.TestReportMsg(event_test->test_view_->registered_mouse_enter_, "Mouse enter event");
  test.ViewSendMouseClick(0, 1);

  test.TestReportMsg(event_test->test_view_->registered_mouse_down_, "Mouse down event");
  test.TestReportMsg(event_test->test_view_->registered_mouse_up_, "Mouse up event");
  test.TestReportMsg(event_test->test_view_->registered_mouse_click_, "Mouse click event");

  test.ViewSendMouseDrag(event_test->test_view_, 1, 0, 0, 50, 50);
  test.TestReportMsg(event_test->test_view_->registered_mouse_click_, "Mouse drag event");

  test.ViewSendMouseMotionTo(event_test->test_view_, -5, -5);
  test.TestReportMsg(event_test->test_view_->registered_mouse_leave_, "Mouse leave event");

  event_test->test_view_->EnableDoubleClick(true);
  test.ViewSendMouseDoubleClick(event_test->test_view_, 1);
  test.TestReportMsg(event_test->test_view_->registered_mouse_double_click_, "Mouse double click event");

  event_test->ResetEvents();
  // Deactivate double click and test if the view still receives it.
  event_test->test_view_->EnableDoubleClick(false);
  test.ViewSendMouseDoubleClick(event_test->test_view_, 1);
  test.TestReportMsg(!event_test->test_view_->registered_mouse_double_click_, "Mouse double click de-activated");

  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 79 of file xtest-mouse-events.cpp.