Alistair Leslie-Hughes : shlwapi: Correct AssocCreate and tests.
Alexandre Julliard
julliard at winehq.org
Tue Aug 4 12:25:23 CDT 2009
Module: wine
Branch: master
Commit: ffd2e69f5327439d0c27d6cff6b49ff13c4a6b0a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ffd2e69f5327439d0c27d6cff6b49ff13c4a6b0a
Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Thu Jul 30 11:30:22 2009 +1000
shlwapi: Correct AssocCreate and tests.
---
dlls/shlwapi/assoc.c | 11 ++++++++---
dlls/shlwapi/tests/assoc.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/dlls/shlwapi/assoc.c b/dlls/shlwapi/assoc.c
index d13f0aa..d6c4107 100644
--- a/dlls/shlwapi/assoc.c
+++ b/dlls/shlwapi/assoc.c
@@ -134,7 +134,8 @@ static BOOL SHLWAPI_ParamAToW(LPCSTR lpszParam, LPWSTR lpszBuff, DWORD dwLen,
* Failure: An HRESULT error code indicating the error.
*
* NOTES
- * refiid must be equal to IID_IQueryAssociations, or this function will fail.
+ * clsid must be equal to CLSID_QueryAssociations and
+ * refiid must be equal to IID_IQueryAssociations, IID_IUnknown or this function will fail
*/
HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
{
@@ -149,8 +150,8 @@ HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
*(DWORD*)lpInterface = 0;
- if (!IsEqualGUID(&clsid, &IID_IQueryAssociations))
- return E_NOTIMPL;
+ if (!IsEqualGUID(&clsid, &CLSID_QueryAssociations))
+ return CLASS_E_CLASSNOTAVAILABLE;
lpAssoc = IQueryAssociations_Constructor();
@@ -159,6 +160,10 @@ HRESULT WINAPI AssocCreate(CLSID clsid, REFIID refiid, void **lpInterface)
hRet = IQueryAssociations_QueryInterface(lpAssoc, refiid, lpInterface);
IQueryAssociations_Release(lpAssoc);
+
+ if(hRet == E_NOINTERFACE)
+ return CLASS_E_CLASSNOTAVAILABLE;
+
return hRet;
}
diff --git a/dlls/shlwapi/tests/assoc.c b/dlls/shlwapi/tests/assoc.c
index 3799ecc..fd2b868 100644
--- a/dlls/shlwapi/tests/assoc.c
+++ b/dlls/shlwapi/tests/assoc.c
@@ -21,12 +21,14 @@
#include "wine/test.h"
#include "shlwapi.h"
+#include "shlguid.h"
#define expect(expected, got) ok ( expected == got, "Expected %d, got %d\n", expected, got)
#define expect_hr(expected, got) ok ( expected == got, "Expected %08x, got %08x\n", expected, got)
static HRESULT (WINAPI *pAssocQueryStringA)(ASSOCF,ASSOCSTR,LPCSTR,LPCSTR,LPSTR,LPDWORD) = NULL;
static HRESULT (WINAPI *pAssocQueryStringW)(ASSOCF,ASSOCSTR,LPCWSTR,LPCWSTR,LPWSTR,LPDWORD) = NULL;
+static HRESULT (WINAPI *pAssocCreate)(CLSID, REFIID, void **) = NULL;
/* Every version of Windows with IE should have this association? */
static const WCHAR dotHtml[] = { '.','h','t','m','l',0 };
@@ -235,14 +237,55 @@ cleanup:
}
+static void test_assoc_create(void)
+{
+ HRESULT hr;
+ IQueryAssociations *pqa;
+
+ if (!pAssocCreate)
+ {
+ win_skip("AssocCreate() is missing\n");
+ return;
+ }
+
+ hr = pAssocCreate(IID_NULL, &IID_NULL, NULL);
+ ok(hr == E_INVALIDARG, "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(CLSID_QueryAssociations, &IID_NULL, (LPVOID*)&pqa);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(IID_NULL, &IID_IQueryAssociations, (LPVOID*)&pqa);
+ ok(hr == CLASS_E_CLASSNOTAVAILABLE || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+
+ hr = pAssocCreate(CLSID_QueryAssociations, &IID_IQueryAssociations, (LPVOID*)&pqa);
+ ok(hr == S_OK || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+ if(hr == S_OK)
+ {
+ IQueryAssociations_Release(pqa);
+ }
+
+ hr = pAssocCreate(CLSID_QueryAssociations, &IID_IUnknown, (LPVOID*)&pqa);
+ ok(hr == S_OK || hr == E_NOTIMPL /* win98 */
+ , "Unexpected result : %08x\n", hr);
+ if(hr == S_OK)
+ {
+ IQueryAssociations_Release(pqa);
+ }
+}
+
START_TEST(assoc)
{
HMODULE hshlwapi;
hshlwapi = GetModuleHandleA("shlwapi.dll");
pAssocQueryStringA = (void*)GetProcAddress(hshlwapi, "AssocQueryStringA");
pAssocQueryStringW = (void*)GetProcAddress(hshlwapi, "AssocQueryStringW");
+ pAssocCreate = (void*)GetProcAddress(hshlwapi, "AssocCreate");
test_getstring_bad();
test_getstring_basic();
test_getstring_no_extra();
+ test_assoc_create();
}
More information about the wine-cvs
mailing list