diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-07-31 17:06:35 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-08-09 10:33:49 -0600 |
| commit | d21eed76c48960707561c45c492c10a6a23c052e (patch) | |
| tree | ebab09d099a699a24801fcfb4d7152cf82cc4a06 /src/test/BurnUnitTest/SearchTest.cpp | |
| parent | ad80d6dc10f9bd6cb6a084857a8fb546cc55e756 (diff) | |
| download | wix-d21eed76c48960707561c45c492c10a6a23c052e.tar.gz wix-d21eed76c48960707561c45c492c10a6a23c052e.tar.bz2 wix-d21eed76c48960707561c45c492c10a6a23c052e.zip | |
WIXFEAT:4763 Change "string" variable type to literal and add "formatted".
Diffstat (limited to 'src/test/BurnUnitTest/SearchTest.cpp')
| -rw-r--r-- | src/test/BurnUnitTest/SearchTest.cpp | 87 |
1 files changed, 79 insertions, 8 deletions
diff --git a/src/test/BurnUnitTest/SearchTest.cpp b/src/test/BurnUnitTest/SearchTest.cpp index 48ab60aa..32107d87 100644 --- a/src/test/BurnUnitTest/SearchTest.cpp +++ b/src/test/BurnUnitTest/SearchTest.cpp | |||
| @@ -66,8 +66,8 @@ namespace Bootstrapper | |||
| 66 | pin_ptr<const WCHAR> wzDirectory1 = PtrToStringChars(this->TestContext->TestDirectory); | 66 | pin_ptr<const WCHAR> wzDirectory1 = PtrToStringChars(this->TestContext->TestDirectory); |
| 67 | pin_ptr<const WCHAR> wzDirectory2 = PtrToStringChars(System::IO::Path::Combine(this->TestContext->TestDirectory, gcnew String(L"none"))); | 67 | pin_ptr<const WCHAR> wzDirectory2 = PtrToStringChars(System::IO::Path::Combine(this->TestContext->TestDirectory, gcnew String(L"none"))); |
| 68 | 68 | ||
| 69 | VariableSetStringHelper(&variables, L"Directory1", wzDirectory1); | 69 | VariableSetStringHelper(&variables, L"Directory1", wzDirectory1, FALSE); |
| 70 | VariableSetStringHelper(&variables, L"Directory2", wzDirectory2); | 70 | VariableSetStringHelper(&variables, L"Directory2", wzDirectory2, FALSE); |
| 71 | 71 | ||
| 72 | LPCWSTR wzDocument = | 72 | LPCWSTR wzDocument = |
| 73 | L"<Bundle>" | 73 | L"<Bundle>" |
| @@ -117,8 +117,8 @@ namespace Bootstrapper | |||
| 117 | hr = FileVersion(wzFile2, &uliVersion.HighPart, &uliVersion.LowPart); | 117 | hr = FileVersion(wzFile2, &uliVersion.HighPart, &uliVersion.LowPart); |
| 118 | TestThrowOnFailure(hr, L"Failed to get DLL version."); | 118 | TestThrowOnFailure(hr, L"Failed to get DLL version."); |
| 119 | 119 | ||
| 120 | VariableSetStringHelper(&variables, L"File1", wzFile1); | 120 | VariableSetStringHelper(&variables, L"File1", wzFile1, FALSE); |
| 121 | VariableSetStringHelper(&variables, L"File2", wzFile2); | 121 | VariableSetStringHelper(&variables, L"File2", wzFile2, FALSE); |
| 122 | 122 | ||
| 123 | LPCWSTR wzDocument = | 123 | LPCWSTR wzDocument = |
| 124 | L"<Bundle>" | 124 | L"<Bundle>" |
| @@ -191,8 +191,8 @@ namespace Bootstrapper | |||
| 191 | Assert::True(SUCCEEDED(hr)); | 191 | Assert::True(SUCCEEDED(hr)); |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | VariableSetStringHelper(&variables, L"MyKey", L"SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\Value"); | 194 | VariableSetStringHelper(&variables, L"MyKey", L"SOFTWARE\\Microsoft\\WiX_Burn_UnitTest\\Value", FALSE); |
| 195 | VariableSetStringHelper(&variables, L"MyValue", L"String"); | 195 | VariableSetStringHelper(&variables, L"MyValue", L"String", FALSE); |
| 196 | 196 | ||
| 197 | LPCWSTR wzDocument = | 197 | LPCWSTR wzDocument = |
| 198 | L"<Bundle>" | 198 | L"<Bundle>" |
| @@ -219,8 +219,9 @@ namespace Bootstrapper | |||
| 219 | L" <RegistrySearch Id='Search21' Type='value' Root='HKCU' Key='SOFTWARE\\Classes\\CLSID\\WiX_Burn_UnitTest\\Bitness' Value='TestStringSpecificToBitness' Variable='Variable21' VariableType='string' Win64='no' />" | 219 | L" <RegistrySearch Id='Search21' Type='value' Root='HKCU' Key='SOFTWARE\\Classes\\CLSID\\WiX_Burn_UnitTest\\Bitness' Value='TestStringSpecificToBitness' Variable='Variable21' VariableType='string' Win64='no' />" |
| 220 | L" <RegistrySearch Id='Search22' Type='value' Root='HKCU' Key='SOFTWARE\\Classes\\CLSID\\WiX_Burn_UnitTest\\Bitness' Value='TestStringSpecificToBitness' Variable='Variable22' VariableType='string' Win64='yes' />" | 220 | L" <RegistrySearch Id='Search22' Type='value' Root='HKCU' Key='SOFTWARE\\Classes\\CLSID\\WiX_Burn_UnitTest\\Bitness' Value='TestStringSpecificToBitness' Variable='Variable22' VariableType='string' Win64='yes' />" |
| 221 | L" <RegistrySearch Id='Search23' Type='exists' Root='HKU' Key='.DEFAULT\\Environment' Variable='Variable23' />" | 221 | L" <RegistrySearch Id='Search23' Type='exists' Root='HKU' Key='.DEFAULT\\Environment' Variable='Variable23' />" |
| 222 | L" <RegistrySearch Id='Search23' Type='exists' Root='HKU' Key='.DEFAULT\\System\\NetworkServiceSidSubkeyDoesNotExist' Variable='Variable24' />" | 222 | L" <RegistrySearch Id='Search24' Type='exists' Root='HKU' Key='.DEFAULT\\System\\NetworkServiceSidSubkeyDoesNotExist' Variable='Variable24' />" |
| 223 | L" <RegistrySearch Id='Search24' Type='value' Root='HKCR' Key='.msi' Variable='Variable25' VariableType='string' />" | 223 | L" <RegistrySearch Id='Search25' Type='value' Root='HKCR' Key='.msi' Variable='Variable25' VariableType='string' />" |
| 224 | L" <RegistrySearch Id='Search26' Type='value' Root='HKCR' Key='.msi' Variable='Variable26' VariableType='formatted' />" | ||
| 224 | L"</Bundle>"; | 225 | L"</Bundle>"; |
| 225 | 226 | ||
| 226 | // load XML document | 227 | // load XML document |
| @@ -263,6 +264,7 @@ namespace Bootstrapper | |||
| 263 | Assert::Equal(1ll, VariableGetNumericHelper(&variables, L"Variable23")); | 264 | Assert::Equal(1ll, VariableGetNumericHelper(&variables, L"Variable23")); |
| 264 | Assert::Equal(0ll, VariableGetNumericHelper(&variables, L"Variable24")); | 265 | Assert::Equal(0ll, VariableGetNumericHelper(&variables, L"Variable24")); |
| 265 | Assert::Equal<String^>(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable25")); | 266 | Assert::Equal<String^>(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable25")); |
| 267 | Assert::Equal<String^>(gcnew String(L"Msi.Package"), VariableGetStringHelper(&variables, L"Variable26")); | ||
| 266 | } | 268 | } |
| 267 | finally | 269 | finally |
| 268 | { | 270 | { |
| @@ -525,6 +527,75 @@ namespace Bootstrapper | |||
| 525 | SearchesUninitialize(&searches); | 527 | SearchesUninitialize(&searches); |
| 526 | } | 528 | } |
| 527 | } | 529 | } |
| 530 | |||
| 531 | [Fact] | ||
| 532 | void SetVariableSearchTest() | ||
| 533 | { | ||
| 534 | HRESULT hr = S_OK; | ||
| 535 | IXMLDOMElement* pixeBundle = NULL; | ||
| 536 | BURN_VARIABLES variables = { }; | ||
| 537 | BURN_SEARCHES searches = { }; | ||
| 538 | BURN_EXTENSIONS burnExtensions = { }; | ||
| 539 | try | ||
| 540 | { | ||
| 541 | LPCWSTR wzDocument = | ||
| 542 | L"<Bundle>" | ||
| 543 | L" <SetVariable Id='Search1' Type='string' Value='VAL1' Variable='PROP1' />" | ||
| 544 | L" <SetVariable Id='Search2' Type='numeric' Value='2' Variable='PROP2' />" | ||
| 545 | L" <SetVariable Id='Search3' Type='string' Value='VAL3' Variable='PROP3' />" | ||
| 546 | L" <SetVariable Id='Search4' Type='string' Value='VAL4' Variable='PROP4' />" | ||
| 547 | L" <SetVariable Id='Search5' Type='string' Value='VAL5' Variable='PROP5' />" | ||
| 548 | L" <SetVariable Id='Search6' Type='string' Value='VAL6' Variable='PROP6' />" | ||
| 549 | L" <SetVariable Id='Search7' Type='string' Value='7' Variable='PROP7' />" | ||
| 550 | L" <SetVariable Id='Search8' Type='version' Value='1.1.0.0' Variable='PROP8' />" | ||
| 551 | L" <SetVariable Id='Search9' Type='formatted' Value='[VAL9]' Variable='PROP9' />" | ||
| 552 | L" <SetVariable Id='Search10' Type='numeric' Value='42' Variable='OVERWRITTEN_STRING' />" | ||
| 553 | L" <SetVariable Id='Search11' Type='string' Value='NEW' Variable='OVERWRITTEN_NUMBER' />" | ||
| 554 | L" <SetVariable Id='Search12' Variable='REMOVED_NUMBER' />" | ||
| 555 | L"</Bundle>"; | ||
| 556 | |||
| 557 | hr = VariableInitialize(&variables); | ||
| 558 | TestThrowOnFailure(hr, L"Failed to initialize variables."); | ||
| 559 | |||
| 560 | // set variables | ||
| 561 | VariableSetStringHelper(&variables, L"OVERWRITTEN_STRING", L"ORIGINAL", FALSE); | ||
| 562 | VariableSetNumericHelper(&variables, L"OVERWRITTEN_NUMBER", 5); | ||
| 563 | VariableSetNumericHelper(&variables, L"REMOVED_NUMBER", 22); | ||
| 564 | |||
| 565 | // load XML document | ||
| 566 | LoadBundleXmlHelper(wzDocument, &pixeBundle); | ||
| 567 | |||
| 568 | hr = SearchesParseFromXml(&searches, &burnExtensions, pixeBundle); | ||
| 569 | TestThrowOnFailure(hr, L"Failed to parse searches from XML."); | ||
| 570 | |||
| 571 | // execute searches | ||
| 572 | hr = SearchesExecute(&searches, &variables); | ||
| 573 | TestThrowOnFailure(hr, L"Failed to execute searches."); | ||
| 574 | |||
| 575 | // check variable values | ||
| 576 | Assert::Equal<String^>(gcnew String(L"VAL1"), VariableGetStringHelper(&variables, L"PROP1")); | ||
| 577 | Assert::Equal(2ll, VariableGetNumericHelper(&variables, L"PROP2")); | ||
| 578 | Assert::Equal<String^>(gcnew String(L"2"), VariableGetStringHelper(&variables, L"PROP2")); | ||
| 579 | Assert::Equal<String^>(gcnew String(L"VAL3"), VariableGetStringHelper(&variables, L"PROP3")); | ||
| 580 | Assert::Equal<String^>(gcnew String(L"VAL4"), VariableGetStringHelper(&variables, L"PROP4")); | ||
| 581 | Assert::Equal<String^>(gcnew String(L"VAL5"), VariableGetStringHelper(&variables, L"PROP5")); | ||
| 582 | Assert::Equal<String^>(gcnew String(L"VAL6"), VariableGetStringHelper(&variables, L"PROP6")); | ||
| 583 | Assert::Equal(7ll, VariableGetNumericHelper(&variables, L"PROP7")); | ||
| 584 | Assert::Equal(MAKEQWORDVERSION(1, 1, 0, 0), VariableGetVersionHelper(&variables, L"PROP8")); | ||
| 585 | Assert::Equal<String^>(gcnew String(L"1.1.0.0"), VariableGetStringHelper(&variables, L"PROP8")); | ||
| 586 | Assert::Equal<String^>(gcnew String(L"[VAL9]"), VariableGetStringHelper(&variables, L"PROP9")); | ||
| 587 | |||
| 588 | Assert::Equal(42ll, VariableGetNumericHelper(&variables, L"OVERWRITTEN_STRING")); | ||
| 589 | Assert::Equal<String^>(gcnew String(L"NEW"), VariableGetStringHelper(&variables, L"OVERWRITTEN_NUMBER")); | ||
| 590 | Assert::Equal((int)BURN_VARIANT_TYPE_NONE, VariableGetTypeHelper(&variables, L"REMOVED_NUMBER")); | ||
| 591 | } | ||
| 592 | finally | ||
| 593 | { | ||
| 594 | ReleaseObject(pixeBundle); | ||
| 595 | VariablesUninitialize(&variables); | ||
| 596 | SearchesUninitialize(&searches); | ||
| 597 | } | ||
| 598 | } | ||
| 528 | }; | 599 | }; |
| 529 | } | 600 | } |
| 530 | } | 601 | } |
