Commit 683502f4 authored by Mariusz Pluciński's avatar Mariusz Pluciński Committed by Alexandre Julliard

gameux/tests: Add tests for AddGame and RemoveGame methods.

parent c8193717
......@@ -3,11 +3,12 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = gameux.dll
IMPORTS = ole32
IMPORTS = uuid shlwapi oleaut32 ole32
C_SRCS = \
gameexplorer.c \
gamestatistics.c
RC_SRCS = rsrc.rc
@MAKE_TEST_RULES@
......@@ -20,18 +20,20 @@
#define COBJMACROS
#include "initguid.h"
#include "windows.h"
#include "ole2.h"
#include "objsafe.h"
#include "objbase.h"
#include "shlwapi.h"
#include "shobjidl.h"
#include "initguid.h"
#include "gameux.h"
#include "wine/test.h"
static void test_create( void )
static void test_create(BOOL* gameExplorerAvailable)
{
HRESULT hr;
......@@ -43,6 +45,7 @@ static void test_create( void )
if(ge)
{
ok(hr == S_OK, "IGameExplorer creating failed (result false)\n");
*gameExplorerAvailable = TRUE;
IGameExplorer_Release(ge);
}
else
......@@ -59,14 +62,89 @@ static void test_create( void )
win_skip("IGameExplorer2 cannot be created\n");
}
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 */
dwExeNameLen = GetModuleFileNameW(NULL, sExeName, sizeof (sExeName) / sizeof (sExeName[0]));
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);
todo_wine ok(SUCCEEDED(hr), "IGameExplorer::AddGame failed (error 0x%08x)\n", hr);
ok(memcmp(&guid, &defaultGUID, sizeof (guid)) == 0, "AddGame unexpectedly modified GUID\n");
if(SUCCEEDED(hr))
{
hr = IGameExplorer_RemoveGame(ge, guid);
todo_wine ok(SUCCEEDED(hr), "IGameExplorer::RemoveGame failed (error 0x%08x)\n", hr);
}
/* try to register game with empty guid */
memcpy(&guid, &GUID_NULL, sizeof (guid));
hr = IGameExplorer_AddGame(ge, bstrExeName, bstrExePath, GIS_CURRENT_USER, &guid);
todo_wine ok(SUCCEEDED(hr), "IGameExplorer::AddGame failed (error 0x%08x)\n", hr);
todo_wine ok(memcmp(&guid, &GUID_NULL, sizeof (guid)) != 0, "AddGame did not modify GUID\n");
if(SUCCEEDED(hr))
{
hr = IGameExplorer_RemoveGame(ge, guid);
todo_wine ok(SUCCEEDED(hr), "IGameExplorer::RemoveGame failed (error 0x%08x)\n", hr);
}
}
/* free allocated resources */
SysFreeString(bstrExePath);
SysFreeString(bstrExeName);
IGameExplorer_Release(ge);
}
}
START_TEST(gameexplorer)
{
HRESULT r;
BOOL gameExplorerAvailable = FALSE;
r = CoInitialize( NULL );
ok( r == S_OK, "failed to init COM\n");
test_create();
test_create(&gameExplorerAvailable);
if(gameExplorerAvailable)
test_add_remove_game();
CoUninitialize();
}
/*
* Resources script for GameUX testing
*
* 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
*/
#include "windef.h"
#include "winuser.h"
#include <gameux.h>
LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
ID_GDF_XML DATA "test.gdf.xml"
<?xml version="1.0" encoding="utf-8"?>
<!--
Example Game Definition File
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
-->
<GameDefinitionFile
xmlns:baseTypes="urn:schemas-microsoft-com:GamesExplorerBaseTypes.v1"
xmlns="urn:schemas-microsoft-com:GameDescription.v1">
<GameDefinition gameID="{17A6558E-60BE-4078-B66F-9C3ADA2A32E6}">
<Name>Example Game</Name>
<Version>
<VersionNumber versionNumber="1.0.0.0"/>
</Version>
</GameDefinition>
</GameDefinitionFile>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment