Author: hbelusca Date: Mon Feb 6 22:14:50 2017 New Revision: 73735
URL: http://svn.reactos.org/svn/reactos?rev=73735&view=rev Log: [USERENV_APITEST]: Add some simple tests for Get[AllUsers|DefaultUser|User]Profile[s]Directory APIs (checking return values & last errors).
Added: trunk/rostests/apitests/userenv/GetProfileDirs.c (with props) Modified: trunk/rostests/apitests/userenv/CMakeLists.txt trunk/rostests/apitests/userenv/testlist.c
Modified: trunk/rostests/apitests/userenv/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/userenv/CMakeList... ============================================================================== --- trunk/rostests/apitests/userenv/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/userenv/CMakeLists.txt [iso-8859-1] Mon Feb 6 22:14:50 2017 @@ -1,5 +1,6 @@
list(APPEND SOURCE + GetProfileDirs.c LoadUserProfile.c testlist.c)
Added: trunk/rostests/apitests/userenv/GetProfileDirs.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/userenv/GetProfil... ============================================================================== --- trunk/rostests/apitests/userenv/GetProfileDirs.c (added) +++ trunk/rostests/apitests/userenv/GetProfileDirs.c [iso-8859-1] Mon Feb 6 22:14:50 2017 @@ -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! +}
Propchange: trunk/rostests/apitests/userenv/GetProfileDirs.c ------------------------------------------------------------------------------ svn:eol-style = native
Modified: trunk/rostests/apitests/userenv/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/userenv/testlist.... ============================================================================== --- trunk/rostests/apitests/userenv/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/userenv/testlist.c [iso-8859-1] Mon Feb 6 22:14:50 2017 @@ -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 } };