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
11 /* The Get[AllUsers|DefaultUser|User]Profile[s]Directory have the same prototype */
12 typedef BOOL (WINAPI
*GET_PROFILE_DIRS_FUNC
)(LPWSTR lpProfileDir
, LPDWORD lpcchSize
);
14 typedef struct _GET_PROFILE_DIRS
16 GET_PROFILE_DIRS_FUNC pFunc
;
18 } GET_PROFILE_DIRS
, *PGET_PROFILE_DIRS
;
20 GET_PROFILE_DIRS GetProfileDirsFuncsList
[] =
22 {GetAllUsersProfileDirectoryW
, L
"GetAllUsersProfileDirectoryW"},
23 {GetDefaultUserProfileDirectoryW
, L
"GetDefaultUserProfileDirectoryW"},
24 {GetProfilesDirectoryW
, L
"GetProfilesDirectoryW"},
25 // {GetUserProfileDirectoryW, L"GetUserProfileDirectoryW"},
28 START_TEST(GetProfileDirs
)
33 WCHAR szProfileDir
[MAX_PATH
];
36 PGET_PROFILE_DIRS GetProfileDirs
;
38 for (i
= 0; i
< _countof(GetProfileDirsFuncsList
); ++i
)
40 GetProfileDirs
= &GetProfileDirsFuncsList
[i
];
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
);
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
);
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
);
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
);
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
);
85 // TODO: Add more tests!