Skip to content

Commit

Permalink
Fixes and added integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Apr 24, 2023
1 parent f497d35 commit da13262
Show file tree
Hide file tree
Showing 11 changed files with 760 additions and 42 deletions.
2 changes: 1 addition & 1 deletion VortexTestingFramework/LinuxMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
int main(int argc, char *argv[])
{
TestFramework framework;
framework.init();
framework.init(argc, argv);
#ifndef WASM
while (framework.stillRunning()) {
framework.run();
Expand Down
25 changes: 7 additions & 18 deletions VortexTestingFramework/TestFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,20 +579,9 @@ bool TestFramework::handlePatternChange(bool force)
// update current mode
m_curMode = *targetMode;
m_curMode.init();
// the realpos is used to target the actual index of pattern to run
// where as the cur selected led might be the middle finger for example
LedPos realPos = (LedPos)(m_curSelectedLed);
if (m_curMode.isMultiLed()) {
// if it's multi led then the real pos is just the first
realPos = (LedPos)(LED_FIRST);
}
// grab the target pattern object that will run
Pattern *targetPat = m_curMode.getPattern(realPos);
if (!targetPat) {
return false;
}
// backup the selected led
RGBColor backupCol = m_ledList[m_curSelectedLed];
// backup the led colors
RGBColor backupCols[LED_COUNT];
memcpy(backupCols, m_ledList, sizeof(RGBColor) * LED_COUNT);
// begin the time simulation so we can tick forward
Time::startSimulation();
// the actual strip is twice the width of the window to allow scrolling
Expand All @@ -603,8 +592,8 @@ bool TestFramework::handlePatternChange(bool force)
}
// clear and re-generate the pattern strip
for (uint32_t x = 0; x < patternStripWidth; ++x) {
// run the pattern like normal
targetPat->play();
// run the current mode like normal
m_curMode.play();
// tick the virtual time forward so that next play()
// the engine will think a tick has passed
Time::tickSimulation();
Expand All @@ -622,8 +611,8 @@ bool TestFramework::handlePatternChange(bool force)
// back to where it was before starting the sim
Time::endSimulation();
// restore original color on the target led
m_ledList[m_curSelectedLed] = backupCol;
// redraw this led because it was written to to generate pattern strip
memcpy(m_ledList, backupCols, sizeof(RGBColor) * LED_COUNT);
// redraw this led because it was written to generate pattern strip
m_leds[m_curSelectedLed].redraw();
// update the background of the pattern strip
m_patternStrip.setBackground(bitmap);
Expand Down
58 changes: 37 additions & 21 deletions VortexTestingFramework/TestFrameworkLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <ctime>

#include <getopt.h>
#include <stdio.h>

#include "TestFrameworkLinux.h"
Expand Down Expand Up @@ -58,6 +59,8 @@ static void wasm_init()
emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback);
emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, key_callback);
emscripten_set_main_loop(do_run, 0, true);
// turn colored output off in the wasm version
g_pTestFramework->setColoredOuptut(false);
}
#endif // ifdef WASM

Expand All @@ -68,15 +71,16 @@ TestFramework::TestFramework() :
m_keepGoing(true),
m_isPaused(true),
m_curPattern(PATTERN_FIRST),
m_curColorset()
m_curColorset(),
m_colored_output(false)
{
}

TestFramework::~TestFramework()
{
}

bool TestFramework::init()
bool TestFramework::init(int argc, char *argv[])
{
if (g_pTestFramework) {
return false;
Expand All @@ -87,6 +91,18 @@ bool TestFramework::init()
printf("Initializing...\n");
#endif

int opt;
while ((opt = getopt(argc, argv, "c")) != -1) {
switch (opt) {
case 'c':
m_colored_output = true;
break;
default: // '?' for unrecognized options
fprintf(stderr, "Usage: %s [-c]\n", argv[0]);
exit(EXIT_FAILURE);
}
}

// do the arduino init/setup
Vortex::init<TestFrameworkCallbacks>();

Expand Down Expand Up @@ -133,26 +149,26 @@ void TestFramework::show()
return;
}
string out;
#ifdef WASM
for (uint32_t i = 0; i < m_numLeds; ++i) {
char buf[128] = { 0 };
snprintf(buf, sizeof(buf), "#%06X|", m_ledList[i].raw());
out += buf;
}
out += "\n";
#else
out += "\33[2K\033[A\r";
for (uint32_t i = 0; i < m_numLeds; ++i) {
out += "\x1B[0m|"; // opening |
out += "\x1B[48;2;"; // colorcode start
out += to_string(m_ledList[i].red) + ";"; // col red
out += to_string(m_ledList[i].green) + ";"; // col green
out += to_string(m_ledList[i].blue) + "m"; // col blue
out += " "; // colored space
out += "\x1B[0m|"; // ending |
if (m_colored_output) {
out += "\33[2K\033[A\r";
for (uint32_t i = 0; i < m_numLeds; ++i) {
out += "\x1B[0m|"; // opening |
out += "\x1B[48;2;"; // colorcode start
out += to_string(m_ledList[i].red) + ";"; // col red
out += to_string(m_ledList[i].green) + ";"; // col green
out += to_string(m_ledList[i].blue) + "m"; // col blue
out += " "; // colored space
out += "\x1B[0m|"; // ending |
}
out += USAGE;
} else {
for (uint32_t i = 0; i < m_numLeds; ++i) {
char buf[128] = { 0 };
snprintf(buf, sizeof(buf), "#%06X|", m_ledList[i].raw());
out += buf;
}
out += "\n";
}
out += USAGE;
#endif
printf("%s", out.c_str());
fflush(stdout);
}
Expand Down
6 changes: 5 additions & 1 deletion VortexTestingFramework/TestFrameworkLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class TestFramework
~TestFramework();

// initialize the test framework
bool init();
bool init(int argc, char *argv[]);

// run the test framework
void run();
void cleanup();
Expand All @@ -48,6 +49,8 @@ class TestFramework

static void printlog(const char *file, const char *func, int line, const char *msg, va_list list);

void setColoredOutput(bool output) { m_colored_output = output; }

private:
class TestFrameworkCallbacks : public VortexCallbacks
{
Expand All @@ -70,6 +73,7 @@ class TestFramework
volatile bool m_isPaused;
PatternID m_curPattern;
Colorset m_curColorset;
bool m_colored_output;
};

extern TestFramework *g_pTestFramework;
2 changes: 1 addition & 1 deletion VortexTestingFramework/VortexEngine
160 changes: 160 additions & 0 deletions VortexTestingFramework/tests/enter_colorselect.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
Input=dasq
Brief=Test to ensure that a long press will enter the color select
--------------------------------------------------------------------------------
Initializing...
Initialized!
a = short press | s = med press | d = enter ringmenu | f = toggle pressed | q = quit
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|
#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|
#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|
#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|#ABAA00|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|
#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|
#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|
#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|#5500AB|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|#FF0000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|#00FF00|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|#0000FF|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|#000000|
#832300|#832300|#832300|#832300|#832300|#832300|#832300|#832300|#832300|#832300|
Loading

0 comments on commit da13262

Please sign in to comment.