gameux: Add implementation of IGameStatistics::SetCategoryTitle.

oldstable
Mariusz Pluciński 2010-09-26 15:17:41 +02:00 committed by Alexandre Julliard
parent 6fa52cd37d
commit 35692e40b1
2 changed files with 52 additions and 9 deletions

View File

@ -39,6 +39,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(gameux);
#define MAX_VALUE_LENGTH 30
#define MAX_CATEGORIES 10
#define MAX_STATS_PER_CATEGORY 10
/*******************************************************************************
* Game statistics helper components
*/
/*******************************************************************************
* struct GAMEUX_STATS
*
* set of structures for containing game's data
*/
struct GAMEUX_STATS_STAT
{
WCHAR sName[MAX_NAME_LENGTH+1];
WCHAR sValue[MAX_VALUE_LENGTH+1];
};
struct GAMEUX_STATS_CATEGORY
{
WCHAR sName[MAX_CATEGORY_LENGTH+1];
struct GAMEUX_STATS_STAT stats[MAX_STATS_PER_CATEGORY];
};
struct GAMEUX_STATS
{
WCHAR sStatsFile[MAX_PATH];
struct GAMEUX_STATS_CATEGORY categories[MAX_CATEGORIES];
};
/*******************************************************************************
* IGameStatistics implementation
*/
@ -46,6 +69,7 @@ typedef struct _GameStatisticsImpl
{
const struct IGameStatisticsVtbl *lpVtbl;
LONG ref;
struct GAMEUX_STATS stats;
} GameStatisticsImpl;
static inline GameStatisticsImpl *impl_from_IGameStatistics( IGameStatistics *iface )
@ -177,8 +201,27 @@ static HRESULT WINAPI GameStatisticsImpl_SetCategoryTitle(
WORD categoryIndex,
LPCWSTR title)
{
FIXME("stub\n");
return E_NOTIMPL;
HRESULT hr = S_OK;
DWORD dwLength;
GameStatisticsImpl *This = impl_from_IGameStatistics(iface);
TRACE("(%p, %d, %s)\n", This, categoryIndex, debugstr_w(title));
if(!title || categoryIndex >= MAX_CATEGORIES)
return E_INVALIDARG;
dwLength = lstrlenW(title);
if(dwLength > MAX_CATEGORY_LENGTH)
{
hr = S_FALSE;
dwLength = MAX_CATEGORY_LENGTH;
}
lstrcpynW(This->stats.categories[categoryIndex].sName,
title, dwLength+1);
return hr;
}
static HRESULT WINAPI GameStatisticsImpl_GetCategoryTitle(

View File

@ -271,10 +271,10 @@ static void test_gamestatisticsmgr( void )
/* write sample statistics */
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, NULL);
todo_wine ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, sCategory0);
todo_wine ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
/* check what happen if string is too long */
sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxCategoryLength+2));
@ -283,12 +283,12 @@ static void test_gamestatisticsmgr( void )
/* when string is too long, Windows returns S_FALSE, but saves string (stripped to expected number of characters) */
hr = IGameStatistics_SetCategoryTitle(gs, 0, sTooLongString);
todo_wine ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
CoTaskMemFree(sTooLongString);
todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0));
todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 1, sCategory1)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 2, sCategory2)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0));
ok(IGameStatistics_SetCategoryTitle(gs, 1, sCategory1)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
ok(IGameStatistics_SetCategoryTitle(gs, 2, sCategory2)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
/* check what happen if any string is NULL */
hr = IGameStatistics_SetStatistic(gs, 0, 0, NULL, sValue00);
@ -333,7 +333,7 @@ static void test_gamestatisticsmgr( void )
todo_wine ok(_isFileExists(lpStatisticsFile) == TRUE, "statistics file %s does not exists\n", wine_dbgstr_w(lpStatisticsFile));
/* this value should not be stored in storage, we need it only to test is it not saved */
todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
hr = IGameStatistics_Release(gs);
ok(SUCCEEDED(hr), "releasing IGameStatistics returned error: 0x%08x\n", hr);