[USERENV_APITEST]: Add some simple tests for Get[AllUsers|DefaultUser|User]Profile...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 6 Feb 2017 22:14:50 +0000 (22:14 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Mon, 6 Feb 2017 22:14:50 +0000 (22:14 +0000)
svn path=/trunk/; revision=73735

rostests/apitests/userenv/CMakeLists.txt
rostests/apitests/userenv/GetProfileDirs.c [new file with mode: 0644]
rostests/apitests/userenv/testlist.c

index a66cdf0..0de58be 100644 (file)
@@ -1,5 +1,6 @@
 
 list(APPEND SOURCE
+    GetProfileDirs.c
     LoadUserProfile.c
     testlist.c)
 
diff --git a/rostests/apitests/userenv/GetProfileDirs.c b/rostests/apitests/userenv/GetProfileDirs.c
new file mode 100644 (file)
index 0000000..eae4224
--- /dev/null
@@ -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!
+}
index 5ff527e..1e86148 100644 (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 }
 };