stuff-from-scratch/test/ui_test_runner.cpp

57 lines
1.4 KiB
C++
Raw Permalink Normal View History

2023-01-05 13:16:52 +00:00
#include "TestFramework.h"
#include "CommandLineArgs.h"
#include "MainApplication.h"
2023-01-05 16:40:27 +00:00
#include "TestUiApplication.h"
2023-01-05 13:16:52 +00:00
#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);
2023-01-16 12:36:02 +00:00
auto args = CommandLineArgs::Create();
CommandLineArgs::initialize(args.get());
2023-01-05 13:16:52 +00:00
2023-01-12 11:54:08 +00:00
const auto user_args = args->getUserArgs();
2023-01-05 13:16:52 +00:00
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));
2023-01-05 16:40:27 +00:00
auto gui_app = std::make_unique<TestUiApplication>(nullptr, std::move(main_app));
2023-01-16 12:36:02 +00:00
2023-01-05 13:16:52 +00:00
#else
int main(int argc, char *argv[])
{
2023-01-16 12:36:02 +00:00
auto args = CommandLineArgs::Create();
2023-01-05 13:16:52 +00:00
args->process(argc, argv);
2023-01-16 12:36:02 +00:00
auto user_args = args->getArgs();
auto gui_app = std::make_unique<TestUiApplication>(std::move(args));
2023-01-05 13:16:52 +00:00
#endif
TestCaseRunner::getInstance().setTestApplication(gui_app.get());
2023-01-23 11:06:30 +00:00
TestCaseRunner::getInstance().run(user_args);
2023-01-05 13:16:52 +00:00
#ifdef _WIN32
CoUninitialize();
#endif
return 0;
}