stuff-from-scratch/test/ui_test_runner.cpp

51 lines
1.2 KiB
C++
Raw 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);
auto args = CommandLineArgs::Create();
CommandLineArgs::initialize(args.get());
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-05 13:16:52 +00:00
#else
int main(int argc, char *argv[])
{
auto args = CommandLineArgs::Create();
args->process(argc, argv);
#endif
TestCaseRunner::getInstance().setTestApplication(gui_app.get());
auto result = TestCaseRunner::getInstance().run({});
#ifdef _WIN32
CoUninitialize();
#endif
return 0;
}