Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions Test/Clipboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


//----------------------------------------------------------------------------//
// Functions //
// Locals //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -365,7 +365,7 @@ static bool TestSpeed (void)
}

VERIFY (Clipboard::Clear());
cout << endl;
cout << "\n\n";

#endif

Expand All @@ -382,14 +382,40 @@ static bool TestSpeed (void)

bool TestClipboard (void)
{
cout << "BEGIN CLIPBOARD TESTING\n------------------------------\n";
cout << "TEST CLIPBOARD\n"
<< "------------------------------\n"
<< " 0: All \n"
<< " 1: Linux\n"
<< " 2: Text \n"
<< " 3: Image\n"
<< " 4: Speed\n\n";

// Ask the user to make a selection
cout << "Enter component(s) to test: ";
string input; getline (cin, input);

int selection; cout << endl;
// Tokenize the input value
stringstream stream (input);
while (stream >> selection)
{
// Test everything
if (selection == 0)
{
return TestLinux()
&& TestText ()
&& TestImage()
&& TestSpeed();
}

cout << "Warning: Some set of tests cannot be automated\n"
<< " Please execute the following commands\n\n";
switch (selection)
{
case 1: if (!TestLinux()) return false; break;
case 2: if (!TestText ()) return false; break;
case 3: if (!TestImage()) return false; break;
case 4: if (!TestSpeed()) return false; break;
}
}

if (!TestLinux()) { cout << ">> Linux Failed\n\n"; return false; }
if (!TestText ()) { cout << ">> Text Failed \n\n"; return false; }
if (!TestImage()) { cout << ">> Image Failed\n\n"; return false; }
if (!TestSpeed()) { cout << ">> Speed Failed\n\n"; return false; }
cout << ">> Success\n\n"; return true;
return true;
}
107 changes: 86 additions & 21 deletions Test/Keyboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static Keyboard k;


//----------------------------------------------------------------------------//
// Functions //
// Locals //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -502,9 +502,17 @@ static bool TestCompiler (void)

////////////////////////////////////////////////////////////////////////////////

// Whether to continue running the thread
static volatile bool resumeThread = false;

////////////////////////////////////////////////////////////////////////////////

static void LiveThread (void)
{
Timer::Sleep (500);
if (!resumeThread)
return;

k.Click (Key0);
k.Click (Key1);
k.Click (Key2);
Expand All @@ -518,6 +526,9 @@ static void LiveThread (void)
k.Click (KeyReturn);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Click (KeyA);
k.Click (KeyB);
k.Click (KeyC);
Expand Down Expand Up @@ -547,6 +558,9 @@ static void LiveThread (void)
k.Click (KeyReturn);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Press (KeyShift);
k.Click (KeyA);
k.Click (KeyB);
Expand Down Expand Up @@ -578,6 +592,9 @@ static void LiveThread (void)
k.Click (KeyReturn);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Click (KeyAdd);
k.Click (KeySubtract);
k.Click (KeyMultiply);
Expand All @@ -596,6 +613,9 @@ static void LiveThread (void)
k.Click (KeyEnter);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Click (KeyMinus);
k.Click (KeyEqual);
k.Click (KeyBackspace);
Expand All @@ -615,6 +635,9 @@ static void LiveThread (void)
k.Click (KeyReturn);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Press (KeyShift);
k.Click (KeyGrave);
k.Click (KeyMinus);
Expand All @@ -632,9 +655,14 @@ static void LiveThread (void)
k.Click (KeyReturn);

Timer::Sleep (500);
if (!resumeThread)
return;

k.Click ("+Hello +Robo<<<+(obot)+1~");
}

////////////////////////////////////////////////////////////////////////////////

static bool TestLive (void)
{
#if (_MSC_VER == 1600)
Expand All @@ -645,45 +673,51 @@ static bool TestLive (void)
getchar();

char input[32] = { 0 };
// Create live testing thread
std::thread live (LiveThread);
resumeThread = true;
// Create testing thread
thread live (LiveThread);

cout << "Numbers: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "0123456789") == 0);
if (strcmp (input, "0123456789"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Alphabet: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "abcdefghijklmnopqrstuvwxyz") == 0);
if (strcmp (input, "abcdefghijklmnopqrstuvwxyz"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Alphabet: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == 0);
if (strcmp (input, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Keypad: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "+-*/.0123456789") == 0);
if (strcmp (input, "+-*/.0123456789"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Punctuation: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "`-=[ ]\\;',./") == 0);
if (strcmp (input, "`-=[ ]\\;',./"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Punctuation: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "~_+{ }|:\"<>?") == 0);
if (strcmp (input, "~_+{ }|:\"<>?"))
{ resumeThread = false; live.join(); VERIFY (false); }

cout << "Hello Robot: ";
cin.getline (input, 32);
VERIFY (strcmp (input, "Hello ROBOT!") == 0);
if (strcmp (input, "Hello ROBOT!"))
{ resumeThread = false; live.join(); VERIFY (false); }

// End thread
live.join();
cout << endl;

#endif

cout << "\nWarning: The next set of tests cannot be automated\n"
<< " Please review the following instructions!\n\n";

cout << "- Live testing will be performed in sets\n"
<< "- Press enter to begin testing a new set\n"
<< "- After beginning, focus the testing app\n"
Expand Down Expand Up @@ -764,9 +798,6 @@ static bool TestLive (void)

static bool TestGetState (void)
{
cout << "Warning: The next set of tests cannot be automated\n"
<< " Please review the following instructions!\n\n";

cout << "- Press keys and verify output\n"
<< "- Press enter to begin testing\n"
<< "- Press escape to stop testing\n";
Expand Down Expand Up @@ -916,13 +947,47 @@ static bool TestGetState (void)
return true;
}



//----------------------------------------------------------------------------//
// Functions //
//----------------------------------------------------------------------------//

////////////////////////////////////////////////////////////////////////////////

bool TestKeyboard (void)
{
cout << "BEGIN KEYBOARD TESTING\n------------------------------\n";
if (!TestCompiler()) { cout << ">> Compiler Failed \n\n"; return false; }
if (!TestLive ()) { cout << ">> Live Test Failed\n\n"; return false; }
if (!TestGetState()) { cout << ">> Get State Failed\n\n"; return false; }
cout << ">> Success\n\n"; return true;
cout << "TEST KEYBOARD\n"
<< "------------------------------\n"
<< " 0: All \n"
<< " 1: Compiler \n"
<< " 2: Live Test\n"
<< " 3: GetState \n\n";

// Ask the user to make a selection
cout << "Enter component(s) to test: ";
string input; getline (cin, input);

int selection; cout << endl;
// Tokenize the input value
stringstream stream (input);
while (stream >> selection)
{
// Test everything
if (selection == 0)
{
return TestCompiler()
&& TestLive ()
&& TestGetState();
}

switch (selection)
{
case 1: if (!TestCompiler()) return false; break;
case 2: if (!TestLive ()) return false; break;
case 3: if (!TestGetState()) return false; break;
}
}

return true;
}
Loading