[PATCH] Test for the explorer.exe

Carlos Vega GarcĂ­a carlosvegagc at gmail.com
Wed Mar 21 21:08:45 CDT 2018


---
 configure                           |   1 +
 programs/explorer/tests/Makefile.in |   5 ++
 programs/explorer/tests/explorer.c  | 158 ++++++++++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+)
 create mode 100755 programs/explorer/tests/Makefile.in
 create mode 100755 programs/explorer/tests/explorer.c

diff --git a/configure b/configure
index 6324574..9f36b54 100755
--- a/configure
+++ b/configure
@@ -19220,6 +19220,7 @@ wine_fn_config_makefile programs/dxdiag enable_dxdiag
 wine_fn_config_makefile programs/eject enable_eject
 wine_fn_config_makefile programs/expand enable_expand
 wine_fn_config_makefile programs/explorer enable_explorer
+wine_fn_config_makefile programs/explorer/tests enable_tests                 
 wine_fn_config_makefile programs/extrac32 enable_extrac32
 wine_fn_config_makefile programs/findstr enable_findstr
 wine_fn_config_makefile programs/fsutil enable_fsutil
diff --git a/programs/explorer/tests/Makefile.in b/programs/explorer/tests/Makefile.in
new file mode 100755
index 0000000..422465b
--- /dev/null
+++ b/programs/explorer/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL   = explorer.exe
+IMPORTS   = shell32 ole32 oleaut32 user32 gdi32 advapi32 shlwapi
+
+C_SRCS = \
+	explorer.c 
diff --git a/programs/explorer/tests/explorer.c b/programs/explorer/tests/explorer.c
new file mode 100755
index 0000000..28e1ad3
--- /dev/null
+++ b/programs/explorer/tests/explorer.c
@@ -0,0 +1,158 @@
+/*
+ * Unit tests for explorer.exe
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include <stdio.h>
+#include <winbase.h>
+#include "dde.h"
+#include "ddeml.h"
+#include "winuser.h"
+#include "shlobj.h"
+
+static HRESULT (WINAPI *pSHGetLocalizedName)(LPCWSTR, LPWSTR, UINT, int *);
+
+static BOOL use_common(void)
+{
+    HMODULE hmod;
+    static BOOL (WINAPI *pIsNTAdmin)(DWORD, LPDWORD);
+
+    /* IsNTAdmin() is available on all platforms. */
+    hmod = LoadLibraryA("advpack.dll");
+    pIsNTAdmin = (void*)GetProcAddress(hmod, "IsNTAdmin");
+
+    if (!pIsNTAdmin(0, NULL))
+    {
+        /* We are definitely not an administrator */
+        FreeLibrary(hmod);
+        return FALSE;
+    }
+    FreeLibrary(hmod);
+
+    /* If we end up here we are on NT4+ as Win9x and WinMe don't have the
+     * notion of administrators (as we need it).
+     */
+
+    /* As of Vista  we should always use the users directory. Tests with the
+     * real Administrator account on Windows 7 proved this.
+     *
+     * FIXME: We need a better way of identifying Vista+ as currently this check
+     * also covers Wine and we don't know yet which behavior we want to follow.
+     */
+    if (pSHGetLocalizedName)
+        return FALSE;
+
+    return TRUE;
+}
+
+static BOOL full_title(void)
+{
+    CABINETSTATE cs;
+
+    memset(&cs, 0, sizeof(cs));
+    ReadCabinetState(&cs, sizeof(cs));
+
+    return (cs.fFullPathTitle == -1);
+}
+
+
+static char ProgramsDir[MAX_PATH];
+static void init_strings(void)
+{
+    char commonprograms[MAX_PATH];
+    char programs[MAX_PATH];
+
+    SHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE);
+    SHGetSpecialFolderPathA(NULL, commonprograms, CSIDL_COMMON_PROGRAMS, FALSE);
+
+    /* ProgramsDir on Vista+ is always the users one (CSIDL_PROGRAMS). Before Vista
+     * it depends on whether the user is an administrator (CSIDL_COMMON_PROGRAMS) or
+     * not (CSIDL_PROGRAMS).
+     */
+
+    if (use_common())
+        lstrcpyA(ProgramsDir, commonprograms);
+    else
+        lstrcpyA(ProgramsDir, programs);
+}
+
+
+
+static BOOL check_window_exists(const char *name)
+{
+    char title[MAX_PATH];
+    HWND window = NULL;
+    int i;
+
+    if (full_title())
+    {
+        strcpy(title, ProgramsDir);
+        strcat(title, "\\");
+        strcat(title, name);
+    }
+    else
+        strcpy(title, name);
+
+	trace("\n \n Window name: %s \n \n",name);
+    for (i = 0; i < 20; i++)
+    {
+        Sleep(20 + 20*i);
+        if ((window = FindWindowA("ExplorerWClass", title)) ||
+            (window = FindWindowA("CabinetWClass", title)))
+        {
+            SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0);
+            break;
+        }
+    }
+
+    return (window != NULL);
+}
+
+
+
+/*
+*We make a call to open a new explorer window and we test if it finally opens.
+*/
+int explorer_available(void)
+{
+	STARTUPINFOA si;
+	PROCESS_INFORMATION pi;
+	LPDWORD lpExitCode;
+	char cmd[] = {'e','x','p','l','o','r','e','r',' ','/','r','o','o','t',0};
+	char windowName[] = {'r','o','o','t',0};
+
+	memset(&si, 0, sizeof(si));
+	si.cb = sizeof(si);
+	CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+
+	/*Checks if the window has been created*/	
+	if (check_window_exists(windowName)) {
+	
+		return TRUE;
+
+	}
+	return FALSE;
+}
+
+START_TEST(explorer)
+{
+	init_strings();
+
+	ok(explorer_available() == TRUE, "explorer is not avaible \n");
+	trace("\n  Test Done \n ");
+
+}
-- 
2.7.4




More information about the wine-devel mailing list