From 516881d4095ac4a8edc85c4731d840ca700a017c Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 10 Jun 2019 22:23:06 -0400 Subject: [PATCH] reorganize tests --- CMakeLists.txt | 2 +- extensions/CMakeLists.txt | 2 -- extensions/extensiontester.cpp | 12 ------------ test/CMakeLists.txt | 1 + {testbed => test}/main.cpp | 14 ++++++++++++-- {testbed => test}/resource.h | 0 {testbed => test}/resource.rc | Bin 5896 -> 5902 bytes testbed/CMakeLists.txt | 1 - 8 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 extensions/extensiontester.cpp create mode 100644 test/CMakeLists.txt rename {testbed => test}/main.cpp (57%) rename {testbed => test}/resource.h (100%) rename {testbed => test}/resource.rc (90%) delete mode 100644 testbed/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d360d..524b464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,4 +36,4 @@ add_subdirectory(GUI) add_subdirectory(GUI/host) add_subdirectory(texthook) add_subdirectory(extensions) -add_subdirectory(testbed) +add_subdirectory(test) diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 8eafe37..2d9c70c 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -15,8 +15,6 @@ add_library(Remove\ Repetition MODULE removerepeat.cpp extensionimpl.cpp) add_library(Replacer MODULE replacer.cpp extensionimpl.cpp) add_library(Thread\ Linker MODULE threadlinker.cpp extensionimpl.cpp) -add_executable(Extension_Tests extensiontester.cpp) - target_link_libraries(Bing\ Translate winhttp Qt5::Widgets) target_link_libraries(Extra\ Window Qt5::Widgets) target_link_libraries(Google\ Translate winhttp Qt5::Widgets) diff --git a/extensions/extensiontester.cpp b/extensions/extensiontester.cpp deleted file mode 100644 index e34841a..0000000 --- a/extensions/extensiontester.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "common.h" -#include - -int main() -{ - wchar_t path[MAX_PATH] = {}; - GetModuleFileNameW(NULL, path, MAX_PATH); - *(wcsrchr(path, L'\\') + 1) = 0; - for (auto file : std::filesystem::directory_iterator(path)) - if (file.path().extension() == L".dll") LoadLibraryW(file.path().c_str()); - Sleep(10000); -} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..0cd93f8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(Test WIN32 main.cpp resource.rc) diff --git a/testbed/main.cpp b/test/main.cpp similarity index 57% rename from testbed/main.cpp rename to test/main.cpp index dabe57e..66b88a9 100644 --- a/testbed/main.cpp +++ b/test/main.cpp @@ -1,13 +1,19 @@ #include "common.h" #include "defs.h" #include "resource.h" +#include +#include +#include wchar_t buffer[1000] = {}; std::array vars = {}; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) { - LoadLibraryW(ITH_DLL); + for (auto file : std::filesystem::directory_iterator(std::filesystem::current_path())) + if (file.path().extension() == L".dll" + && (std::stringstream() << std::ifstream(file.path(), std::ios::binary).rdbuf()).str().find("OnNewSentence") != std::string::npos) + LoadLibraryW(file.path().c_str()); ShowWindow(CreateDialogParamW(hInstance, MAKEINTRESOURCEW(IDD_DIALOG1), NULL, [](HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -> INT_PTR { @@ -37,7 +43,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) return FALSE; }, 0), SW_SHOW); - std::thread([] { while (true) lstrlenW(L"こんにちは"); }).detach(); + std::thread([] { while (true) Sleep(vars.at(0)), lstrlenW(L"こんにちは"); }).detach(); + + STARTUPINFOW info = { sizeof(info) }; + wchar_t commandLine[] = { L"Textractor -p\"Test.exe\"" }; + CreateProcessW(NULL, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &info, DUMMY); MSG msg; while (GetMessageW(&msg, NULL, 0, 0) > 0) diff --git a/testbed/resource.h b/test/resource.h similarity index 100% rename from testbed/resource.h rename to test/resource.h diff --git a/testbed/resource.rc b/test/resource.rc similarity index 90% rename from testbed/resource.rc rename to test/resource.rc index 64dd59d3d94ec63264651d5e7ab4123093e8d667..0baf4fbf8c7008ba3e3f74f0e7bfa9a2a5231849 100644 GIT binary patch delta 161 zcmeCs>(kqCfNk?JHYQfd9EM_s5{4p%9EMbeJO%}Z6d;|$kjPLuIgn40(~!ZCL5IPN z!DzA|pZ#Pz9t~y~dj%3(h!-JVgT#IYXQ#vU?c&pdv(@+!>`DAOAo0xy`Q6z8p+zJa delta 153 zcmeCv>(JY9fQ>bYA(bIz^L{pF*2xcec^C~RALLVJH)POZFk-Nr+{kA?*@Z`g8OC0R v#FpSih&Lgz-ypHW_+V->;b!RYYr)ww_;uKg8H|CpSxlbDBE0z?zX3Y{H1H>E diff --git a/testbed/CMakeLists.txt b/testbed/CMakeLists.txt deleted file mode 100644 index 66c9427..0000000 --- a/testbed/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_executable(Testbed WIN32 main.cpp resource.rc)