aboutsummaryrefslogtreecommitdiff
path: root/src/api/burn/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/burn/test')
-rw-r--r--src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp18
-rw-r--r--src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp21
-rw-r--r--src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp26
-rw-r--r--src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h4
-rw-r--r--src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp15
-rw-r--r--src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h3
-rw-r--r--src/api/burn/test/BalUtilUnitTest/precomp.h4
-rw-r--r--src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs141
8 files changed, 32 insertions, 200 deletions
diff --git a/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp
index 2ae539ee..ba04c1bb 100644
--- a/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp
+++ b/src/api/burn/test/BalUtilUnitTest/BAFunctionsTests.cpp
@@ -12,32 +12,30 @@ namespace BalUtilTests
12 public ref class BAFunctions 12 public ref class BAFunctions
13 { 13 {
14 public: 14 public:
15 [Fact] 15 [Fact(Skip = "Need a mock implementation of IBootstrapperEngine to test BAFunctions.")]
16 void CanCreateTestBAFunctions() 16 void CanCreateTestBAFunctions()
17 { 17 {
18 HRESULT hr = S_OK; 18 HRESULT hr = S_OK;
19 BOOTSTRAPPER_CREATE_ARGS bootstrapperArgs = { };
20 BOOTSTRAPPER_COMMAND bootstrapperCommand = { };
21 BA_FUNCTIONS_CREATE_ARGS args = { }; 19 BA_FUNCTIONS_CREATE_ARGS args = { };
22 BA_FUNCTIONS_CREATE_RESULTS results = { }; 20 BA_FUNCTIONS_CREATE_RESULTS results = { };
23 IBootstrapperEngine* pEngine = NULL; 21 IBootstrapperEngine* pEngine = NULL;
22 BOOTSTRAPPER_COMMAND command = { };
24 IBAFunctions* pBAFunctions = NULL; 23 IBAFunctions* pBAFunctions = NULL;
25 24
26 bootstrapperArgs.cbSize = sizeof(bootstrapperArgs);
27 bootstrapperArgs.pCommand = &bootstrapperCommand;
28
29 args.cbSize = sizeof(args); 25 args.cbSize = sizeof(args);
30 args.pBootstrapperCreateArgs = &bootstrapperArgs; 26 args.pEngine = pEngine;
27 args.pCommand = &command;
31 28
32 results.cbSize = sizeof(results); 29 results.cbSize = sizeof(results);
33 30
34 try 31 try
35 { 32 {
36 hr = BalInitializeFromCreateArgs(&bootstrapperArgs, &pEngine); 33 BalInitialize(pEngine);
37 NativeAssert::Succeeded(hr, "Failed to create engine.");
38 34
39 hr = CreateBAFunctions(NULL, pEngine, &args, &results, &pBAFunctions); 35 hr = CreateBAFunctions(NULL, &args, &results);
40 NativeAssert::Succeeded(hr, "Failed to create BAFunctions."); 36 NativeAssert::Succeeded(hr, "Failed to create BAFunctions.");
37
38 pBAFunctions = reinterpret_cast<IBAFunctions*>(results.pvBAFunctionsProcContext);
41 } 39 }
42 finally 40 finally
43 { 41 {
diff --git a/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp
index 70b01a42..9a68c738 100644
--- a/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp
+++ b/src/api/burn/test/BalUtilUnitTest/BootstrapperApplicationTests.cpp
@@ -12,28 +12,21 @@ namespace BalUtilTests
12 public ref class BootstrapperApplication 12 public ref class BootstrapperApplication
13 { 13 {
14 public: 14 public:
15 [Fact] 15 [Fact(Skip = "Need a mock implementation of IBootstrapperEngine to test BootstrapperApplication.")]
16 void CanCreateTestBootstrapperApplication() 16 void CanCreateTestBootstrapperApplication()
17 { 17 {
18 HRESULT hr = S_OK; 18 HRESULT hr = S_OK;
19 BOOTSTRAPPER_CREATE_ARGS args = { };
20 BOOTSTRAPPER_COMMAND command = { };
21 BOOTSTRAPPER_CREATE_RESULTS results = { };
22 IBootstrapperEngine* pEngine = NULL;
23 IBootstrapperApplication* pApplication = NULL; 19 IBootstrapperApplication* pApplication = NULL;
24 20 IBootstrapperEngine* pEngine = NULL;
25 args.cbSize = sizeof(args); 21 BOOTSTRAPPER_COMMAND command = { };
26 args.pCommand = &command;
27
28 results.cbSize = sizeof(results);
29 22
30 try 23 try
31 { 24 {
32 hr = BalInitializeFromCreateArgs(&args, &pEngine); 25 hr = CreateBootstrapperApplication(&pApplication);
33 NativeAssert::Succeeded(hr, "Failed to create engine.");
34
35 hr = CreateBootstrapperApplication(pEngine, &args, &results, &pApplication);
36 NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication."); 26 NativeAssert::Succeeded(hr, "Failed to create BootstrapperApplication.");
27
28 hr = pApplication->OnCreate(pEngine, &command);
29 NativeAssert::Succeeded(hr, "Failed to initialize BootstrapperApplication.");
37 } 30 }
38 finally 31 finally
39 { 32 {
diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp
index 927a8d10..3e850442 100644
--- a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp
+++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.cpp
@@ -8,34 +8,32 @@ class CTestBAFunctions : public CBalBaseBAFunctions
8{ 8{
9public: 9public:
10 CTestBAFunctions( 10 CTestBAFunctions(
11 __in HMODULE hModule, 11 __in HMODULE hModule
12 __in IBootstrapperEngine* pEngine, 12 ) : CBalBaseBAFunctions(hModule)
13 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs
14 ) : CBalBaseBAFunctions(hModule, pEngine, pArgs)
15 { 13 {
16 } 14 }
17}; 15};
18 16
19HRESULT CreateBAFunctions( 17HRESULT CreateBAFunctions(
20 __in HMODULE hModule, 18 __in HMODULE hModule,
21 __in IBootstrapperEngine* pEngine,
22 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, 19 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
23 __in BA_FUNCTIONS_CREATE_RESULTS* pResults, 20 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
24 __out IBAFunctions** ppApplication
25 ) 21 )
26{ 22{
27 HRESULT hr = S_OK; 23 HRESULT hr = S_OK;
28 CTestBAFunctions* pApplication = NULL; 24 CTestBAFunctions* pFunction = NULL;
29 25
30 pApplication = new CTestBAFunctions(hModule, pEngine, pArgs); 26 pFunction = new CTestBAFunctions(hModule);
31 ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object."); 27 ExitOnNull(pFunction, hr, E_OUTOFMEMORY, "Failed to create new test bafunctions object.");
28
29 hr = pFunction->OnCreate(pArgs->pEngine, pArgs->pCommand);
30 ExitOnFailure(hr, "Failed to initialize new test bafunctions.");
32 31
33 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; 32 pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc;
34 pResults->pvBAFunctionsProcContext = pApplication; 33 pResults->pvBAFunctionsProcContext = pFunction;
35 *ppApplication = pApplication; 34 pFunction = NULL;
36 pApplication = NULL;
37 35
38LExit: 36LExit:
39 ReleaseObject(pApplication); 37 ReleaseObject(pFunction);
40 return hr; 38 return hr;
41} 39}
diff --git a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h
index 41f36df8..e25e40c3 100644
--- a/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h
+++ b/src/api/burn/test/BalUtilUnitTest/TestBAFunctions.h
@@ -3,8 +3,6 @@
3 3
4HRESULT CreateBAFunctions( 4HRESULT CreateBAFunctions(
5 __in HMODULE hModule, 5 __in HMODULE hModule,
6 __in IBootstrapperEngine* pEngine,
7 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, 6 __in const BA_FUNCTIONS_CREATE_ARGS* pArgs,
8 __in BA_FUNCTIONS_CREATE_RESULTS* pResults, 7 __inout BA_FUNCTIONS_CREATE_RESULTS* pResults
9 __out IBAFunctions** ppApplication
10 ); 8 );
diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp
index daa1d690..b345ab9f 100644
--- a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp
+++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.cpp
@@ -2,36 +2,25 @@
2 2
3#include "precomp.h" 3#include "precomp.h"
4#include "BalBaseBootstrapperApplication.h" 4#include "BalBaseBootstrapperApplication.h"
5#include "BalBaseBootstrapperApplicationProc.h"
6 5
7class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication 6class CTestBootstrapperApplication : public CBalBaseBootstrapperApplication
8{ 7{
9public: 8public:
10 CTestBootstrapperApplication( 9 CTestBootstrapperApplication() : CBalBaseBootstrapperApplication()
11 __in IBootstrapperEngine* pEngine
12 ) : CBalBaseBootstrapperApplication(pEngine)
13 { 10 {
14 } 11 }
15}; 12};
16 13
17HRESULT CreateBootstrapperApplication( 14HRESULT CreateBootstrapperApplication(
18 __in IBootstrapperEngine* pEngine,
19 __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
20 __inout BOOTSTRAPPER_CREATE_RESULTS* pResults,
21 __out IBootstrapperApplication** ppApplication 15 __out IBootstrapperApplication** ppApplication
22 ) 16 )
23{ 17{
24 HRESULT hr = S_OK; 18 HRESULT hr = S_OK;
25 CTestBootstrapperApplication* pApplication = NULL; 19 CTestBootstrapperApplication* pApplication = NULL;
26 20
27 pApplication = new CTestBootstrapperApplication(pEngine); 21 pApplication = new CTestBootstrapperApplication();
28 ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object."); 22 ExitOnNull(pApplication, hr, E_OUTOFMEMORY, "Failed to create new test bootstrapper application object.");
29 23
30 hr = pApplication->Initialize(pArgs);
31 ExitOnFailure(hr, "CTestBootstrapperApplication initialization failed.");
32
33 pResults->pfnBootstrapperApplicationProc = BalBaseBootstrapperApplicationProc;
34 pResults->pvBootstrapperApplicationProcContext = pApplication;
35 *ppApplication = pApplication; 24 *ppApplication = pApplication;
36 pApplication = NULL; 25 pApplication = NULL;
37 26
diff --git a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h
index c173e9ee..313bfede 100644
--- a/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h
+++ b/src/api/burn/test/BalUtilUnitTest/TestBootstrapperApplication.h
@@ -2,8 +2,5 @@
2// 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// 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.
3 3
4HRESULT CreateBootstrapperApplication( 4HRESULT CreateBootstrapperApplication(
5 __in IBootstrapperEngine* pEngine,
6 __in const BOOTSTRAPPER_CREATE_ARGS* pArgs,
7 __inout BOOTSTRAPPER_CREATE_RESULTS* pResults,
8 __out IBootstrapperApplication** ppApplication 5 __out IBootstrapperApplication** ppApplication
9 ); 6 );
diff --git a/src/api/burn/test/BalUtilUnitTest/precomp.h b/src/api/burn/test/BalUtilUnitTest/precomp.h
index 218cab68..57487bc5 100644
--- a/src/api/burn/test/BalUtilUnitTest/precomp.h
+++ b/src/api/burn/test/BalUtilUnitTest/precomp.h
@@ -15,8 +15,8 @@
15#include <dutil.h> 15#include <dutil.h>
16#include <dictutil.h> 16#include <dictutil.h>
17 17
18#include <BootstrapperEngine.h> 18#include <baenginetypes.h>
19#include <BootstrapperApplication.h> 19#include <batypes.h>
20 20
21#include <BAFunctions.h> 21#include <BAFunctions.h>
22#include <IBootstrapperEngine.h> 22#include <IBootstrapperEngine.h>
diff --git a/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs b/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs
deleted file mode 100644
index 7074c166..00000000
--- a/src/api/burn/test/WixToolsetTest.Mba.Core/BaseBootstrapperApplicationFactoryFixture.cs
+++ /dev/null
@@ -1,141 +0,0 @@
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
3namespace WixToolsetTest.Mba.Core
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Runtime.InteropServices;
8 using WixInternal.TestSupport;
9 using WixToolset.Mba.Core;
10 using Xunit;
11
12 public class BaseBootstrapperApplicationFactoryFixture
13 {
14 [Fact]
15 public void CanCreateBA()
16 {
17 var command = new TestCommand
18 {
19 action = LaunchAction.Install,
20 cbSize = Marshal.SizeOf(typeof(TestCommand)),
21 display = Display.Full,
22 wzCommandLine = "this \"is a\" test VariableA=AVariable =EmptyName EmptyValue=",
23 };
24 var pCommand = Marshal.AllocHGlobal(command.cbSize);
25 try
26 {
27 Marshal.StructureToPtr(command, pCommand, false);
28 var createArgs = new BootstrapperCreateArgs(0, IntPtr.Zero, IntPtr.Zero, pCommand);
29 var pArgs = Marshal.AllocHGlobal(createArgs.cbSize);
30 try
31 {
32 Marshal.StructureToPtr(createArgs, pArgs, false);
33 var createResults = new TestCreateResults
34 {
35 cbSize = Marshal.SizeOf<TestCreateResults>(),
36 };
37 var pResults = Marshal.AllocHGlobal(createResults.cbSize);
38 try
39 {
40 var baFactory = new TestBAFactory();
41 baFactory.Create(pArgs, pResults);
42
43 createResults = Marshal.PtrToStructure<TestCreateResults>(pResults);
44 Assert.Equal(baFactory.BA, createResults.pBA);
45 Assert.Equal(baFactory.BA.Command.Action, command.action);
46 Assert.Equal(baFactory.BA.Command.Display, command.display);
47
48 var mbaCommand = baFactory.BA.Command.ParseCommandLine();
49 WixAssert.CompareLineByLine(mbaCommand.UnknownCommandLineArgs, new string[] { "this", "is a", "test" });
50 Assert.Equal(mbaCommand.Variables, new KeyValuePair<string, string>[]
51 {
52 new KeyValuePair<string, string>("VariableA", "AVariable"),
53 new KeyValuePair<string, string>("", "EmptyName"),
54 new KeyValuePair<string, string>("EmptyValue", ""),
55 });
56 }
57 finally
58 {
59 Marshal.FreeHGlobal(pResults);
60 }
61 }
62 finally
63 {
64 Marshal.FreeHGlobal(pArgs);
65 }
66 }
67 finally
68 {
69 Marshal.FreeHGlobal(pCommand);
70 }
71 }
72
73 internal class TestBAFactory : BaseBootstrapperApplicationFactory
74 {
75 public TestBA BA { get; private set; }
76
77 protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand)
78 {
79 this.BA = new TestBA(engine, bootstrapperCommand);
80 return this.BA;
81 }
82 }
83
84 internal class TestBA : BootstrapperApplication
85 {
86 public IBootstrapperCommand Command { get; }
87
88 public TestBA(IEngine engine, IBootstrapperCommand command)
89 : base(engine)
90 {
91 this.Command = command;
92 }
93
94 protected override void Run()
95 {
96 }
97 }
98
99 [StructLayout(LayoutKind.Sequential)]
100 public struct TestCommand
101 {
102 public int cbSize;
103 public LaunchAction action;
104 public Display display;
105 [MarshalAs(UnmanagedType.LPWStr)] public string wzCommandLine;
106 public int nCmdShow;
107 public ResumeType resume;
108 public IntPtr hwndSplashScreen;
109 public RelationType relation;
110 [MarshalAs(UnmanagedType.Bool)] public bool passthrough;
111 [MarshalAs(UnmanagedType.LPWStr)] public string wzLayoutDirectory;
112 }
113
114 [StructLayout(LayoutKind.Sequential)]
115 public struct BootstrapperCreateArgs
116 {
117 [MarshalAs(UnmanagedType.I4)] public readonly int cbSize;
118 [MarshalAs(UnmanagedType.I8)] public readonly long qwEngineAPIVersion;
119 public readonly IntPtr pfnBootstrapperEngineProc;
120 public readonly IntPtr pvBootstrapperEngineProcContext;
121 public readonly IntPtr pCommand;
122
123 public BootstrapperCreateArgs(long version, IntPtr pEngineProc, IntPtr pEngineContext, IntPtr pCommand)
124 {
125 this.cbSize = Marshal.SizeOf(typeof(BootstrapperCreateArgs));
126 this.qwEngineAPIVersion = version;
127 this.pfnBootstrapperEngineProc = pEngineProc;
128 this.pvBootstrapperEngineProcContext = pEngineContext;
129 this.pCommand = pCommand;
130 }
131 }
132
133 [StructLayout(LayoutKind.Sequential)]
134 public struct TestCreateResults
135 {
136 public int cbSize;
137 public IntPtr pBAProc;
138 [MarshalAs(UnmanagedType.Interface)] public IBootstrapperApplication pBA;
139 }
140 }
141}