diff options
Diffstat (limited to 'src/test/examples/TestEngine/TestEngine.cpp')
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/test/examples/TestEngine/TestEngine.cpp b/src/test/examples/TestEngine/TestEngine.cpp index c0a62eda..9d8f8638 100644 --- a/src/test/examples/TestEngine/TestEngine.cpp +++ b/src/test/examples/TestEngine/TestEngine.cpp | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | HRESULT TestEngine::LoadBA( | 5 | HRESULT TestEngine::LoadBA( |
| 6 | __in LPCWSTR wzBundleFilePath, | ||
| 6 | __in LPCWSTR wzBAFilePath | 7 | __in LPCWSTR wzBAFilePath |
| 7 | ) | 8 | ) |
| 8 | { | 9 | { |
| 9 | HRESULT hr = S_OK; | 10 | HRESULT hr = S_OK; |
| 10 | BOOTSTRAPPER_COMMAND command = { }; | 11 | BOOTSTRAPPER_COMMAND command = { }; |
| 11 | BOOTSTRAPPER_CREATE_ARGS args = { }; | 12 | BOOTSTRAPPER_CREATE_ARGS args = { }; |
| 12 | HMODULE hBAModule = NULL; | ||
| 13 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; | 13 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; |
| 14 | 14 | ||
| 15 | if (m_pCreateResults) | 15 | if (m_pCreateResults) |
| @@ -19,7 +19,7 @@ HRESULT TestEngine::LoadBA( | |||
| 19 | 19 | ||
| 20 | LogInitialize(::GetModuleHandleW(NULL)); | 20 | LogInitialize(::GetModuleHandleW(NULL)); |
| 21 | 21 | ||
| 22 | hr = LogOpen(NULL, L"ExampleTestEngine", NULL, L"txt", FALSE, FALSE, NULL); | 22 | hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL); |
| 23 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); | 23 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); |
| 24 | 24 | ||
| 25 | m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); | 25 | m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); |
| @@ -34,10 +34,10 @@ HRESULT TestEngine::LoadBA( | |||
| 34 | 34 | ||
| 35 | m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); | 35 | m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); |
| 36 | 36 | ||
| 37 | hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); | 37 | m_hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); |
| 38 | ExitOnNullWithLastError(hBAModule, hr, "Failed to load BA dll."); | 38 | ExitOnNullWithLastError(m_hBAModule, hr, "Failed to load BA dll."); |
| 39 | 39 | ||
| 40 | pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(hBAModule, "BootstrapperApplicationCreate"); | 40 | pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(m_hBAModule, "BootstrapperApplicationCreate"); |
| 41 | ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); | 41 | ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); |
| 42 | 42 | ||
| 43 | hr = pfnCreate(&args, m_pCreateResults); | 43 | hr = pfnCreate(&args, m_pCreateResults); |
| @@ -68,6 +68,29 @@ HRESULT TestEngine::SendShutdownEvent( | |||
| 68 | return hr; | 68 | return hr; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | HRESULT TestEngine::SendStartupEvent() | ||
| 72 | { | ||
| 73 | HRESULT hr = S_OK; | ||
| 74 | BA_ONSTARTUP_ARGS startupArgs = { }; | ||
| 75 | BA_ONSTARTUP_RESULTS startupResults = { }; | ||
| 76 | startupArgs.cbSize = sizeof(BA_ONSTARTUP_ARGS); | ||
| 77 | startupResults.cbSize = sizeof(BA_ONSTARTUP_RESULTS); | ||
| 78 | hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &startupArgs, &startupResults, m_pCreateResults->pvBootstrapperApplicationProcContext); | ||
| 79 | return hr; | ||
| 80 | } | ||
| 81 | |||
| 82 | void TestEngine::UnloadBA() | ||
| 83 | { | ||
| 84 | PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; | ||
| 85 | |||
| 86 | pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy"); | ||
| 87 | |||
| 88 | if (pfnDestroy) | ||
| 89 | { | ||
| 90 | pfnDestroy(); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 71 | HRESULT TestEngine::BAEngineLog( | 94 | HRESULT TestEngine::BAEngineLog( |
| 72 | __in TestEngine* pContext, | 95 | __in TestEngine* pContext, |
| 73 | __in BAENGINE_LOG_ARGS* pArgs, | 96 | __in BAENGINE_LOG_ARGS* pArgs, |
| @@ -108,6 +131,7 @@ LExit: | |||
| 108 | 131 | ||
| 109 | TestEngine::TestEngine() | 132 | TestEngine::TestEngine() |
| 110 | { | 133 | { |
| 134 | m_hBAModule = NULL; | ||
| 111 | m_pCreateResults = NULL; | 135 | m_pCreateResults = NULL; |
| 112 | } | 136 | } |
| 113 | 137 | ||
