ReactOS 0.4.15-dev-8417-gb6b82fe
GetProfileDirs.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Tests for Get[AllUsers|DefaultUser|User]Profile[s]Directory APIs.
5 * PROGRAMMERS: Hermes Belusca-Maito
6 */
7
8#include <apitest.h>
9#include <userenv.h>
10
11/* The Get[AllUsers|DefaultUser|User]Profile[s]Directory have the same prototype */
12typedef BOOL (WINAPI *GET_PROFILE_DIRS_FUNC)(LPWSTR lpProfileDir, LPDWORD lpcchSize);
13
14typedef struct _GET_PROFILE_DIRS
15{
19
21{
22 {GetAllUsersProfileDirectoryW, L"GetAllUsersProfileDirectoryW"},
23 {GetDefaultUserProfileDirectoryW, L"GetDefaultUserProfileDirectoryW"},
24 {GetProfilesDirectoryW, L"GetProfilesDirectoryW"},
25// {GetUserProfileDirectoryW, L"GetUserProfileDirectoryW"},
26};
27
28START_TEST(GetProfileDirs)
29{
31 DWORD dwLastError;
32 DWORD cchSize;
33 WCHAR szProfileDir[MAX_PATH];
34
35 USHORT i;
36 PGET_PROFILE_DIRS GetProfileDirs;
37
38 for (i = 0; i < _countof(GetProfileDirsFuncsList); ++i)
39 {
40 GetProfileDirs = &GetProfileDirsFuncsList[i];
41
42 SetLastError(0xdeadbeef);
43 Success = GetProfileDirs->pFunc(NULL, NULL);
44 dwLastError = GetLastError();
45 ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
46 ok(dwLastError == ERROR_INVALID_PARAMETER, "%S: Expected error %lu, got %lu\n",
47 GetProfileDirs->pFuncName, (DWORD)ERROR_INVALID_PARAMETER, dwLastError);
48
49 SetLastError(0xdeadbeef);
50 Success = GetProfileDirs->pFunc(szProfileDir, NULL);
51 dwLastError = GetLastError();
52 ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
53 ok(dwLastError == ERROR_INVALID_PARAMETER, "%S: Expected error %lu, got %lu\n",
54 GetProfileDirs->pFuncName, (DWORD)ERROR_INVALID_PARAMETER, dwLastError);
55
56 cchSize = 0;
57 SetLastError(0xdeadbeef);
58 Success = GetProfileDirs->pFunc(NULL, &cchSize);
59 dwLastError = GetLastError();
60 ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
61 ok(dwLastError == ERROR_INSUFFICIENT_BUFFER, "%S: Expected error %lu, got %lu\n",
62 GetProfileDirs->pFuncName, (DWORD)ERROR_INSUFFICIENT_BUFFER, dwLastError);
63 ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
64
65 cchSize = 0;
66 SetLastError(0xdeadbeef);
67 Success = GetProfileDirs->pFunc(szProfileDir, &cchSize);
68 dwLastError = GetLastError();
69 ok(!Success, "%S: Expected failure, got success instead\n", GetProfileDirs->pFuncName);
70 ok(dwLastError == ERROR_INSUFFICIENT_BUFFER, "%S: Expected error %lu, got %lu\n",
71 GetProfileDirs->pFuncName, (DWORD)ERROR_INSUFFICIENT_BUFFER, dwLastError);
72 ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
73
74 cchSize = _countof(szProfileDir);
75 SetLastError(0xdeadbeef);
76 Success = GetProfileDirs->pFunc(szProfileDir, &cchSize);
77 dwLastError = GetLastError();
78 ok(Success, "%S: Expected to success, got failure instead\n", GetProfileDirs->pFuncName);
79 ok(dwLastError == 0xdeadbeef, "%S: Expected error %lu, got %lu\n",
80 GetProfileDirs->pFuncName, (DWORD)0xdeadbeef, dwLastError);
81 ok(cchSize != 0, "%S: Expected a profile directory size != 0, got 0\n", GetProfileDirs->pFuncName);
82 ok(*szProfileDir, "%S: Expected a profile directory, got nothing\n", GetProfileDirs->pFuncName);
83 }
84
85 // TODO: Add more tests!
86}
struct _GET_PROFILE_DIRS GET_PROFILE_DIRS
GET_PROFILE_DIRS GetProfileDirsFuncsList[]
BOOL(WINAPI * GET_PROFILE_DIRS_FUNC)(LPWSTR lpProfileDir, LPDWORD lpcchSize)
struct _GET_PROFILE_DIRS * PGET_PROFILE_DIRS
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI GetAllUsersProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1310
BOOL WINAPI GetDefaultUserProfileDirectoryW(_Out_opt_ LPWSTR lpProfileDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1443
BOOL WINAPI GetProfilesDirectoryW(_Out_ LPWSTR lpProfilesDir, _Inout_ LPDWORD lpcchSize)
Definition: profile.c:1576
@ Success
Definition: eventcreate.c:712
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
#define _countof(array)
Definition: sndvol32.h:70
GET_PROFILE_DIRS_FUNC pFunc
uint32_t * LPDWORD
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define WINAPI
Definition: msvc.h:6
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185