Ge van Geldorp : mapi32/tests: Skip tests if no default email client is installed.
Alexandre Julliard
julliard at winehq.org
Wed Oct 7 09:46:05 CDT 2009
Module: wine
Branch: master
Commit: 61c69e55e4ba2ce7b6d1056b2669fef5cfd4b361
URL: http://source.winehq.org/git/wine.git/?a=commit;h=61c69e55e4ba2ce7b6d1056b2669fef5cfd4b361
Author: Ge van Geldorp <ggeldorp at vmware.com>
Date: Mon Sep 17 00:00:00 2001 +0200
mapi32/tests: Skip tests if no default email client is installed.
---
dlls/mapi32/tests/Makefile.in | 2 +-
dlls/mapi32/tests/imalloc.c | 7 ++++
dlls/mapi32/tests/mapi32_test.h | 62 +++++++++++++++++++++++++++++++++++++++
dlls/mapi32/tests/prop.c | 7 ++++
dlls/mapi32/tests/util.c | 7 ++++
5 files changed, 84 insertions(+), 1 deletions(-)
diff --git a/dlls/mapi32/tests/Makefile.in b/dlls/mapi32/tests/Makefile.in
index 6c4482e..bd3c1a1 100644
--- a/dlls/mapi32/tests/Makefile.in
+++ b/dlls/mapi32/tests/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@
VPATH = @srcdir@
TESTDLL = mapi32.dll
-IMPORTS = kernel32
+IMPORTS = advapi32 kernel32
CTESTS = \
imalloc.c \
diff --git a/dlls/mapi32/tests/imalloc.c b/dlls/mapi32/tests/imalloc.c
index ec7557b..485180c 100644
--- a/dlls/mapi32/tests/imalloc.c
+++ b/dlls/mapi32/tests/imalloc.c
@@ -26,6 +26,7 @@
#include "winerror.h"
#include "winnt.h"
#include "mapiutil.h"
+#include "mapi32_test.h"
static HMODULE hMapi32 = 0;
@@ -88,6 +89,12 @@ START_TEST(imalloc)
{
SCODE ret;
+ if (!HaveDefaultMailClient())
+ {
+ win_skip("No default mail client installed\n");
+ return;
+ }
+
hMapi32 = LoadLibraryA("mapi32.dll");
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil at 4");
diff --git a/dlls/mapi32/tests/mapi32_test.h b/dlls/mapi32/tests/mapi32_test.h
new file mode 100644
index 0000000..5002dbc
--- /dev/null
+++ b/dlls/mapi32/tests/mapi32_test.h
@@ -0,0 +1,62 @@
+/*
+ * 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
+ */
+
+/*
+ * Return FALSE if no default mail client is installed.
+ */
+static BOOL HaveDefaultMailClient(void)
+{
+ HKEY Key;
+ DWORD Type, Size;
+ BYTE Buffer[64];
+ BOOL HasHKCUKey;
+
+ /* We check the default value of both HKCU\Software\Clients\Mail and
+ * HKLM\Software\Clients\Mail, if one of them is present there is a default
+ * mail client. If neither of these keys is present, we might be running
+ * on an old Windows version (W95, NT4) and we assume a default mail client
+ * might be available. Only if one of the keys is present, but there is
+ * no default value do we assume there is no default client. */
+ if (RegOpenKeyExA(HKEY_CURRENT_USER, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS)
+ {
+ Size = sizeof(Buffer);
+ /* Any return value besides ERROR_FILE_NOT_FOUND (including success,
+ ERROR_MORE_DATA) indicates the value is present */
+ if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND)
+ {
+ RegCloseKey(Key);
+ return TRUE;
+ }
+ RegCloseKey(Key);
+ HasHKCUKey = TRUE;
+ }
+ else
+ HasHKCUKey = FALSE;
+
+ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Clients\\Mail", 0, KEY_QUERY_VALUE, &Key) == ERROR_SUCCESS)
+ {
+ Size = sizeof(Buffer);
+ if (RegQueryValueExA(Key, NULL, NULL, &Type, Buffer, &Size) != ERROR_FILE_NOT_FOUND)
+ {
+ RegCloseKey(Key);
+ return TRUE;
+ }
+ RegCloseKey(Key);
+ return FALSE;
+ }
+
+ return ! HasHKCUKey;
+}
diff --git a/dlls/mapi32/tests/prop.c b/dlls/mapi32/tests/prop.c
index 8f4ff1e..237134b 100644
--- a/dlls/mapi32/tests/prop.c
+++ b/dlls/mapi32/tests/prop.c
@@ -27,6 +27,7 @@
#include "initguid.h"
#include "mapiutil.h"
#include "mapitags.h"
+#include "mapi32_test.h"
static HMODULE hMapi32 = 0;
@@ -1360,6 +1361,12 @@ START_TEST(prop)
{
SCODE ret;
+ if (!HaveDefaultMailClient())
+ {
+ win_skip("No default mail client installed\n");
+ return;
+ }
+
if(!InitFuncPtrs())
{
win_skip("Needed functions are not available\n");
diff --git a/dlls/mapi32/tests/util.c b/dlls/mapi32/tests/util.c
index af4fc57..feb2c6d 100644
--- a/dlls/mapi32/tests/util.c
+++ b/dlls/mapi32/tests/util.c
@@ -26,6 +26,7 @@
#include "winnt.h"
#include "mapiutil.h"
#include "mapitags.h"
+#include "mapi32_test.h"
static HMODULE hMapi32 = 0;
@@ -172,6 +173,12 @@ START_TEST(util)
{
SCODE ret;
+ if (!HaveDefaultMailClient())
+ {
+ win_skip("No default mail client installed\n");
+ return;
+ }
+
hMapi32 = LoadLibraryA("mapi32.dll");
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil at 4");
More information about the wine-cvs
mailing list