summaryrefslogtreecommitdiff
path: root/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-11-10 22:48:05 -0600
committerSean Hall <r.sean.hall@gmail.com>2022-11-10 23:49:10 -0600
commit209c92111928a98972d7f0f9d6d620ab566564d9 (patch)
treefd13d81105b02e63cc61c7819dba6f5c6c7e936e /src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
parent3f6a633769a9c732db765411ef9b810133ad3957 (diff)
downloadwix-209c92111928a98972d7f0f9d6d620ab566564d9.tar.gz
wix-209c92111928a98972d7f0f9d6d620ab566564d9.tar.bz2
wix-209c92111928a98972d7f0f9d6d620ab566564d9.zip
Automate the test for GetRelatedBundleVariable.
Diffstat (limited to 'src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp')
-rw-r--r--src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp b/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
new file mode 100644
index 00000000..01750b4b
--- /dev/null
+++ b/src/test/burn/TestData/BAFunctionsTests/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp
@@ -0,0 +1,102 @@
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#include "BalBaseBAFunctions.h"
5#include "BalBaseBAFunctionsProc.h"
6
7const LPCWSTR STRING_VARIABLE = L"AString";
8const LPCWSTR NUMBER_VARIABLE = L"ANumber";
9
10class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions
11{
12public: // IBAFunctions
13
14
15public: //IBootstrapperApplication
16 virtual STDMETHODIMP OnDetectRelatedBundle(
17 __in_z LPCWSTR wzBundleId,
18 __in BOOTSTRAPPER_RELATION_TYPE relationType,
19 __in_z LPCWSTR wzBundleTag,
20 __in BOOL fPerMachine,
21 __in LPCWSTR wzVersion,
22 __in BOOL fMissingFromCache,
23 __inout BOOL* pfCancel
24 )
25 {
26
27 HRESULT hr = S_OK;
28 LPWSTR wzValue = NULL;
29
30 hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue);
31
32 ExitOnFailure(hr, "Failed to get related bundle string variable.");
33
34 if (wzValue)
35 {
36 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: AString = %ws", wzValue);
37 }
38
39 hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue);
40
41 if (wzValue)
42 {
43 BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieved related bundle variable with BAFunctions: ANumber = %ws", wzValue);
44 }
45
46 hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel);
47 LExit:
48 ReleaseStr(wzValue);
49 return hr;
50 }
51private:
52
53
54public:
55 //
56 // Constructor - initialize member variables.
57 //
58 CBafRelatedBundleVariableTesting(
59 __in HMODULE hModule,
60 __in IBootstrapperEngine* pEngine,
61 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs
62 ) : CBalBaseBAFunctions(hModule, pEngine, pArgs)
63 {
64 }
65
66 //
67 // Destructor - release member variables.
68 //
69 ~CBafRelatedBundleVariableTesting()
70 {
71 }
72
73private:
74};
75
76
77HRESULT WINAPI CreateBAFunctions(
78 __in HMODULE hModule,
79 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
80 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
81 )
82{
83 HRESULT hr = S_OK;
84 CBafRelatedBundleVariableTesting* pBAFunctions = NULL;
85 IBootstrapperEngine* pEngine = NULL;
86
87 hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine);
88 ExitOnFailure(hr, "Failed to initialize Bal.");
89
90 pBAFunctions = new CBafRelatedBundleVariableTesting(hModule, pEngine, pArgs);
91 ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CBafRelatedBundleVariableTesting object.");
92
93 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
94 pResults->pvBAFunctionsProcContext = pBAFunctions;
95 pBAFunctions = NULL;
96
97LExit:
98 ReleaseObject(pBAFunctions);
99 ReleaseObject(pEngine);
100
101 return hr;
102}