Commit 61c69e55 authored by Ge van Geldorp's avatar Ge van Geldorp Committed by Alexandre Julliard

mapi32/tests: Skip tests if no default email client is installed.

parent 8eada56b
...@@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. ...@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR = @srcdir@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
TESTDLL = mapi32.dll TESTDLL = mapi32.dll
IMPORTS = kernel32 IMPORTS = advapi32 kernel32
CTESTS = \ CTESTS = \
imalloc.c \ imalloc.c \
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "winerror.h" #include "winerror.h"
#include "winnt.h" #include "winnt.h"
#include "mapiutil.h" #include "mapiutil.h"
#include "mapi32_test.h"
static HMODULE hMapi32 = 0; static HMODULE hMapi32 = 0;
...@@ -88,6 +89,12 @@ START_TEST(imalloc) ...@@ -88,6 +89,12 @@ START_TEST(imalloc)
{ {
SCODE ret; SCODE ret;
if (!HaveDefaultMailClient())
{
win_skip("No default mail client installed\n");
return;
}
hMapi32 = LoadLibraryA("mapi32.dll"); hMapi32 = LoadLibraryA("mapi32.dll");
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
......
/*
* 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;
}
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "initguid.h" #include "initguid.h"
#include "mapiutil.h" #include "mapiutil.h"
#include "mapitags.h" #include "mapitags.h"
#include "mapi32_test.h"
static HMODULE hMapi32 = 0; static HMODULE hMapi32 = 0;
...@@ -1360,6 +1361,12 @@ START_TEST(prop) ...@@ -1360,6 +1361,12 @@ START_TEST(prop)
{ {
SCODE ret; SCODE ret;
if (!HaveDefaultMailClient())
{
win_skip("No default mail client installed\n");
return;
}
if(!InitFuncPtrs()) if(!InitFuncPtrs())
{ {
win_skip("Needed functions are not available\n"); win_skip("Needed functions are not available\n");
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "winnt.h" #include "winnt.h"
#include "mapiutil.h" #include "mapiutil.h"
#include "mapitags.h" #include "mapitags.h"
#include "mapi32_test.h"
static HMODULE hMapi32 = 0; static HMODULE hMapi32 = 0;
...@@ -172,6 +173,12 @@ START_TEST(util) ...@@ -172,6 +173,12 @@ START_TEST(util)
{ {
SCODE ret; SCODE ret;
if (!HaveDefaultMailClient())
{
win_skip("No default mail client installed\n");
return;
}
hMapi32 = LoadLibraryA("mapi32.dll"); hMapi32 = LoadLibraryA("mapi32.dll");
pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4"); pScInitMapiUtil = (void*)GetProcAddress(hMapi32, "ScInitMapiUtil@4");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment