Back to index

nux  3.0.0
Classes | Functions | Variables
xtest-text-entry-logic.cpp File Reference
#include "Nux/Nux.h"
#include "Nux/WindowThread.h"
#include "Nux/VLayout.h"
#include "Nux/TextEntry.h"
#include "Nux/InputMethodIBus.h"
#include "Nux/ProgramFramework/ProgramTemplate.h"
#include "Nux/ProgramFramework/TestView.h"
#include "Nux/ProgramFramework/TestTextEntry.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  TestTextEntry

Functions

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

Variables

TestTextEntry * test_textentry = NULL

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 139 of file xtest-text-entry-logic.cpp.

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

  test_textentry = new TestTextEntry("Text Entry", 600, 200, 10000);
  test_textentry->Startup();
  test_textentry->UserInterfaceSetup();

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

  test_thread->Start(test_textentry);

  test_textentry->Run();

  delete test_thread;
  delete test_textentry;

  return 0;
}

Here is the call graph for this function:

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

Definition at line 86 of file xtest-text-entry-logic.cpp.

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

  nux::SleepForMilliseconds(1300);

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

  NuxAutomatedTestFramework test(wnd_thread);

  test.Startup();

  test.TestReportMsg(test_textentry->text_entry_, "TextEntry created");

  test_textentry->ResetEvents();
  test.ViewSendMouseMotionToCenter(test_textentry->text_entry_);

  test.TestReportMsg(test_textentry->text_entry_->HasKeyFocus() == false, "Focus test");
  test.TestReportMsg(test_textentry->text_entry_->IsInTextInputMode() == false, "Text input mode test");
  test.ViewSendMouseClick(0, 1);
  test.TestReportMsg(test_textentry->text_entry_->HasKeyFocus() == true, "Focus test");
  test.TestReportMsg(test_textentry->text_entry_->IsInTextInputMode() == false, "Text input mode test");

  // Type "Nux"
  // The cursor is at the end of the line
  // Simulate CTRL+A to select the entire text
  // Simulate DELETE key to delete the text
  {
    test.ViewSendString("Nux");
    test.TestReportMsg(test_textentry->text_entry_->GetText() == "Nux", "Typed \"Nux\"");

    test.TestReportMsg(test_textentry->text_entry_->IsInTextInputMode() == true, "Text input mode test");

    test.ViewSendCtrlA();
    nux::SleepForMilliseconds(500);
    test.TestReportMsg(test_textentry->text_entry_->GetTextSelection() == "Nux", "Selection is \"Nux\"");

    test.ViewSendDelete();
    nux::SleepForMilliseconds(500);
    test.TestReportMsg(test_textentry->text_entry_->GetText() == "", "TextEntry is empty");
  }

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

Here is the call graph for this function:


Variable Documentation

TestTextEntry* test_textentry = NULL

Definition at line 84 of file xtest-text-entry-logic.cpp.