[USERENV_APITEST]: Add some simple tests for Get[AllUsers|DefaultUser|User]Profile[s]Directory APIs (checking return values & last errors).

svn path=/trunk/; revision=73735
This commit is contained in:
Hermès Bélusca-Maïto 2017-02-06 22:14:50 +00:00
parent 4578326e06
commit 3f2554487e
3 changed files with 89 additions and 0 deletions

View file

@ -1,5 +1,6 @@
list(APPEND SOURCE
GetProfileDirs.c
LoadUserProfile.c
testlist.c)

View file

@ -0,0 +1,86 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
* PURPOSE: Tests for Get[AllUsers|DefaultUser|User]Profile[s]Directory APIs.
* PROGRAMMERS: Hermes Belusca-Maito
*/
#include <apitest.h>
#include <userenv.h>
/* The Get[AllUsers|DefaultUser|User]Profile[s]Directory have the same prototype */
typedef BOOL (WINAPI *GET_PROFILE_DIRS_FUNC)(LPWSTR lpProfileDir, LPDWORD lpcchSize);
typedef struct _GET_PROFILE_DIRS
{
GET_PROFILE_DIRS_FUNC pFunc;
LPCWSTR pFuncName;
} GET_PROFILE_DIRS, *PGET_PROFILE_DIRS;
GET_PROFILE_DIRS GetProfileDirsFuncsList[] =
{
{GetAllUsersProfileDirectoryW, L"GetAllUsersProfileDirectoryW"},
{GetDefaultUserProfileDirectoryW, L"GetDefaultUserProfileDirectoryW"},
{GetProfilesDirectoryW, L"GetProfilesDirectoryW"},
// {GetUserProfileDirectoryW, L"GetUserProfileDirectoryW"},
};
START_TEST(GetProfileDirs)
{
BOOL Success;
DWORD dwLastError;
DWORD cchSize;
WCHAR szProfileDir[MAX_PATH];
USHORT i;
PGET_PROFILE_DIRS GetProfileDirs;
for (i = 0; i < _countof(GetProfileDirsFuncsList); ++i)
{
GetProfileDirs = &GetProfileDirsFuncsList[i];
SetLastError(0xdeadbeef);
Success = GetProfileDirs->pFunc(NULL, NULL);
dwLastError = GetLastError();
ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
ok(dwLastError == ERROR_INVALID_PARAMETER, "%S: Expected error %lu, got %lu\n",
GetProfileDirs->pFuncName, (DWORD)ERROR_INVALID_PARAMETER, dwLastError);
SetLastError(0xdeadbeef);
Success = GetProfileDirs->pFunc(szProfileDir, NULL);
dwLastError = GetLastError();
ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
ok(dwLastError == ERROR_INVALID_PARAMETER, "%S: Expected error %lu, got %lu\n",
GetProfileDirs->pFuncName, (DWORD)ERROR_INVALID_PARAMETER, dwLastError);
cchSize = 0;
SetLastError(0xdeadbeef);
Success = GetProfileDirs->pFunc(NULL, &cchSize);
dwLastError = GetLastError();
ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
ok(dwLastError == ERROR_INSUFFICIENT_BUFFER, "%S: Expected error %lu, got %lu\n",
GetProfileDirs->pFuncName, (DWORD)ERROR_INSUFFICIENT_BUFFER, dwLastError);
ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
cchSize = 0;
SetLastError(0xdeadbeef);
Success = GetProfileDirs->pFunc(szProfileDir, &cchSize);
dwLastError = GetLastError();
ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
ok(dwLastError == ERROR_INSUFFICIENT_BUFFER, "%S: Expected error %lu, got %lu\n",
GetProfileDirs->pFuncName, (DWORD)ERROR_INSUFFICIENT_BUFFER, dwLastError);
ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
cchSize = _countof(szProfileDir);
SetLastError(0xdeadbeef);
Success = GetProfileDirs->pFunc(szProfileDir, &cchSize);
dwLastError = GetLastError();
ok(Success, "%S: Expected to success, got failure instead\n", GetProfileDirs->pFuncName);
ok(dwLastError == 0xdeadbeef, "%S: Expected error %lu, got %lu\n",
GetProfileDirs->pFuncName, (DWORD)0xdeadbeef, dwLastError);
ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
ok(*szProfileDir, "%S: Expected a profile directory, got nothing\n", GetProfileDirs->pFuncName);
}
// TODO: Add more tests!
}

View file

@ -3,10 +3,12 @@
#define STANDALONE
#include <apitest.h>
extern void func_GetProfileDirs(void);
extern void func_LoadUserProfile(void);
const struct test winetest_testlist[] =
{
{ "GetProfileDirs", func_GetProfileDirs },
{ "LoadUserProfile", func_LoadUserProfile },
{ 0, 0 }
};