Back to index

nux  3.0.0
Classes | Functions | Variables
xtest-keynav-directions.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  KeyNavDirectionTest

Functions

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

Variables

KeyNavDirectionTestkeynav_direction_test = NULL

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 167 of file xtest-keynav-directions.cpp.

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

  keynav_direction_test = new KeyNavDirectionTest("Automated: KeyNav Directions", 300, 300, 15000);
  keynav_direction_test->Startup();
  keynav_direction_test->UserInterfaceSetup();

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

  test_thread->Start(keynav_direction_test);

  keynav_direction_test->Run();

  delete test_thread;
  delete keynav_direction_test;

  return 0;
}

Here is the call graph for this function:

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

Definition at line 103 of file xtest-keynav-directions.cpp.

{
  while (keynav_direction_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);

  // Move mouse to center of view0_
  test.ViewSendMouseMotionToCenter(keynav_direction_test->view0_);

  // Mouse down/up on view0_
  test.ViewSendMouseClick(keynav_direction_test->view0_, 1);
  
  nux::SleepForMilliseconds(500);
  test.SendFakeKeyEvent(XK_Down, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view1_->has_focus_ && (keynav_direction_test->view1_->key_nav_direction_ == nux::KEY_NAV_DOWN),
   "View1 received key nav from top");
  
  test.SendFakeKeyEvent(XK_Up, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view0_->has_focus_ && (keynav_direction_test->view0_->key_nav_direction_ == nux::KEY_NAV_UP),
   "View0 received key nav from bottom");
    
  test.SendFakeKeyEvent(XK_Right, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view2_->has_focus_ && (keynav_direction_test->view0_->key_nav_direction_ == nux::KEY_NAV_RIGHT),
   "View2 received key nav from left");
   
  test.SendFakeKeyEvent(XK_Down, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view3_->has_focus_ && (keynav_direction_test->view3_->key_nav_direction_ == nux::KEY_NAV_DOWN),
   "View3 received key nav from top");
   
  test.SendFakeKeyEvent(XK_Up, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view2_->has_focus_ && (keynav_direction_test->view2_->key_nav_direction_ == nux::KEY_NAV_UP),
   "View2 received key nav from bottom");
   
  test.SendFakeKeyEvent(XK_Left, 0);
  nux::SleepForMilliseconds(500);
  test.TestReportMsg(keynav_direction_test->view0_->has_focus_ && (keynav_direction_test->view0_->key_nav_direction_ == nux::KEY_NAV_LEFT),
   "View0 received key nav from right");
                
  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 101 of file xtest-keynav-directions.cpp.