diff options
| author | Rob Mensching <rob@firegiant.com> | 2025-03-18 17:12:42 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-03-18 18:01:57 -0700 |
| commit | 32bfb97857041bb4385df3754c3f9eb2f8b23d8e (patch) | |
| tree | f26125a61c3bda97d6f3031c17cb262e404acd0b /src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp | |
| parent | 7133077ecc0ef2ada3746c8a0569b1028b6ff6d1 (diff) | |
| download | wix-32bfb97857041bb4385df3754c3f9eb2f8b23d8e.tar.gz wix-32bfb97857041bb4385df3754c3f9eb2f8b23d8e.tar.bz2 wix-32bfb97857041bb4385df3754c3f9eb2f8b23d8e.zip | |
LocUtil occasionally failed due to XmlInitialization
Split into separate classes to prevent potential parallelism race conditions.
Diffstat (limited to 'src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp')
| -rw-r--r-- | src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp new file mode 100644 index 00000000..a558c0c5 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/LocControlsUtilTests.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 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 | |||
| 5 | using namespace System; | ||
| 6 | using namespace Xunit; | ||
| 7 | using namespace WixInternal::TestSupport; | ||
| 8 | |||
| 9 | namespace DutilTests | ||
| 10 | { | ||
| 11 | public ref class LocControlsUtil | ||
| 12 | { | ||
| 13 | public: | ||
| 14 | [Fact] | ||
| 15 | void CanLoadControlsWxl() | ||
| 16 | { | ||
| 17 | HRESULT hr = S_OK; | ||
| 18 | WIX_LOCALIZATION* pLoc = NULL; | ||
| 19 | LOC_CONTROL* pLocControl = NULL; | ||
| 20 | |||
| 21 | DutilInitialize(&DutilTestTraceError); | ||
| 22 | |||
| 23 | try | ||
| 24 | { | ||
| 25 | hr = XmlInitialize(); | ||
| 26 | NativeAssert::Succeeded(hr, "Failed to initialize Xml."); | ||
| 27 | |||
| 28 | pin_ptr<const wchar_t> wxlFilePath = PtrToStringChars(TestData::Get("TestData", "LocUtilTests", "controls.wxl")); | ||
| 29 | hr = LocLoadFromFile(wxlFilePath, &pLoc); | ||
| 30 | NativeAssert::Succeeded(hr, "Failed to parse controls.wxl: {0}", wxlFilePath); | ||
| 31 | |||
| 32 | Assert::Equal(3ul, pLoc->cLocControls); | ||
| 33 | |||
| 34 | hr = LocGetControl(pLoc, L"Control1", &pLocControl); | ||
| 35 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control1' from: {0}", wxlFilePath); | ||
| 36 | NativeAssert::StringEqual(L"Control1", pLocControl->wzControl); | ||
| 37 | NativeAssert::Equal(1, pLocControl->nX); | ||
| 38 | NativeAssert::Equal(2, pLocControl->nY); | ||
| 39 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
| 40 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
| 41 | NativeAssert::StringEqual(L"This is control #1", pLocControl->wzText); | ||
| 42 | |||
| 43 | hr = LocGetControl(pLoc, L"Control2", &pLocControl); | ||
| 44 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control2' from: {0}", wxlFilePath); | ||
| 45 | NativeAssert::StringEqual(L"Control2", pLocControl->wzControl); | ||
| 46 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
| 47 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
| 48 | NativeAssert::Equal(50, pLocControl->nWidth); | ||
| 49 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nHeight); | ||
| 50 | NativeAssert::StringEqual(L"This is control #2", pLocControl->wzText); | ||
| 51 | |||
| 52 | hr = LocGetControl(pLoc, L"Control3", &pLocControl); | ||
| 53 | NativeAssert::Succeeded(hr, "Failed to get loc control 'Control3' from: {0}", wxlFilePath); | ||
| 54 | NativeAssert::StringEqual(L"Control3", pLocControl->wzControl); | ||
| 55 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nX); | ||
| 56 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nY); | ||
| 57 | NativeAssert::Equal(LOC_CONTROL_NOT_SET, pLocControl->nWidth); | ||
| 58 | NativeAssert::Equal(150, pLocControl->nHeight); | ||
| 59 | NativeAssert::StringEqual(L"", pLocControl->wzText); | ||
| 60 | } | ||
| 61 | finally | ||
| 62 | { | ||
| 63 | if (pLoc) | ||
| 64 | { | ||
| 65 | LocFree(pLoc); | ||
| 66 | } | ||
| 67 | |||
| 68 | DutilUninitialize(); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | }; | ||
| 72 | } | ||
