| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | #include "precomp.h" |
| 4 | |
| 5 | HRESULT RunShutdownEngine( |
| 6 | __in LPCWSTR wzBundleFilePath, |
| 7 | __in LPCWSTR wzBAFilePath |
| 8 | ) |
| 9 | { |
| 10 | HRESULT hr = S_OK; |
| 11 | TestEngine* pTestEngine = NULL; |
| 12 | |
| 13 | pTestEngine = new TestEngine(); |
| 14 | ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); |
| 15 | |
| 16 | hr = pTestEngine->Initialize(wzBundleFilePath); |
| 17 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); |
| 18 | |
| 19 | hr = pTestEngine->LoadBA(wzBAFilePath); |
| 20 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); |
| 21 | |
| 22 | hr = pTestEngine->SendStartupEvent(); |
| 23 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); |
| 24 | |
| 25 | hr = pTestEngine->SimulateQuit(0); |
| 26 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); |
| 27 | |
| 28 | hr = pTestEngine->RunApplication(); |
| 29 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); |
| 30 | |
| 31 | hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); |
| 32 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); |
| 33 | |
| 34 | pTestEngine->UnloadBA(FALSE); |
| 35 | |
| 36 | LExit: |
| 37 | return hr; |
| 38 | } |