diff --git a/dlls/shlwapi/tests/istream.c b/dlls/shlwapi/tests/istream.c index 5b37991c75..527fa2416f 100644 --- a/dlls/shlwapi/tests/istream.c +++ b/dlls/shlwapi/tests/istream.c @@ -185,51 +185,51 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode) } -static void test_SHCreateStreamOnFileA(DWORD mode) +static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm) { IStream * stream; HRESULT ret; ULONG refcount; static const char * test_file = "c:\\test.txt"; - trace("SHCreateStreamOnFileA: testing mode %d\n", mode); + trace("SHCreateStreamOnFileA: testing mode %d, STGM flags %08x\n", mode, stgm); /* invalid arguments */ stream = NULL; - ret = (*pSHCreateStreamOnFileA)(NULL, mode, &stream); + ret = (*pSHCreateStreamOnFileA)(NULL, mode | stgm, &stream); ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "SHCreateStreamOnFileA: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream); #if 0 /* This test crashes on WinXP SP2 */ - ret = (*pSHCreateStreamOnFileA)(test_file, mode, NULL); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | stgm, NULL); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret); #endif stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CONVERT, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CONVERT | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_DELETEONRELEASE, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_TRANSACTED, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_TRANSACTED | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream); /* file does not exist */ stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream); ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "SHCreateStreamOnFileA: expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n"); @@ -245,7 +245,7 @@ static void test_SHCreateStreamOnFileA(DWORD mode) /* file exists */ stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n"); @@ -257,7 +257,7 @@ static void test_SHCreateStreamOnFileA(DWORD mode) } stream = NULL; - ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE, &stream); + ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n"); @@ -272,53 +272,53 @@ static void test_SHCreateStreamOnFileA(DWORD mode) } -static void test_SHCreateStreamOnFileW(DWORD mode) +static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm) { IStream * stream; HRESULT ret; ULONG refcount; static const WCHAR test_file[] = { 'c', ':', '\\', 't', 'e', 's', 't', '.', 't', 'x', 't', '\0' }; - trace("SHCreateStreamOnFileW: testing mode %d\n", mode); + trace("SHCreateStreamOnFileW: testing mode %d, STGM flags %08x\n", mode, stgm); /* invalid arguments */ stream = NULL; - ret = (*pSHCreateStreamOnFileW)(NULL, mode, &stream); + ret = (*pSHCreateStreamOnFileW)(NULL, mode | stgm, &stream); ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* XP */ ret == E_INVALIDARG /* Vista */, "SHCreateStreamOnFileW: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) or E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream); #if 0 /* This test crashes on WinXP SP2 */ - ret = (*pSHCreateStreamOnFileW)(test_file, mode, NULL); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | stgm, NULL); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret); #endif stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CONVERT, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CONVERT | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_DELETEONRELEASE, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_TRANSACTED, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_TRANSACTED | stgm, &stream); ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream); /* file does not exist */ stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream); ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "SHCreateStreamOnFileW: expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got 0x%08x\n", ret); ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream); stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n"); @@ -334,7 +334,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode) /* file exists */ stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n"); @@ -346,7 +346,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode) } stream = NULL; - ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE, &stream); + ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE | stgm, &stream); ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret); ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n"); @@ -504,6 +504,14 @@ START_TEST(istream) STGM_READWRITE }; + static const DWORD stgm_sharing[] = { + 0, + STGM_SHARE_DENY_NONE, + STGM_SHARE_DENY_READ, + STGM_SHARE_DENY_WRITE, + STGM_SHARE_EXCLUSIVE + }; + static const DWORD stgm_flags[] = { 0, STGM_CONVERT, @@ -514,7 +522,7 @@ START_TEST(istream) STGM_TRANSACTED | STGM_CONVERT | STGM_DELETEONRELEASE }; - int i, j; + int i, j, k; hShlwapi = GetModuleHandleA("shlwapi.dll"); @@ -532,15 +540,17 @@ START_TEST(istream) skip("SHCreateStreamOnFileEx not found.\n"); for (i = 0; i != sizeof(stgm_access)/sizeof(stgm_access[0]); i++) { - if (pSHCreateStreamOnFileA) - test_SHCreateStreamOnFileA(stgm_access[i]); + for (j = 0; j != sizeof(stgm_sharing)/sizeof(stgm_sharing[0]); j ++) { + if (pSHCreateStreamOnFileA) + test_SHCreateStreamOnFileA(stgm_access[i], stgm_sharing[j]); - if (pSHCreateStreamOnFileW) - test_SHCreateStreamOnFileW(stgm_access[i]); + if (pSHCreateStreamOnFileW) + test_SHCreateStreamOnFileW(stgm_access[i], stgm_sharing[j]); - if (pSHCreateStreamOnFileEx) { - for (j = 0; j != sizeof(stgm_flags)/sizeof(stgm_flags[0]); j++) - test_SHCreateStreamOnFileEx(stgm_access[i], stgm_flags[j]); + if (pSHCreateStreamOnFileEx) { + for (k = 0; k != sizeof(stgm_flags)/sizeof(stgm_flags[0]); k++) + test_SHCreateStreamOnFileEx(stgm_access[i], stgm_sharing[j] | stgm_flags[k]); + } } } }