diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-08-03 15:41:18 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-08-04 10:03:57 -0500 |
| commit | 6d7a275edafb3ae0f3cff94d66503a82dafb71f7 (patch) | |
| tree | fae8f75e2cd1d7b179b0ed93e15625d68ba7c441 /src/burn/test/BurnUnitTest/RegistrationTest.cpp | |
| parent | ed57d171f6fb6bb4e180696cc12caa568599566a (diff) | |
| download | wix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.tar.gz wix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.tar.bz2 wix-6d7a275edafb3ae0f3cff94d66503a82dafb71f7.zip | |
Replace static cache internals with a struct.
Initialize them explicitly to make it clearer when that happens.
Diffstat (limited to 'src/burn/test/BurnUnitTest/RegistrationTest.cpp')
| -rw-r--r-- | src/burn/test/BurnUnitTest/RegistrationTest.cpp | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index b1c911f7..7c0dde5a 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp | |||
| @@ -75,6 +75,8 @@ namespace Bootstrapper | |||
| 75 | BURN_REGISTRATION registration = { }; | 75 | BURN_REGISTRATION registration = { }; |
| 76 | BURN_LOGGING logging = { }; | 76 | BURN_LOGGING logging = { }; |
| 77 | BURN_PACKAGES packages = { }; | 77 | BURN_PACKAGES packages = { }; |
| 78 | BURN_CACHE cache = { }; | ||
| 79 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 78 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); | 80 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); |
| 79 | 81 | ||
| 80 | try | 82 | try |
| @@ -99,13 +101,16 @@ namespace Bootstrapper | |||
| 99 | // load XML document | 101 | // load XML document |
| 100 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 102 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 101 | 103 | ||
| 104 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 105 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 106 | |||
| 102 | hr = VariableInitialize(&variables); | 107 | hr = VariableInitialize(&variables); |
| 103 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 108 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 104 | 109 | ||
| 105 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 110 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 106 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 111 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 107 | 112 | ||
| 108 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 113 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 109 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 114 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 110 | 115 | ||
| 111 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 116 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -115,7 +120,7 @@ namespace Bootstrapper | |||
| 115 | TestThrowOnFailure(hr, L"Failed to get current process path."); | 120 | TestThrowOnFailure(hr, L"Failed to get current process path."); |
| 116 | 121 | ||
| 117 | // write registration | 122 | // write registration |
| 118 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 123 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_CACHE_BUNDLE | BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 119 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 124 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 120 | 125 | ||
| 121 | // verify that registration was created | 126 | // verify that registration was created |
| @@ -126,7 +131,7 @@ namespace Bootstrapper | |||
| 126 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)(Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr))); | 131 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)(Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr))); |
| 127 | 132 | ||
| 128 | // end session | 133 | // end session |
| 129 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 134 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 130 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 135 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 131 | 136 | ||
| 132 | // verify that registration was removed | 137 | // verify that registration was removed |
| @@ -165,6 +170,8 @@ namespace Bootstrapper | |||
| 165 | BURN_REGISTRATION registration = { }; | 170 | BURN_REGISTRATION registration = { }; |
| 166 | BURN_LOGGING logging = { }; | 171 | BURN_LOGGING logging = { }; |
| 167 | BURN_PACKAGES packages = { }; | 172 | BURN_PACKAGES packages = { }; |
| 173 | BURN_CACHE cache = { }; | ||
| 174 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 168 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); | 175 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); |
| 169 | try | 176 | try |
| 170 | { | 177 | { |
| @@ -188,13 +195,16 @@ namespace Bootstrapper | |||
| 188 | // load XML document | 195 | // load XML document |
| 189 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 196 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 190 | 197 | ||
| 198 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 199 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 200 | |||
| 191 | hr = VariableInitialize(&variables); | 201 | hr = VariableInitialize(&variables); |
| 192 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 202 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 193 | 203 | ||
| 194 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 204 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 195 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 205 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 196 | 206 | ||
| 197 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 207 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 198 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 208 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 199 | 209 | ||
| 200 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 210 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -208,7 +218,7 @@ namespace Bootstrapper | |||
| 208 | // | 218 | // |
| 209 | 219 | ||
| 210 | // write registration | 220 | // write registration |
| 211 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 221 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 212 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 222 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 213 | 223 | ||
| 214 | // verify that registration was created | 224 | // verify that registration was created |
| @@ -217,7 +227,7 @@ namespace Bootstrapper | |||
| 217 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 227 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 218 | 228 | ||
| 219 | // complete registration | 229 | // complete registration |
| 220 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 230 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 221 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 231 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 222 | 232 | ||
| 223 | // verify that registration was updated | 233 | // verify that registration was updated |
| @@ -230,7 +240,7 @@ namespace Bootstrapper | |||
| 230 | // | 240 | // |
| 231 | 241 | ||
| 232 | // write registration | 242 | // write registration |
| 233 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 243 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 234 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 244 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 235 | 245 | ||
| 236 | // verify that registration was updated | 246 | // verify that registration was updated |
| @@ -239,7 +249,7 @@ namespace Bootstrapper | |||
| 239 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 249 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 240 | 250 | ||
| 241 | // delete registration | 251 | // delete registration |
| 242 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 252 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 243 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 253 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 244 | 254 | ||
| 245 | // verify that registration was removed | 255 | // verify that registration was removed |
| @@ -277,6 +287,8 @@ namespace Bootstrapper | |||
| 277 | BURN_REGISTRATION registration = { }; | 287 | BURN_REGISTRATION registration = { }; |
| 278 | BURN_LOGGING logging = { }; | 288 | BURN_LOGGING logging = { }; |
| 279 | BURN_PACKAGES packages = { }; | 289 | BURN_PACKAGES packages = { }; |
| 290 | BURN_CACHE cache = { }; | ||
| 291 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 280 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); | 292 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); |
| 281 | try | 293 | try |
| 282 | { | 294 | { |
| @@ -300,13 +312,16 @@ namespace Bootstrapper | |||
| 300 | // load XML document | 312 | // load XML document |
| 301 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 313 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 302 | 314 | ||
| 315 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 316 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 317 | |||
| 303 | hr = VariableInitialize(&variables); | 318 | hr = VariableInitialize(&variables); |
| 304 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 319 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 305 | 320 | ||
| 306 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 321 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 307 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 322 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 308 | 323 | ||
| 309 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 324 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 310 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 325 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 311 | 326 | ||
| 312 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 327 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -320,7 +335,7 @@ namespace Bootstrapper | |||
| 320 | // | 335 | // |
| 321 | 336 | ||
| 322 | // write registration | 337 | // write registration |
| 323 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 338 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 324 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 339 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 325 | 340 | ||
| 326 | // verify that registration was created | 341 | // verify that registration was created |
| @@ -328,7 +343,7 @@ namespace Bootstrapper | |||
| 328 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 343 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 329 | 344 | ||
| 330 | // complete registration | 345 | // complete registration |
| 331 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); | 346 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_REQUIRED, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); |
| 332 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 347 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 333 | 348 | ||
| 334 | // verify that registration variables were updated | 349 | // verify that registration variables were updated |
| @@ -349,7 +364,7 @@ namespace Bootstrapper | |||
| 349 | // | 364 | // |
| 350 | 365 | ||
| 351 | // delete registration | 366 | // delete registration |
| 352 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 367 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 353 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 368 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 354 | 369 | ||
| 355 | // verify that registration was removed | 370 | // verify that registration was removed |
| @@ -387,6 +402,8 @@ namespace Bootstrapper | |||
| 387 | BURN_REGISTRATION registration = { }; | 402 | BURN_REGISTRATION registration = { }; |
| 388 | BURN_LOGGING logging = { }; | 403 | BURN_LOGGING logging = { }; |
| 389 | BURN_PACKAGES packages = { }; | 404 | BURN_PACKAGES packages = { }; |
| 405 | BURN_CACHE cache = { }; | ||
| 406 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 390 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); | 407 | String^ cacheDirectory = Path::Combine(Path::Combine(Environment::GetFolderPath(Environment::SpecialFolder::LocalApplicationData), gcnew String(L"Package Cache")), gcnew String(TEST_BUNDLE_ID)); |
| 391 | try | 408 | try |
| 392 | { | 409 | { |
| @@ -412,13 +429,16 @@ namespace Bootstrapper | |||
| 412 | // load XML document | 429 | // load XML document |
| 413 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 430 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 414 | 431 | ||
| 432 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 433 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 434 | |||
| 415 | hr = VariableInitialize(&variables); | 435 | hr = VariableInitialize(&variables); |
| 416 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 436 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 417 | 437 | ||
| 418 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 438 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 419 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 439 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 420 | 440 | ||
| 421 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 441 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 422 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 442 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 423 | 443 | ||
| 424 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 444 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -432,7 +452,7 @@ namespace Bootstrapper | |||
| 432 | // | 452 | // |
| 433 | 453 | ||
| 434 | // write registration | 454 | // write registration |
| 435 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 455 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 436 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 456 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 437 | 457 | ||
| 438 | // verify that registration was created | 458 | // verify that registration was created |
| @@ -440,7 +460,7 @@ namespace Bootstrapper | |||
| 440 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 460 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 441 | 461 | ||
| 442 | // finish registration | 462 | // finish registration |
| 443 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); | 463 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_ARP, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_FULL); |
| 444 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 464 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 445 | 465 | ||
| 446 | // verify that registration was updated | 466 | // verify that registration was updated |
| @@ -465,7 +485,7 @@ namespace Bootstrapper | |||
| 465 | // | 485 | // |
| 466 | 486 | ||
| 467 | // write registration | 487 | // write registration |
| 468 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 488 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 469 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 489 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 470 | 490 | ||
| 471 | // verify that registration was updated | 491 | // verify that registration was updated |
| @@ -473,7 +493,7 @@ namespace Bootstrapper | |||
| 473 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 493 | Assert::Equal<String^>(String::Concat(L"\"", Path::Combine(cacheDirectory, gcnew String(L"setup.exe")), L"\" /burn.runonce"), (String^)Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 474 | 494 | ||
| 475 | // delete registration | 495 | // delete registration |
| 476 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 496 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 477 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 497 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 478 | 498 | ||
| 479 | // verify that registration was removed | 499 | // verify that registration was removed |
| @@ -514,6 +534,8 @@ namespace Bootstrapper | |||
| 514 | BURN_REGISTRATION registration = { }; | 534 | BURN_REGISTRATION registration = { }; |
| 515 | BURN_LOGGING logging = { }; | 535 | BURN_LOGGING logging = { }; |
| 516 | BURN_PACKAGES packages = { }; | 536 | BURN_PACKAGES packages = { }; |
| 537 | BURN_CACHE cache = { }; | ||
| 538 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 517 | BYTE* pbBuffer = NULL; | 539 | BYTE* pbBuffer = NULL; |
| 518 | SIZE_T cbBuffer = 0; | 540 | SIZE_T cbBuffer = 0; |
| 519 | 541 | ||
| @@ -546,6 +568,9 @@ namespace Bootstrapper | |||
| 546 | // load XML document | 568 | // load XML document |
| 547 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 569 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 548 | 570 | ||
| 571 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 572 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 573 | |||
| 549 | hr = VariableInitialize(&variables); | 574 | hr = VariableInitialize(&variables); |
| 550 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 575 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 551 | 576 | ||
| @@ -555,7 +580,7 @@ namespace Bootstrapper | |||
| 555 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 580 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 556 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 581 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 557 | 582 | ||
| 558 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 583 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 559 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 584 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 560 | 585 | ||
| 561 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 586 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -565,7 +590,7 @@ namespace Bootstrapper | |||
| 565 | TestThrowOnFailure(hr, L"Failed to get current process path."); | 590 | TestThrowOnFailure(hr, L"Failed to get current process path."); |
| 566 | 591 | ||
| 567 | // begin session | 592 | // begin session |
| 568 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 593 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 569 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 594 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 570 | 595 | ||
| 571 | VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); | 596 | VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); |
| @@ -608,7 +633,7 @@ namespace Bootstrapper | |||
| 608 | NativeAssert::StringEqual(L"42", sczValue); | 633 | NativeAssert::StringEqual(L"42", sczValue); |
| 609 | 634 | ||
| 610 | // end session | 635 | // end session |
| 611 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 636 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 612 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 637 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 613 | } | 638 | } |
| 614 | finally | 639 | finally |
| @@ -643,6 +668,8 @@ namespace Bootstrapper | |||
| 643 | BURN_REGISTRATION registration = { }; | 668 | BURN_REGISTRATION registration = { }; |
| 644 | BURN_LOGGING logging = { }; | 669 | BURN_LOGGING logging = { }; |
| 645 | BURN_PACKAGES packages = { }; | 670 | BURN_PACKAGES packages = { }; |
| 671 | BURN_CACHE cache = { }; | ||
| 672 | BURN_ENGINE_COMMAND internalCommand = { }; | ||
| 646 | BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE; | 673 | BOOTSTRAPPER_RESUME_TYPE resumeType = BOOTSTRAPPER_RESUME_TYPE_NONE; |
| 647 | BYTE* pbBuffer = NULL; | 674 | BYTE* pbBuffer = NULL; |
| 648 | SIZE_T cbBuffer = 0; | 675 | SIZE_T cbBuffer = 0; |
| @@ -674,6 +701,9 @@ namespace Bootstrapper | |||
| 674 | // load XML document | 701 | // load XML document |
| 675 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | 702 | LoadBundleXmlHelper(wzDocument, &pixeBundle); |
| 676 | 703 | ||
| 704 | hr = CacheInitialize(&cache, &internalCommand); | ||
| 705 | TestThrowOnFailure(hr, L"Failed initialize cache."); | ||
| 706 | |||
| 677 | hr = VariableInitialize(&variables); | 707 | hr = VariableInitialize(&variables); |
| 678 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | 708 | TestThrowOnFailure(hr, L"Failed to initialize variables."); |
| 679 | 709 | ||
| @@ -683,7 +713,7 @@ namespace Bootstrapper | |||
| 683 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); | 713 | hr = UserExperienceParseFromXml(&userExperience, pixeBundle); |
| 684 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); | 714 | TestThrowOnFailure(hr, L"Failed to parse UX from XML."); |
| 685 | 715 | ||
| 686 | hr = RegistrationParseFromXml(®istration, pixeBundle); | 716 | hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); |
| 687 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); | 717 | TestThrowOnFailure(hr, L"Failed to parse registration from XML."); |
| 688 | 718 | ||
| 689 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); | 719 | hr = PlanSetResumeCommand(®istration, BOOTSTRAPPER_ACTION_INSTALL, &command, &logging); |
| @@ -699,7 +729,7 @@ namespace Bootstrapper | |||
| 699 | Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_NONE, (int)resumeType); | 729 | Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_NONE, (int)resumeType); |
| 700 | 730 | ||
| 701 | // begin session | 731 | // begin session |
| 702 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 732 | hr = RegistrationSessionBegin(sczCurrentProcess, ®istration, &cache, &variables, BURN_REGISTRATION_ACTION_OPERATIONS_WRITE_REGISTRATION, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, 0, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 703 | TestThrowOnFailure(hr, L"Failed to register bundle."); | 733 | TestThrowOnFailure(hr, L"Failed to register bundle."); |
| 704 | 734 | ||
| 705 | VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); | 735 | VariableSetNumericHelper(&variables, L"MyBurnVariable1", 42); |
| @@ -738,7 +768,7 @@ namespace Bootstrapper | |||
| 738 | Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType); | 768 | Assert::Equal((int)BOOTSTRAPPER_RESUME_TYPE_INTERRUPTED, (int)resumeType); |
| 739 | 769 | ||
| 740 | // suspend session | 770 | // suspend session |
| 741 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); | 771 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_SUSPEND, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_REGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_INPROGRESS); |
| 742 | TestThrowOnFailure(hr, L"Failed to suspend session."); | 772 | TestThrowOnFailure(hr, L"Failed to suspend session."); |
| 743 | 773 | ||
| 744 | // verify that run key was removed | 774 | // verify that run key was removed |
| @@ -765,7 +795,7 @@ namespace Bootstrapper | |||
| 765 | Assert::NotEqual((Object^)nullptr, Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); | 795 | Assert::NotEqual((Object^)nullptr, Registry::GetValue(gcnew String(TEST_RUN_KEY), gcnew String(TEST_BUNDLE_ID), nullptr)); |
| 766 | 796 | ||
| 767 | // end session | 797 | // end session |
| 768 | hr = RegistrationSessionEnd(®istration, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); | 798 | hr = RegistrationSessionEnd(®istration, &cache, &variables, &packages, BURN_RESUME_MODE_NONE, BOOTSTRAPPER_APPLY_RESTART_NONE, BURN_DEPENDENCY_REGISTRATION_ACTION_UNREGISTER, BOOTSTRAPPER_REGISTRATION_TYPE_NONE); |
| 769 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); | 799 | TestThrowOnFailure(hr, L"Failed to unregister bundle."); |
| 770 | 800 | ||
| 771 | // read resume type after session | 801 | // read resume type after session |
