Skip to content

Commit

Permalink
VortexLib (#12)
Browse files Browse the repository at this point in the history
Converted test framework to use vortexlib
  • Loading branch information
Unreal-Dan authored Feb 11, 2023
1 parent 9def1a3 commit 7d056db
Show file tree
Hide file tree
Showing 33 changed files with 2,444 additions and 2,749 deletions.
17 changes: 15 additions & 2 deletions VortexTestingFramework.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32106.194
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VortexTestingFramework", "VortexTestingFramework\VortexTestingFramework.vcxproj", "{9E2604AF-8C7B-4DDD-8644-A13CFBB830AD}"
ProjectSection(ProjectDependencies) = postProject
{A8F96E2A-8877-465A-B12D-A544035BF054} = {A8F96E2A-8877-465A-B12D-A544035BF054}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VortexEngine", "VortexTestingFramework\VortexEngine\VortexEngine\VortexEngine.vcxproj", "{A8F96E2A-8877-465A-B12D-A544035BF054}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +26,14 @@ Global
{9E2604AF-8C7B-4DDD-8644-A13CFBB830AD}.Release|x64.Build.0 = Release|x64
{9E2604AF-8C7B-4DDD-8644-A13CFBB830AD}.Release|x86.ActiveCfg = Release|Win32
{9E2604AF-8C7B-4DDD-8644-A13CFBB830AD}.Release|x86.Build.0 = Release|Win32
{A8F96E2A-8877-465A-B12D-A544035BF054}.Debug|x64.ActiveCfg = Debug|x64
{A8F96E2A-8877-465A-B12D-A544035BF054}.Debug|x64.Build.0 = Debug|x64
{A8F96E2A-8877-465A-B12D-A544035BF054}.Debug|x86.ActiveCfg = Debug|Win32
{A8F96E2A-8877-465A-B12D-A544035BF054}.Debug|x86.Build.0 = Debug|Win32
{A8F96E2A-8877-465A-B12D-A544035BF054}.Release|x64.ActiveCfg = Release|x64
{A8F96E2A-8877-465A-B12D-A544035BF054}.Release|x64.Build.0 = Release|x64
{A8F96E2A-8877-465A-B12D-A544035BF054}.Release|x86.ActiveCfg = Release|Win32
{A8F96E2A-8877-465A-B12D-A544035BF054}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
83 changes: 83 additions & 0 deletions VortexTestingFramework/EditorPipe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include "EditorPipe.h"
#include "TestFramework.h"

HANDLE EditorPipe::hPipe = nullptr;
bool EditorPipe::m_serialConnected = false;

bool EditorPipe::init()
{
// create a global pipe
hPipe = CreateNamedPipe(
"\\\\.\\pipe\\vortextestframework",
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT,
1,
4096,
4096,
0,
NULL);
if (hPipe == INVALID_HANDLE_VALUE) {
// this will happen if two test frameworks are launched
// maybe there's a better way around it idk
return false;
}
// try to find editor window
HWND hwnd = FindWindow("VWINDOW", NULL);
if (hwnd != NULL) {
// send it a message to tell it the test framework is here
PostMessage(hwnd, WM_USER + 1, 0, 0);
}
return true;
}

bool EditorPipe::connect()
{
// create a global pipe
if (!ConnectNamedPipe(hPipe, NULL)) {
int err = GetLastError();
if (err != ERROR_PIPE_CONNECTED && err != ERROR_PIPE_LISTENING) {
return false;
}
}
m_serialConnected = true;
return true;
}

int32_t EditorPipe::available()
{
DWORD amount = 0;
if (!PeekNamedPipe(hPipe, 0, 0, 0, &amount, 0)) {
return 0;
}
return (int32_t)amount;
}

size_t EditorPipe::read(char *buf, size_t amt)
{
DWORD total = 0;
DWORD numRead = 0;
do {
if (!ReadFile(hPipe, buf + total, amt - total, &numRead, NULL)) {
int err = GetLastError();
if (err == ERROR_PIPE_NOT_CONNECTED) {
printf("Fail\n");
}
break;
}
total += numRead;
} while (total < amt);
return total;
}

uint32_t EditorPipe::write(const uint8_t *buf, size_t len)
{
DWORD total = 0;
DWORD written = 0;
do {
if (!WriteFile(hPipe, buf + total, len - total, &written, NULL)) {
break;
}
total += written;
} while (total < len);
return total;
}
23 changes: 23 additions & 0 deletions VortexTestingFramework/EditorPipe.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include <windows.h>
#include <inttypes.h>

// This is a named pipe to the editor so that the editor
// can connect with the test framework seamlessly

class EditorPipe
{
public:
static bool init();
static bool connect();
static int32_t available();
static size_t read(char *buf, size_t amt);
static uint32_t write(const uint8_t *buf, size_t len);

static bool isConnected() { return m_serialConnected; }

private:
static HANDLE hPipe;
static bool m_serialConnected;
};
15 changes: 0 additions & 15 deletions VortexTestingFramework/EngineDependencies/Adafruit_Dotstar.h

This file was deleted.

Loading

0 comments on commit 7d056db

Please sign in to comment.