gameux/tests: Use wide-char string literals.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-12-06 16:02:17 +01:00 committed by Alexandre Julliard
parent 7f46f2314f
commit 323d46fb93
1 changed files with 44 additions and 57 deletions

View File

@ -89,12 +89,6 @@ static void test_unregister_game(IGameExplorer *ge)
*/
static HRESULT _buildStatisticsFilePath(LPCGUID guidApplicationId, LPWSTR *lpStatisticsFile)
{
static const WCHAR sBackslash[] = {'\\',0};
static const WCHAR sStatisticsDir[] = {'\\','M','i','c','r','o','s','o','f','t',
'\\','W','i','n','d','o','w','s','\\','G','a','m','e','E','x','p',
'l','o','r','e','r','\\','G','a','m','e','S','t','a','t','i','s',
't','i','c','s','\\',0};
static const WCHAR sDotGamestats[] = {'.','g','a','m','e','s','t','a','t','s',0};
HRESULT hr;
WCHAR sGuid[49], sPath[MAX_PATH];
@ -105,11 +99,11 @@ static HRESULT _buildStatisticsFilePath(LPCGUID guidApplicationId, LPWSTR *lpSta
if(SUCCEEDED(hr))
{
lstrcatW(sPath, sStatisticsDir);
lstrcatW(sPath, L"\\Microsoft\\Windows\\GameExplorer\\GameStatistics\\");
lstrcatW(sPath, sGuid);
lstrcatW(sPath, sBackslash);
lstrcatW(sPath, L"\\");
lstrcatW(sPath, sGuid);
lstrcatW(sPath, sDotGamestats);
lstrcatW(sPath, L".gamestats");
*lpStatisticsFile = CoTaskMemAlloc((lstrlenW(sPath)+1)*sizeof(WCHAR));
if(!*lpStatisticsFile) hr = E_OUTOFMEMORY;
@ -145,22 +139,6 @@ static BOOL _isFileExists(LPCWSTR lpFile)
static void test_gamestatisticsmgr( void )
{
static const GUID guidApplicationId = { 0x17A6558E, 0x60BE, 0x4078, { 0xB6, 0x6F, 0x9C, 0x3A, 0xDA, 0x2A, 0x32, 0xE6 } };
static const WCHAR sCategory0[] = {'C','a','t','e','g','o','r','y','0',0};
static const WCHAR sCategory1[] = {'C','a','t','e','g','o','r','y','1',0};
static const WCHAR sCategory2[] = {'C','a','t','e','g','o','r','y','2',0};
static const WCHAR sCategory0a[] = {'C','a','t','e','g','o','r','y','0','a',0};
static const WCHAR sStatistic00[] = {'S','t','a','t','i','s','t','i','c','0','0',0};
static const WCHAR sStatistic01[] = {'S','t','a','t','i','s','t','i','c','0','1',0};
static const WCHAR sStatistic10[] = {'S','t','a','t','i','s','t','i','c','1','0',0};
static const WCHAR sStatistic11[] = {'S','t','a','t','i','s','t','i','c','1','1',0};
static const WCHAR sStatistic20[] = {'S','t','a','t','i','s','t','i','c','2','0',0};
static const WCHAR sStatistic21[] = {'S','t','a','t','i','s','t','i','c','2','1',0};
static const WCHAR sValue00[] = {'V','a','l','u','e','0','0',0};
static const WCHAR sValue01[] = {'V','a','l','u','e','0','1',0};
static const WCHAR sValue10[] = {'V','a','l','u','e','1','0',0};
static const WCHAR sValue11[] = {'V','a','l','u','e','1','1',0};
static const WCHAR sValue20[] = {'V','a','l','u','e','2','0',0};
static const WCHAR sValue21[] = {'V','a','l','u','e','2','1',0};
HRESULT hr;
DWORD dwOpenResult;
@ -221,7 +199,7 @@ static void test_gamestatisticsmgr( void )
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, NULL);
ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, sCategory0);
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, L"Category0");
ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
/* check what happen if string is too long */
@ -234,45 +212,51 @@ static void test_gamestatisticsmgr( void )
ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
CoTaskMemFree(sTooLongString);
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));
ok(IGameStatistics_SetCategoryTitle(gs, 0, L"Category0")==S_OK, "setting category title failed: Category0\n");
ok(IGameStatistics_SetCategoryTitle(gs, 1, L"Category1")==S_OK, "setting category title failed: Category1\n");
ok(IGameStatistics_SetCategoryTitle(gs, 2, L"Category2")==S_OK, "setting category title failed: Category2\n");
/* check what happen if any string is NULL */
hr = IGameStatistics_SetStatistic(gs, 0, 0, NULL, sValue00);
hr = IGameStatistics_SetStatistic(gs, 0, 0, NULL, L"Value00");
ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
hr = IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, NULL);
hr = IGameStatistics_SetStatistic(gs, 0, 0, L"Statistic00", NULL);
ok(hr == S_OK, "setting statistic returned unexpected value: 0x%x)\n", hr);
/* check what happen if any string is too long */
sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxNameLength+2));
memset(sTooLongString, 'a', sizeof(WCHAR)*(uMaxNameLength+1));
sTooLongString[uMaxNameLength+1]=0;
hr = IGameStatistics_SetStatistic(gs, 0, 0, sTooLongString, sValue00);
hr = IGameStatistics_SetStatistic(gs, 0, 0, sTooLongString, L"Value00");
ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
CoTaskMemFree(sTooLongString);
sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxValueLength+2));
memset(sTooLongString, 'a', sizeof(WCHAR)*(uMaxValueLength+1));
sTooLongString[uMaxValueLength+1]=0;
hr = IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, sTooLongString);
hr = IGameStatistics_SetStatistic(gs, 0, 0, L"Statistic00", sTooLongString);
ok(hr == S_FALSE, "setting statistic returned unexpected value: 0x%x)\n", hr);
CoTaskMemFree(sTooLongString);
/* check what happen on too big index of category or statistic */
hr = IGameStatistics_SetStatistic(gs, wMaxCategories, 0, sStatistic00, sValue00);
hr = IGameStatistics_SetStatistic(gs, wMaxCategories, 0, L"Statistic00", L"Value00");
ok(hr == E_INVALIDARG, "setting statistic returned unexpected value: 0x%x)\n", hr);
hr = IGameStatistics_SetStatistic(gs, 0, wMaxStatsPerCategory, sStatistic00, sValue00);
hr = IGameStatistics_SetStatistic(gs, 0, wMaxStatsPerCategory, L"Statistic00", L"Value00");
ok(hr == E_INVALIDARG, "setting statistic returned unexpected value: 0x%x)\n", hr);
ok(IGameStatistics_SetStatistic(gs, 0, 0, sStatistic00, sValue00)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic00), wine_dbgstr_w(sValue00));
ok(IGameStatistics_SetStatistic(gs, 0, 1, sStatistic01, sValue01)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic01), wine_dbgstr_w(sValue01));
ok(IGameStatistics_SetStatistic(gs, 1, 0, sStatistic10, sValue10)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic10), wine_dbgstr_w(sValue10));
ok(IGameStatistics_SetStatistic(gs, 1, 1, sStatistic11, sValue11)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic11), wine_dbgstr_w(sValue11));
ok(IGameStatistics_SetStatistic(gs, 2, 0, sStatistic20, sValue20)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic20), wine_dbgstr_w(sValue20));
ok(IGameStatistics_SetStatistic(gs, 2, 1, sStatistic21, sValue21)==S_OK, "setting statistic failed: name=%s, value=%s\n", wine_dbgstr_w(sStatistic21), wine_dbgstr_w(sValue21));
ok(IGameStatistics_SetStatistic(gs, 0, 0, L"Statistic00", L"Value00")==S_OK,
"setting statistic failed: name=Statistic00, value=Value00\n");
ok(IGameStatistics_SetStatistic(gs, 0, 1, L"Statistic01", L"Value01")==S_OK,
"setting statistic failed: name=Statistic01, value=Value01\n");
ok(IGameStatistics_SetStatistic(gs, 1, 0, L"Statistic10", L"Value10")==S_OK,
"setting statistic failed: name=Statistic10, value=Value10\n");
ok(IGameStatistics_SetStatistic(gs, 1, 1, L"Statistic11", L"Value11")==S_OK,
"setting statistic failed: name=Statistic11, value=Value11\n");
ok(IGameStatistics_SetStatistic(gs, 2, 0, L"Statistic20", L"Value20")==S_OK,
"setting statistic failed: name=Statistic20, value=Value20\n");
ok(IGameStatistics_SetStatistic(gs, 2, 1, L"Statistic21", L"Value21")==S_OK,
"setting statistic failed: name=Statistic21, value=Value21\n");
ok(_isFileExists(lpStatisticsFile) == FALSE, "statistics file %s already exists\n", wine_dbgstr_w(lpStatisticsFile));
@ -281,7 +265,7 @@ static void test_gamestatisticsmgr( void )
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 */
ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
ok(IGameStatistics_SetCategoryTitle(gs, 0, L"Category0a")==S_OK, "setting category title failed: Category0a\n");
hr = IGameStatistics_Release(gs);
ok(SUCCEEDED(hr), "releasing IGameStatistics returned error: 0x%08x\n", hr);
@ -295,17 +279,20 @@ static void test_gamestatisticsmgr( void )
/* verify values with these which we stored before*/
hr = IGameStatistics_GetCategoryTitle(gs, 0, &lpName);
ok(hr == S_OK, "getting category title failed\n");
ok(lstrcmpW(lpName, sCategory0)==0, "getting category title returned invalid string %s\n", wine_dbgstr_w(lpName));
ok(lstrcmpW(lpName, L"Category0")==0, "getting category title returned invalid string %s\n",
wine_dbgstr_w(lpName));
CoTaskMemFree(lpName);
hr = IGameStatistics_GetCategoryTitle(gs, 1, &lpName);
ok(hr == S_OK, "getting category title failed\n");
ok(lstrcmpW(lpName, sCategory1)==0, "getting category title returned invalid string %s\n", wine_dbgstr_w(lpName));
ok(lstrcmpW(lpName, L"Category1")==0, "getting category title returned invalid string %s\n",
wine_dbgstr_w(lpName));
CoTaskMemFree(lpName);
hr = IGameStatistics_GetCategoryTitle(gs, 2, &lpName);
ok(hr == S_OK, "getting category title failed\n");
ok(lstrcmpW(lpName, sCategory2)==0, "getting category title returned invalid string %s\n", wine_dbgstr_w(lpName));
ok(lstrcmpW(lpName, L"Category2")==0, "getting category title returned invalid string %s\n",
wine_dbgstr_w(lpName));
CoTaskMemFree(lpName);
/* check result if category doesn't exists */
@ -316,43 +303,43 @@ static void test_gamestatisticsmgr( void )
hr = IGameStatistics_GetStatistic(gs, 0, 0, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic00")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value00")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 0, 1, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic01")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value01")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 1, 0, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic10")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value10")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 1, 1, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic11")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value11")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 2, 0, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic20")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value20")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);
hr = IGameStatistics_GetStatistic(gs, 2, 1, &lpName, &lpValue);
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");
ok(lstrcmpW(lpName, L"Statistic21")==0, "getting statistic returned invalid name\n");
ok(lstrcmpW(lpValue, L"Value21")==0, "getting statistic returned invalid value\n");
CoTaskMemFree(lpName);
CoTaskMemFree(lpValue);