2010-08-03 11:58:01 +02:00
|
|
|
/*
|
2010-08-16 09:59:45 +02:00
|
|
|
* IGameExplorer and IGameExplorer2 tests
|
2010-08-03 11:58:01 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Mariusz Pluciński
|
|
|
|
*
|
|
|
|
* 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 "windows.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "objsafe.h"
|
|
|
|
#include "objbase.h"
|
2010-08-23 12:47:02 +02:00
|
|
|
#include "shlwapi.h"
|
2010-08-23 13:13:38 +02:00
|
|
|
#include "sddl.h"
|
2010-08-23 12:47:02 +02:00
|
|
|
#include "shobjidl.h"
|
|
|
|
|
|
|
|
#include "initguid.h"
|
2010-08-03 11:58:01 +02:00
|
|
|
#include "gameux.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2010-09-15 00:57:02 +02:00
|
|
|
static void test_create(BOOL* gameExplorerAvailable, BOOL* gameExplorer2Available)
|
2010-08-03 11:58:01 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
IGameExplorer* ge = NULL;
|
2010-08-16 09:59:45 +02:00
|
|
|
IGameExplorer2* ge2 = NULL;
|
2010-08-03 11:58:01 +02:00
|
|
|
|
|
|
|
/* interface available up from Vista */
|
|
|
|
hr = CoCreateInstance( &CLSID_GameExplorer, NULL, CLSCTX_INPROC_SERVER, &IID_IGameExplorer, (LPVOID*)&ge);
|
|
|
|
if(ge)
|
|
|
|
{
|
|
|
|
ok(hr == S_OK, "IGameExplorer creating failed (result false)\n");
|
2010-08-23 12:47:02 +02:00
|
|
|
*gameExplorerAvailable = TRUE;
|
2010-08-03 11:58:01 +02:00
|
|
|
IGameExplorer_Release(ge);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IGameExplorer cannot be created\n");
|
2010-08-16 09:59:45 +02:00
|
|
|
|
|
|
|
/* interface available up from Win7 */
|
|
|
|
hr = CoCreateInstance( &CLSID_GameExplorer, NULL, CLSCTX_INPROC_SERVER, &IID_IGameExplorer2, (LPVOID*)&ge2);
|
|
|
|
if(ge2)
|
|
|
|
{
|
|
|
|
ok( hr == S_OK, "IGameExplorer2 creating failed (result false)\n");
|
2010-09-15 00:57:02 +02:00
|
|
|
*gameExplorer2Available = TRUE;
|
2010-08-16 09:59:45 +02:00
|
|
|
IGameExplorer2_Release(ge2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
win_skip("IGameExplorer2 cannot be created\n");
|
2010-08-03 11:58:01 +02:00
|
|
|
}
|
|
|
|
|
2010-08-23 12:47:02 +02:00
|
|
|
static void test_add_remove_game(void)
|
|
|
|
{
|
|
|
|
static const GUID defaultGUID = {0x01234567, 0x89AB, 0xCDEF,
|
|
|
|
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}};
|
|
|
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
IGameExplorer* ge = NULL;
|
|
|
|
WCHAR sExeName[MAX_PATH];
|
|
|
|
WCHAR sExePath[MAX_PATH];
|
|
|
|
BSTR bstrExeName = NULL, bstrExePath = NULL;
|
|
|
|
DWORD dwExeNameLen;
|
|
|
|
GUID guid;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_GameExplorer, NULL, CLSCTX_INPROC_SERVER, &IID_IGameExplorer, (LPVOID*) & ge);
|
|
|
|
ok(ge != NULL, "cannot create coclass IGameExplorer\n");
|
|
|
|
ok(hr == S_OK, "cannot create coclass IGameExplorer\n");
|
|
|
|
|
|
|
|
if(ge)
|
|
|
|
{
|
|
|
|
/* prepare path to binary */
|
2018-05-30 01:15:30 +02:00
|
|
|
dwExeNameLen = GetModuleFileNameW(NULL, sExeName, ARRAY_SIZE(sExeName));
|
2010-08-23 12:47:02 +02:00
|
|
|
ok(dwExeNameLen != 0, "GetModuleFileNameW returned invalid value\n");
|
|
|
|
lstrcpynW(sExePath, sExeName, StrRChrW(sExeName, NULL, '\\') - sExeName + 1);
|
|
|
|
bstrExeName = SysAllocString(sExeName);
|
|
|
|
ok(bstrExeName != NULL, "cannot allocate string for exe name\n");
|
|
|
|
bstrExePath = SysAllocString(sExePath);
|
|
|
|
ok(bstrExePath != NULL, "cannot allocate string for exe path\n");
|
|
|
|
|
|
|
|
if(bstrExeName && bstrExePath)
|
|
|
|
{
|
|
|
|
trace("prepared EXE name: %s\n", wine_dbgstr_w(bstrExeName));
|
|
|
|
trace("prepared EXE path: %s\n", wine_dbgstr_w(bstrExePath));
|
|
|
|
|
|
|
|
|
|
|
|
/* try to register game with provided guid */
|
|
|
|
memcpy(&guid, &defaultGUID, sizeof (guid));
|
|
|
|
|
|
|
|
hr = IGameExplorer_AddGame(ge, bstrExeName, bstrExePath, GIS_CURRENT_USER, &guid);
|
2010-09-07 15:34:41 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer::AddGame failed (error 0x%08x)\n", hr);
|
2010-08-23 12:47:02 +02:00
|
|
|
ok(memcmp(&guid, &defaultGUID, sizeof (guid)) == 0, "AddGame unexpectedly modified GUID\n");
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IGameExplorer_RemoveGame(ge, guid);
|
2010-09-07 16:08:39 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer::RemoveGame failed (error 0x%08x)\n", hr);
|
2010-08-23 12:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* try to register game with empty guid */
|
|
|
|
memcpy(&guid, &GUID_NULL, sizeof (guid));
|
|
|
|
|
|
|
|
hr = IGameExplorer_AddGame(ge, bstrExeName, bstrExePath, GIS_CURRENT_USER, &guid);
|
2010-09-07 15:34:41 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer::AddGame failed (error 0x%08x)\n", hr);
|
2010-08-23 12:47:02 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IGameExplorer_RemoveGame(ge, guid);
|
2010-09-07 16:08:39 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer::RemoveGame failed (error 0x%08x)\n", hr);
|
2010-08-23 12:47:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free allocated resources */
|
|
|
|
SysFreeString(bstrExePath);
|
|
|
|
SysFreeString(bstrExeName);
|
|
|
|
|
|
|
|
IGameExplorer_Release(ge);
|
|
|
|
}
|
|
|
|
}
|
2010-09-28 20:12:49 +02:00
|
|
|
|
|
|
|
static void test_install_uninstall_game(void)
|
2010-09-15 00:57:02 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
IGameExplorer2* ge2 = NULL;
|
|
|
|
WCHAR sExeName[MAX_PATH];
|
|
|
|
WCHAR sExePath[MAX_PATH];
|
|
|
|
DWORD dwExeNameLen;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_GameExplorer, NULL, CLSCTX_INPROC_SERVER, &IID_IGameExplorer2, (LPVOID*)&ge2);
|
|
|
|
ok(ge2 != NULL, "cannot create coclass IGameExplorer2\n");
|
|
|
|
ok(hr == S_OK, "cannot create coclass IGameExplorer2\n");
|
|
|
|
|
|
|
|
if(ge2)
|
|
|
|
{
|
|
|
|
/* prepare path to binary */
|
2018-05-30 01:15:30 +02:00
|
|
|
dwExeNameLen = GetModuleFileNameW(NULL, sExeName, ARRAY_SIZE(sExeName));
|
2010-09-15 00:57:02 +02:00
|
|
|
ok(dwExeNameLen != 0, "GetModuleFileNameW returned invalid value\n");
|
|
|
|
lstrcpynW(sExePath, sExeName, StrRChrW(sExeName, NULL, '\\') - sExeName + 1);
|
|
|
|
|
|
|
|
trace("prepared EXE name: %s\n", wine_dbgstr_w(sExeName));
|
|
|
|
trace("prepared EXE path: %s\n", wine_dbgstr_w(sExePath));
|
|
|
|
|
|
|
|
|
|
|
|
hr = IGameExplorer2_InstallGame(ge2, sExeName, sExePath, GIS_CURRENT_USER);
|
2010-09-16 13:55:19 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer2::InstallGame failed (error 0x%08x)\n", hr);
|
2010-09-15 00:57:02 +02:00
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IGameExplorer2_UninstallGame(ge2, sExeName);
|
2010-09-16 13:55:34 +02:00
|
|
|
ok(SUCCEEDED(hr), "IGameExplorer2::UninstallGame failed (error 0x%08x)\n", hr);
|
2010-09-15 00:57:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IGameExplorer2_Release(ge2);
|
|
|
|
}
|
|
|
|
}
|
2010-08-23 12:47:02 +02:00
|
|
|
|
2011-10-11 17:24:52 +02:00
|
|
|
static void run_tests(void)
|
2010-08-03 11:58:01 +02:00
|
|
|
{
|
2010-08-23 12:47:02 +02:00
|
|
|
BOOL gameExplorerAvailable = FALSE;
|
2010-09-15 00:57:02 +02:00
|
|
|
BOOL gameExplorer2Available = FALSE;
|
2010-08-03 11:58:01 +02:00
|
|
|
|
2011-10-11 17:24:52 +02:00
|
|
|
test_create(&gameExplorerAvailable, &gameExplorer2Available);
|
|
|
|
|
|
|
|
if(gameExplorerAvailable)
|
|
|
|
test_add_remove_game();
|
|
|
|
|
|
|
|
if(gameExplorer2Available)
|
|
|
|
test_install_uninstall_game();
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(gameexplorer)
|
|
|
|
{
|
2019-10-25 19:19:48 +02:00
|
|
|
HRESULT hr;
|
2010-09-15 00:57:02 +02:00
|
|
|
|
2019-10-25 19:19:48 +02:00
|
|
|
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
|
|
|
ok(hr == S_OK, "Failed to initialize COM, hr %#x.\n", hr);
|
|
|
|
trace("Running multithreaded tests.\n");
|
|
|
|
run_tests();
|
|
|
|
CoUninitialize();
|
|
|
|
|
|
|
|
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
|
|
|
ok(hr == S_OK, "Failed to initialize COM, hr %#x.\n", hr);
|
|
|
|
trace("Running apartment threaded tests.\n");
|
|
|
|
run_tests();
|
|
|
|
CoUninitialize();
|
2010-08-03 11:58:01 +02:00
|
|
|
}
|