diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-29 10:28:53 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-29 15:08:37 -0500 |
| commit | 7cca75c8e95f129a21c33f1f4568e90e9e397f9d (patch) | |
| tree | cb9890caa1ac8bc891d444b6376a5e9f997ca1e3 /src/libs/dutil/test | |
| parent | 3ff6428a068bafd74d8ec072a5fc261c33cc2019 (diff) | |
| download | wix-7cca75c8e95f129a21c33f1f4568e90e9e397f9d.tar.gz wix-7cca75c8e95f129a21c33f1f4568e90e9e397f9d.tar.bz2 wix-7cca75c8e95f129a21c33f1f4568e90e9e397f9d.zip | |
Add AppWaitForSingleObject/MultipleObjects, ThreadWaitForCompletion.
Diffstat (limited to '')
4 files changed, 65 insertions, 0 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp b/src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp new file mode 100644 index 00000000..e8c23469 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 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 | namespace DutilTests | ||
| 6 | { | ||
| 7 | using namespace System; | ||
| 8 | using namespace Xunit; | ||
| 9 | using namespace WixBuildTools::TestSupport; | ||
| 10 | |||
| 11 | public ref class AppUtil | ||
| 12 | { | ||
| 13 | public: | ||
| 14 | [Fact] | ||
| 15 | void WaitForMultipleObjectsTest() | ||
| 16 | { | ||
| 17 | HRESULT hr = S_OK; | ||
| 18 | HANDLE hOne = NULL; | ||
| 19 | HANDLE hTwo = NULL; | ||
| 20 | HANDLE rghHandles[2] = { }; | ||
| 21 | DWORD dwSignaledIndex = 0; | ||
| 22 | |||
| 23 | try | ||
| 24 | { | ||
| 25 | hOne = ::CreateEventW(NULL, TRUE, FALSE, NULL); | ||
| 26 | if (!hOne) | ||
| 27 | { | ||
| 28 | hr = HRESULT_FROM_WIN32(::GetLastError()); | ||
| 29 | NativeAssert::Succeeded(FAILED(hr) ? hr : E_FAIL, "Failed to create event."); | ||
| 30 | } | ||
| 31 | |||
| 32 | hTwo = ::CreateEventW(NULL, TRUE, TRUE, NULL); | ||
| 33 | if (!hTwo) | ||
| 34 | { | ||
| 35 | hr = HRESULT_FROM_WIN32(::GetLastError()); | ||
| 36 | NativeAssert::Succeeded(FAILED(hr) ? hr : E_FAIL, "Failed to create event."); | ||
| 37 | } | ||
| 38 | |||
| 39 | rghHandles[0] = hOne; | ||
| 40 | rghHandles[1] = hTwo; | ||
| 41 | |||
| 42 | hr = AppWaitForMultipleObjects(countof(rghHandles), rghHandles, FALSE, 0, &dwSignaledIndex); | ||
| 43 | NativeAssert::Succeeded(hr, "Failed to wait for multiple objects."); | ||
| 44 | Assert::Equal<DWORD>(1, dwSignaledIndex); | ||
| 45 | |||
| 46 | rghHandles[0] = hTwo; | ||
| 47 | rghHandles[1] = hOne; | ||
| 48 | |||
| 49 | hr = AppWaitForMultipleObjects(countof(rghHandles), rghHandles, FALSE, 0, &dwSignaledIndex); | ||
| 50 | NativeAssert::Succeeded(hr, "Failed to wait for multiple objects."); | ||
| 51 | Assert::Equal<DWORD>(0, dwSignaledIndex); | ||
| 52 | } | ||
| 53 | finally | ||
| 54 | { | ||
| 55 | ReleaseHandle(hOne); | ||
| 56 | ReleaseHandle(hTwo); | ||
| 57 | } | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | } | ||
diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj index a1f13239..210f50f5 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | </PropertyGroup> | 44 | </PropertyGroup> |
| 45 | 45 | ||
| 46 | <ItemGroup> | 46 | <ItemGroup> |
| 47 | <ClCompile Include="AppUtilTests.cpp" /> | ||
| 47 | <ClCompile Include="ApupUtilTests.cpp" /> | 48 | <ClCompile Include="ApupUtilTests.cpp" /> |
| 48 | <ClCompile Include="AssemblyInfo.cpp" /> | 49 | <ClCompile Include="AssemblyInfo.cpp" /> |
| 49 | <ClCompile Include="DictUtilTest.cpp" /> | 50 | <ClCompile Include="DictUtilTest.cpp" /> |
diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters index cb0c8a73..f1d9c307 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters | |||
| @@ -15,6 +15,9 @@ | |||
| 15 | </Filter> | 15 | </Filter> |
| 16 | </ItemGroup> | 16 | </ItemGroup> |
| 17 | <ItemGroup> | 17 | <ItemGroup> |
| 18 | <ClCompile Include="AppUtilTests.cpp"> | ||
| 19 | <Filter>Source Files</Filter> | ||
| 20 | </ClCompile> | ||
| 18 | <ClCompile Include="ApupUtilTests.cpp"> | 21 | <ClCompile Include="ApupUtilTests.cpp"> |
| 19 | <Filter>Source Files</Filter> | 22 | <Filter>Source Files</Filter> |
| 20 | </ClCompile> | 23 | </ClCompile> |
diff --git a/src/libs/dutil/test/DUtilUnitTest/precomp.h b/src/libs/dutil/test/DUtilUnitTest/precomp.h index ac57cdd4..a5542774 100644 --- a/src/libs/dutil/test/DUtilUnitTest/precomp.h +++ b/src/libs/dutil/test/DUtilUnitTest/precomp.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <dutil.h> | 13 | #include <dutil.h> |
| 14 | 14 | ||
| 15 | #include <verutil.h> | 15 | #include <verutil.h> |
| 16 | #include <apputil.h> | ||
| 16 | #include <atomutil.h> | 17 | #include <atomutil.h> |
| 17 | #include <dictutil.h> | 18 | #include <dictutil.h> |
| 18 | #include <dirutil.h> | 19 | #include <dirutil.h> |
