aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp
blob: 3f290b862272840f15a81f385710064a1d700f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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.

#include "precomp.h"

HRESULT RunReloadEngine(
    __in LPCWSTR wzBundleFilePath,
    __in LPCWSTR wzBAFilePath
    )
{
    HRESULT hr = S_OK;
    TestEngine* pTestEngine = NULL;

    pTestEngine = new TestEngine();
    ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine.");

    hr = pTestEngine->Initialize(wzBundleFilePath);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine.");

    hr = pTestEngine->LoadBA(wzBAFilePath);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA.");

    hr = pTestEngine->SendStartupEvent();
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup.");

    hr = pTestEngine->SimulateQuit(0);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit.");

    hr = pTestEngine->RunApplication();
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine.");

    hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown.");

    pTestEngine->UnloadBA(TRUE);

    hr = pTestEngine->LoadBA(wzBAFilePath);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA.");

    hr = pTestEngine->SendStartupEvent();
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup.");

    hr = pTestEngine->SimulateQuit(0);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit.");

    hr = pTestEngine->RunApplication();
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine.");

    hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART);
    ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown.");

    pTestEngine->UnloadBA(FALSE);

LExit:
    return hr;
}