gameux: Add implementation of IGameStatistics::GetStatistic.

This commit is contained in:
Pluciński Mariusz 2010-11-04 16:37:04 +01:00 committed by Alexandre Julliard
parent ff9e31a2b5
commit 6b35b5dd37
2 changed files with 61 additions and 20 deletions

View File

@ -839,8 +839,49 @@ static HRESULT WINAPI GameStatisticsImpl_GetStatistic(
LPWSTR *pName,
LPWSTR *pValue)
{
FIXME("stub\n");
return E_NOTIMPL;
HRESULT hr = S_OK;
LONG nLength;
GameStatisticsImpl *This = impl_from_IGameStatistics(iface);
TRACE("%p, %d,%d, %p, %p\n", This, categoryIndex, statIndex, pName, pValue);
if(!pName || !pValue)
return E_INVALIDARG;
*pName = NULL;
*pValue = NULL;
if(categoryIndex >= MAX_CATEGORIES || statIndex >= MAX_STATS_PER_CATEGORY)
hr = E_INVALIDARG;
if(SUCCEEDED(hr))
{
nLength = lstrlenW(This->stats.categories[categoryIndex].stats[statIndex].sName);
if(nLength != 0)
{
*pName = CoTaskMemAlloc(sizeof(WCHAR)*(nLength+1));
if(!(*pName))
hr = E_OUTOFMEMORY;
else
lstrcpyW(*pName, This->stats.categories[categoryIndex].stats[statIndex].sName);
}
}
if(SUCCEEDED(hr))
{
nLength = lstrlenW(This->stats.categories[categoryIndex].stats[statIndex].sValue);
if(nLength != 0)
{
*pValue = CoTaskMemAlloc(sizeof(WCHAR)*(nLength+1));
if(!(*pValue))
hr = E_OUTOFMEMORY;
else
lstrcpyW(*pValue, This->stats.categories[categoryIndex].stats[statIndex].sValue);
}
}
TRACE("returning pair; %s => %s\n", debugstr_w(*pName), debugstr_w(*pValue));
return hr;
}
static HRESULT WINAPI GameStatisticsImpl_SetStatistic(

View File

@ -367,44 +367,44 @@ static void test_gamestatisticsmgr( void )
CoTaskMemFree(lpName);
hr = IGameStatistics_GetStatistic(gs, 0, 0, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic00)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue00)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic00)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue00)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 0, 1, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic01)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue01)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic01)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue01)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 1, 0, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic10)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue10)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic10)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue10)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 1, 1, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic11)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue11)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic11)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue11)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 2, 0, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic20)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue20)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic20)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue20)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 2, 1, &lpName, &lpValue);
todo_wine ok(hr == S_OK, "getting statistic failed\n");
todo_wine ok(lstrcmpW(lpName, sStatistic21)==0, "getting statistic returned invalid name\n");
todo_wine ok(lstrcmpW(lpValue, sValue21)==0, "getting statistic returned invalid value\n");
ok(hr == S_OK, "getting statistic failed\n");
ok(lstrcmpW(lpName, sStatistic21)==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, sValue21)==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);