[PATCH v2 8/9] windows.media.speech/tests: Make use of a helper function for IAsyncInfo checking.
Bernhard Kölbl
wine at gitlab.winehq.org
Thu May 12 15:28:11 CDT 2022
From: Bernhard Kölbl <besentv at gmail.com>
Signed-off-by: Bernhard Kölbl <besentv at gmail.com>
---
dlls/windows.media.speech/tests/speech.c | 81 ++++++++++++------------
1 file changed, 42 insertions(+), 39 deletions(-)
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c
index b458c33eb11..3c5744d6aa6 100644
--- a/dlls/windows.media.speech/tests/speech.c
+++ b/dlls/windows.media.speech/tests/speech.c
@@ -336,6 +336,39 @@ static void await_async_inspectable_( unsigned int line, IAsyncOperation_IInspec
CloseHandle(handler->event_finished);
}
+#define check_async_info(obj, exp_id, exp_status, exp_hr) check_asnyc_info_(__LINE__, obj, exp_id, exp_status, exp_hr)
+static void check_asnyc_info_( unsigned int line, IInspectable *async_obj, UINT32 expect_id, AsyncStatus expect_status, HRESULT expect_hr)
+{
+ IAsyncInfo *async_info;
+ AsyncStatus async_status;
+ UINT32 async_id;
+ HRESULT hr, async_hr;
+
+ hr = IInspectable_QueryInterface(async_obj, &IID_IAsyncInfo, (void **)&async_info);
+ ok_(__FILE__, line)(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+
+ async_id = 0xdeadbeef;
+ hr = IAsyncInfo_get_Id(async_info, &async_id);
+ if (expect_status < 4) todo_wine ok_(__FILE__, line)(hr == S_OK, "IAsyncInfo_get_Id returned %#lx\n", hr);
+ else todo_wine ok_(__FILE__, line)(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_Id returned %#lx\n", hr);
+ todo_wine ok_(__FILE__, line)(async_id == expect_id, "got async_id %#x\n", async_id);
+
+ async_status = 0xdeadbeef;
+ hr = IAsyncInfo_get_Status(async_info, &async_status);
+ if (expect_status < 4) ok_(__FILE__, line)(hr == S_OK, "IAsyncInfo_get_Status returned %#lx\n", hr);
+ else ok_(__FILE__, line)(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_Status returned %#lx\n", hr);
+ ok_(__FILE__, line)(async_status == expect_status, "got async_status %#x\n", async_status);
+
+ async_hr = 0xdeadbeef;
+ hr = IAsyncInfo_get_ErrorCode(async_info, &async_hr);
+ if (expect_status < 4) ok_(__FILE__, line)(hr == S_OK, "IAsyncInfo_get_ErrorCode returned %#lx\n", hr);
+ else ok_(__FILE__, line)(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_ErrorCode returned %#lx\n", hr);
+ if (expect_status < 4) todo_wine_if(FAILED(expect_hr)) ok_(__FILE__, line)(async_hr == expect_hr, "got async_hr %#lx\n", async_hr);
+ else ok_(__FILE__, line)(async_hr == E_ILLEGAL_METHOD_CALL, "got async_hr %#lx\n", async_hr);
+
+ IAsyncInfo_Release(async_info);
+}
+
struct iterator_hstring
{
IIterator_HSTRING IIterator_HSTRING_iface;
@@ -877,9 +910,8 @@ static void test_SpeechRecognizer(void)
AsyncStatus async_status;
HSTRING hstr, hstr_lang;
HANDLE put_thread;
- HRESULT hr, error_code;
- UINT32 id;
LONG ref, old_ref;
+ HRESULT hr;
hr = RoInitialize(RO_INIT_MULTITHREADED);
ok(hr == S_OK, "RoInitialize failed, hr %#lx.\n", hr);
@@ -1009,6 +1041,7 @@ static void test_SpeechRecognizer(void)
await_async_inspectable((IAsyncOperation_IInspectable *)operation,
&compilation_handler,
&IID_IAsyncOperationCompletedHandler_SpeechRecognitionCompilationResult);
+ check_async_info((IInspectable *)operation, 1, Completed, S_OK);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(operation, NULL);
ok(hr == E_ILLEGAL_DELEGATE_ASSIGNMENT, "Got unexpected hr %#lx.\n", hr);
@@ -1035,43 +1068,17 @@ static void test_SpeechRecognizer(void)
hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, &IID_IAsyncInfo, (void **)&info);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
- id = 0xdeadbeef;
- hr = IAsyncInfo_get_Id(info, &id);
- todo_wine ok(hr == S_OK, "IAsyncInfo_get_Id failed, hr %#lx.\n", hr);
- todo_wine ok(id != 0xdeadbeef, "Id was %#x.\n", id);
-
- async_status = 0xdeadbeef;
- hr = IAsyncInfo_get_Status(info, &async_status);
- ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
- ok(async_status == Completed, "Status was %#x.\n", async_status);
-
- error_code = 0xdeadbeef;
- hr = IAsyncInfo_get_ErrorCode(info, &error_code);
- ok(hr == S_OK, "IAsyncInfo_get_ErrorCode failed, hr %#lx.\n", hr);
- ok(error_code == S_OK, "ErrorCode was %#lx.\n", error_code);
-
hr = IAsyncInfo_Cancel(info);
ok(hr == S_OK, "IAsyncInfo_Cancel failed, hr %#lx.\n", hr);
-
- async_status = 0xdeadbeef;
- hr = IAsyncInfo_get_Status(info, &async_status);
- ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
- ok(async_status == Completed, "Status was %#x.\n", async_status);
+ check_async_info((IInspectable *)operation, 1, Completed, S_OK);
hr = IAsyncInfo_Close(info);
ok(hr == S_OK, "IAsyncInfo_Close failed, hr %#lx.\n", hr);
+ check_async_info((IInspectable *)operation, 1, AsyncStatus_Closed, S_OK);
+
hr = IAsyncInfo_Close(info);
ok(hr == S_OK, "IAsyncInfo_Close failed, hr %#lx.\n", hr);
-
- async_status = 0xdeadbeef;
- hr = IAsyncInfo_get_Status(info, &async_status);
- ok(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
- ok(async_status == AsyncStatus_Closed, "Status was %#x.\n", async_status);
-
- error_code = 0xdeadbeef;
- hr = IAsyncInfo_get_ErrorCode(info, &error_code);
- ok(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_ErrorCode failed, hr %#lx.\n", hr);
- ok(error_code == E_ILLEGAL_METHOD_CALL, "ErrorCode was %#lx.\n", error_code);
+ check_async_info((IInspectable *)operation, 1, AsyncStatus_Closed, S_OK);
ref = IAsyncInfo_Release(info);
ok(ref == 1, "Got unexpected ref %lu.\n", ref);
@@ -1097,18 +1104,13 @@ static void test_SpeechRecognizer(void)
hr = IAsyncInfo_get_Status(info, &async_status);
ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
ok(async_status != AsyncStatus_Closed, "Status was %#x.\n", async_status);
+ IAsyncInfo_Release(info);
await_async_inspectable((IAsyncOperation_IInspectable *)operation,
&compilation_handler,
&IID_IAsyncOperationCompletedHandler_SpeechRecognitionCompilationResult);
+ check_async_info((IInspectable *)operation, 2, Completed, S_OK);
- async_status = 0xdeadbeef;
- hr = IAsyncInfo_get_Status(info, &async_status);
- ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
- ok(async_status == Completed, "Status was %#x.\n", async_status);
-
- ref = IAsyncInfo_Release(info);
- ok(ref >= 1, "Got unexpected ref %lu.\n", ref);
ref = IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation);
ok(ref >= 0, "Got unexpected ref %lu.\n", ref);
@@ -1163,6 +1165,7 @@ static void test_SpeechRecognizer(void)
SetEvent(compilation_handler.event_block);
ok(!WaitForSingleObject(compilation_handler.event_unblock, 1000), "Wait for event_unblock failed.\n");
+ check_async_info((IInspectable *)operation, 1, AsyncStatus_Closed, S_OK);
CloseHandle(put_thread);
CloseHandle(compilation_handler.event_block);
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/34
More information about the wine-devel
mailing list