2019-11-18 03:17:51 +01:00
|
|
|
/*
|
|
|
|
* Speech API (SAPI) text-to-speech tests.
|
|
|
|
*
|
|
|
|
* Copyright 2019 Jactry Zeng for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "sapiddk.h"
|
|
|
|
#include "sperror.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
|
|
|
|
static void _expect_ref(IUnknown *obj, ULONG ref, int line)
|
|
|
|
{
|
|
|
|
ULONG rc;
|
|
|
|
IUnknown_AddRef(obj);
|
|
|
|
rc = IUnknown_Release(obj);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok_(__FILE__,line)(rc == ref, "Unexpected refcount %ld, expected %ld.\n", rc, ref);
|
2019-11-18 03:17:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_interfaces(void)
|
|
|
|
{
|
2019-11-18 03:18:07 +01:00
|
|
|
ISpeechVoice *speech_voice, *speech_voice2;
|
2019-11-18 03:18:21 +01:00
|
|
|
IConnectionPointContainer *container;
|
2019-11-18 03:18:07 +01:00
|
|
|
ISpVoice *spvoice, *spvoice2;
|
2019-11-18 03:17:51 +01:00
|
|
|
IDispatch *dispatch;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ISpeechVoice, (void **)&speech_voice);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "Failed to create ISpeechVoice interface: %#lx.\n", hr);
|
2019-11-18 03:17:51 +01:00
|
|
|
EXPECT_REF(speech_voice, 1);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDispatch, (void **)&dispatch);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "Failed to create IDispatch interface: %#lx.\n", hr);
|
2019-11-18 03:17:51 +01:00
|
|
|
EXPECT_REF(dispatch, 1);
|
|
|
|
EXPECT_REF(speech_voice, 1);
|
|
|
|
IDispatch_Release(dispatch);
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IUnknown, (void **)&unk);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "Failed to create IUnknown interface: %#lx.\n", hr);
|
2019-11-18 03:17:51 +01:00
|
|
|
EXPECT_REF(unk, 1);
|
|
|
|
EXPECT_REF(speech_voice, 1);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
|
2019-11-18 03:18:07 +01:00
|
|
|
hr = CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ISpVoice, (void **)&spvoice);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "Failed to create ISpVoice interface: %#lx.\n", hr);
|
2019-11-18 03:18:07 +01:00
|
|
|
EXPECT_REF(spvoice, 1);
|
|
|
|
EXPECT_REF(speech_voice, 1);
|
|
|
|
|
|
|
|
hr = ISpVoice_QueryInterface(spvoice, &IID_ISpeechVoice, (void **)&speech_voice2);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "ISpVoice_QueryInterface failed: %#lx.\n", hr);
|
2019-11-18 03:18:07 +01:00
|
|
|
EXPECT_REF(speech_voice2, 2);
|
|
|
|
EXPECT_REF(spvoice, 2);
|
|
|
|
EXPECT_REF(speech_voice, 1);
|
|
|
|
ISpeechVoice_Release(speech_voice2);
|
|
|
|
|
|
|
|
hr = ISpeechVoice_QueryInterface(speech_voice, &IID_ISpVoice, (void **)&spvoice2);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "ISpeechVoice_QueryInterface failed: %#lx.\n", hr);
|
2019-11-18 03:18:07 +01:00
|
|
|
EXPECT_REF(speech_voice, 2);
|
|
|
|
EXPECT_REF(spvoice2, 2);
|
|
|
|
EXPECT_REF(spvoice, 1);
|
|
|
|
ISpVoice_Release(spvoice2);
|
|
|
|
ISpVoice_Release(spvoice);
|
|
|
|
|
2019-11-18 03:18:21 +01:00
|
|
|
hr = ISpeechVoice_QueryInterface(speech_voice, &IID_IConnectionPointContainer,
|
|
|
|
(void **)&container);
|
2022-03-04 09:25:28 +01:00
|
|
|
ok(hr == S_OK, "ISpeechVoice_QueryInterface failed: %#lx.\n", hr);
|
2019-11-18 03:18:21 +01:00
|
|
|
EXPECT_REF(speech_voice, 2);
|
|
|
|
EXPECT_REF(container, 2);
|
|
|
|
IConnectionPointContainer_Release(container);
|
|
|
|
|
2019-11-18 03:17:51 +01:00
|
|
|
ISpeechVoice_Release(speech_voice);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(tts)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
test_interfaces();
|
|
|
|
CoUninitialize();
|
|
|
|
}
|