From 683502f4650fa6aeafcd718c21aa296384a23d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Pluci=C5=84ski?= Date: Mon, 23 Aug 2010 12:47:02 +0200 Subject: [PATCH] gameux/tests: Add tests for AddGame and RemoveGame methods. --- dlls/gameux/tests/Makefile.in | 3 +- dlls/gameux/tests/gameexplorer.c | 86 ++++++++++++++++++++++++++++++-- dlls/gameux/tests/rsrc.rc | 26 ++++++++++ dlls/gameux/tests/test.gdf.xml | 30 +++++++++++ 4 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 dlls/gameux/tests/rsrc.rc create mode 100644 dlls/gameux/tests/test.gdf.xml diff --git a/dlls/gameux/tests/Makefile.in b/dlls/gameux/tests/Makefile.in index 7188e74e19c..542fc29cfde 100644 --- a/dlls/gameux/tests/Makefile.in +++ b/dlls/gameux/tests/Makefile.in @@ -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@ diff --git a/dlls/gameux/tests/gameexplorer.c b/dlls/gameux/tests/gameexplorer.c index 8498fe1d7f9..3decfa2c988 100644 --- a/dlls/gameux/tests/gameexplorer.c +++ b/dlls/gameux/tests/gameexplorer.c @@ -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(); } diff --git a/dlls/gameux/tests/rsrc.rc b/dlls/gameux/tests/rsrc.rc new file mode 100644 index 00000000000..b310db9c6c0 --- /dev/null +++ b/dlls/gameux/tests/rsrc.rc @@ -0,0 +1,26 @@ +/* + * 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 + +LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT +ID_GDF_XML DATA "test.gdf.xml" diff --git a/dlls/gameux/tests/test.gdf.xml b/dlls/gameux/tests/test.gdf.xml new file mode 100644 index 00000000000..32d054abe71 --- /dev/null +++ b/dlls/gameux/tests/test.gdf.xml @@ -0,0 +1,30 @@ + + + + + Example Game + + + + +