From 7cca75c8e95f129a21c33f1f4568e90e9e397f9d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 29 Jun 2022 10:28:53 -0500 Subject: Add AppWaitForSingleObject/MultipleObjects, ThreadWaitForCompletion. --- src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp (limited to 'src/libs/dutil/test/DUtilUnitTest/AppUtilTests.cpp') 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 @@ +// 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. + +#include "precomp.h" + +namespace DutilTests +{ + using namespace System; + using namespace Xunit; + using namespace WixBuildTools::TestSupport; + + public ref class AppUtil + { + public: + [Fact] + void WaitForMultipleObjectsTest() + { + HRESULT hr = S_OK; + HANDLE hOne = NULL; + HANDLE hTwo = NULL; + HANDLE rghHandles[2] = { }; + DWORD dwSignaledIndex = 0; + + try + { + hOne = ::CreateEventW(NULL, TRUE, FALSE, NULL); + if (!hOne) + { + hr = HRESULT_FROM_WIN32(::GetLastError()); + NativeAssert::Succeeded(FAILED(hr) ? hr : E_FAIL, "Failed to create event."); + } + + hTwo = ::CreateEventW(NULL, TRUE, TRUE, NULL); + if (!hTwo) + { + hr = HRESULT_FROM_WIN32(::GetLastError()); + NativeAssert::Succeeded(FAILED(hr) ? hr : E_FAIL, "Failed to create event."); + } + + rghHandles[0] = hOne; + rghHandles[1] = hTwo; + + hr = AppWaitForMultipleObjects(countof(rghHandles), rghHandles, FALSE, 0, &dwSignaledIndex); + NativeAssert::Succeeded(hr, "Failed to wait for multiple objects."); + Assert::Equal(1, dwSignaledIndex); + + rghHandles[0] = hTwo; + rghHandles[1] = hOne; + + hr = AppWaitForMultipleObjects(countof(rghHandles), rghHandles, FALSE, 0, &dwSignaledIndex); + NativeAssert::Succeeded(hr, "Failed to wait for multiple objects."); + Assert::Equal(0, dwSignaledIndex); + } + finally + { + ReleaseHandle(hOne); + ReleaseHandle(hTwo); + } + } + }; +} -- cgit v1.2.3-55-g6feb