stuff-from-scratch/test/ui_test_runner.cpp
2023-01-23 11:06:30 +00:00

56 lines
1.4 KiB
C++

#include "TestFramework.h"
#include "CommandLineArgs.h"
#include "MainApplication.h"
#include "TestUiApplication.h"
#include "Widget.h"
#ifdef _WIN32
#include "Win32WindowInterface.h"
#include <windows.h>
#endif
#include <iostream>
#ifdef _WIN32
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
std::ofstream out("out.txt");
std::cout.rdbuf(out.rdbuf());
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
auto args = CommandLineArgs::Create();
CommandLineArgs::initialize(args.get());
const auto user_args = args->getUserArgs();
auto main_app = MainApplication::Create();
auto applicationContext = std::make_unique<Win32ApplicationContext>();
applicationContext->hInstance = reinterpret_cast<void*>(hInstance);
applicationContext->nCmdShow = nCmdShow;
main_app->initialize(std::move(args), std::move(applicationContext));
auto gui_app = std::make_unique<TestUiApplication>(nullptr, std::move(main_app));
#else
int main(int argc, char *argv[])
{
auto args = CommandLineArgs::Create();
args->process(argc, argv);
auto user_args = args->getArgs();
auto gui_app = std::make_unique<TestUiApplication>(std::move(args));
#endif
TestCaseRunner::getInstance().setTestApplication(gui_app.get());
TestCaseRunner::getInstance().run(user_args);
#ifdef _WIN32
CoUninitialize();
#endif
return 0;
}