Back to index

nux  3.0.0
Classes | Functions | Variables
xtest-focus-on-mouse-enter.cpp File Reference
#include "Nux/Nux.h"
#include "Nux/WindowThread.h"
#include "Nux/VLayout.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  FocusOnMouseEnterTest

Functions

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

Variables

FocusOnMouseEnterTestfocus_on_mouse_enter_test = nullptr

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 119 of file xtest-focus-on-mouse-enter.cpp.

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

  focus_on_mouse_enter_test = new FocusOnMouseEnterTest("Focus On Mouse Enter Test", 300, 300, 15000);
  focus_on_mouse_enter_test->Startup();
  focus_on_mouse_enter_test->UserInterfaceSetup();

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

  test_thread->Start(focus_on_mouse_enter_test);

  focus_on_mouse_enter_test->Run();

  delete test_thread;
  delete focus_on_mouse_enter_test;

  return 0;
}

Here is the call graph for this function:

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

Definition at line 79 of file xtest-focus-on-mouse-enter.cpp.

{
  while (focus_on_mouse_enter_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(focus_on_mouse_enter_test->focus_view_, "Focus view created");
  test.TestReportMsg(focus_on_mouse_enter_test->no_focus_view_, "No focus view created");

  // Move mouse to center of no_focus_view_
  test.ViewSendMouseMotionToCenter(focus_on_mouse_enter_test->no_focus_view_);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(!focus_on_mouse_enter_test->no_focus_view_->has_focus_, "no_focus_view_ did not take the focus");

   // Move mouse to center of focus_view_
  test.ViewSendMouseMotionToCenter(focus_on_mouse_enter_test->focus_view_);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(focus_on_mouse_enter_test->focus_view_->has_focus_, "focus_view_ has the focus");

  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 77 of file xtest-focus-on-mouse-enter.cpp.