volume.c 4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Unit test suite
 *
 * Copyright 2006 Stefan Leichter
 *
 * 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
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20 21 22 23 24 25 26 27 28 29
 */

#include "wine/test.h"
#include "winbase.h"

#define CDROM   "CDROM"
#define FLOPPY  "FLOPPY"
#define HARDISK "HARDDISK"
#define LANMAN  "LANMANREDIRECTOR"
#define RAMDISK "RAMDISK"

30 31 32 33 34 35
static HINSTANCE hdll;
static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointA)(LPCSTR, LPSTR, DWORD);
static BOOL (WINAPI * pGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD);

/* ############################### */

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
static void test_query_dos_deviceA(void)
{
    char drivestr[] = "a:";
    char *p, buffer[2000];
    DWORD ret;
    for (;drivestr[0] <= 'z'; drivestr[0]++) {
        ret = QueryDosDeviceA( drivestr, buffer, sizeof(buffer));
        if(ret) {
            for (p = buffer; *p; p++) *p = toupper(*p);
            todo_wine
            ok( strstr( buffer, CDROM)   || strstr( buffer, FLOPPY) ||
                strstr( buffer, HARDISK) || strstr( buffer, LANMAN) ||
                strstr( buffer, RAMDISK), "expect the string %s contains %s,%s,%s,%s or %s\n",
                buffer, CDROM, FLOPPY, HARDISK, LANMAN, RAMDISK);
        }
    }
}

54 55 56 57 58 59
static void test_GetVolumeNameForVolumeMountPointA(void)
{
    BOOL ret;
    char volume[MAX_PATH], path[] = "c:\\";
    DWORD len = sizeof(volume);

60 61 62 63 64 65 66
    /* not present before w2k */
    if (!pGetVolumeNameForVolumeMountPointA) {
        skip("GetVolumeNameForVolumeMountPointA not found\n");
        return;
    }

    ret = pGetVolumeNameForVolumeMountPointA(path, volume, 0);
67 68 69
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");

    if (0) { /* these crash on XP */
70
    ret = pGetVolumeNameForVolumeMountPointA(path, NULL, len);
71 72
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");

73
    ret = pGetVolumeNameForVolumeMountPointA(NULL, volume, len);
74 75 76
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
    }

77
    ret = pGetVolumeNameForVolumeMountPointA(path, volume, len);
78 79 80 81 82 83 84 85 86
    ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
}

static void test_GetVolumeNameForVolumeMountPointW(void)
{
    BOOL ret;
    WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
    DWORD len = sizeof(volume) / sizeof(WCHAR);

87 88 89 90 91 92 93
    /* not present before w2k */
    if (!pGetVolumeNameForVolumeMountPointW) {
        skip("GetVolumeNameForVolumeMountPointW not found\n");
        return;
    }

    ret = pGetVolumeNameForVolumeMountPointW(path, volume, 0);
94 95 96
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");

    if (0) { /* these crash on XP */
97
    ret = pGetVolumeNameForVolumeMountPointW(path, NULL, len);
98 99
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");

100
    ret = pGetVolumeNameForVolumeMountPointW(NULL, volume, len);
101 102 103
    ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
    }

104
    ret = pGetVolumeNameForVolumeMountPointW(path, volume, len);
105 106 107
    ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
}

108 109
START_TEST(volume)
{
110 111 112 113
    hdll = GetModuleHandleA("kernel32.dll");
    pGetVolumeNameForVolumeMountPointA = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointA");
    pGetVolumeNameForVolumeMountPointW = (void *) GetProcAddress(hdll, "GetVolumeNameForVolumeMountPointW");

114
    test_query_dos_deviceA();
115 116
    test_GetVolumeNameForVolumeMountPointA();
    test_GetVolumeNameForVolumeMountPointW();
117
}