From: Guillaume Charifi Subject: [1/3] oleaut32: Add test for TLB dependencies lookup in resources (try 3) Message-Id: <25833014.951689.1407767268356.JavaMail.www@wsfrf1213> Date: Mon, 21 Jul 2014 23:23:40 +0200 (CEST) --- dlls/oleaut32/tests/Makefile.in  |  1 + dlls/oleaut32/tests/test_dep.idl | 44 ++++++++++++++++++++++++++++++++++++++++++++ dlls/oleaut32/tests/tmarshal.rc  |  3 +++ dlls/oleaut32/tests/typelib.c    | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/dlls/oleaut32/tests/Makefile.in b/dlls/oleaut32/tests/Makefile.in index 036c63d..227f0e4 100644 --- a/dlls/oleaut32/tests/Makefile.in +++ b/dlls/oleaut32/tests/Makefile.in @@ -16,6 +16,7 @@ C_SRCS = \ RC_SRCS = tmarshal.rc IDL_SRCS = \ + test_dep.idl \ test_reg.idl \ test_tlb.idl \ tmarshal.idl diff --git a/dlls/oleaut32/tests/test_dep.idl b/dlls/oleaut32/tests/test_dep.idl new file mode 100644 index 0000000..050e96e --- /dev/null +++ b/dlls/oleaut32/tests/test_dep.idl @@ -0,0 +1,44 @@ +/* + * ITypeLib dependency test + * + * Copyright 2014 Guillaume Charifi + * + * 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 + */ + +#pragma makedep ident +#pragma makedep typelib + +import "oaidl.idl"; /* needed by widl */ +import "test_tlb.idl"; + +[ + uuid(e0228f26-2946-478c-b64a-93feefa50532), + version(0.0), +] +library TestDep +{ + importlib("stdole2.tlb"); + importlib("test_tlb.tlb"); + + [ + odl, + uuid(394376dd-3bb8-4804-8ccc-9559434004f3) + ] + interface ITestDep : ISimpleIface + { + HRESULT test(); + } +} diff --git a/dlls/oleaut32/tests/tmarshal.rc b/dlls/oleaut32/tests/tmarshal.rc index cbb3b18..84ce487 100644 --- a/dlls/oleaut32/tests/tmarshal.rc +++ b/dlls/oleaut32/tests/tmarshal.rc @@ -35,3 +35,6 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: test_reg.tlb */ 3 TYPELIB test_reg.tlb + +/* @makedep: test_dep.tlb */ +4 TYPELIB test_dep.tlb diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 49057a4..0091c1e 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -36,6 +36,7 @@ #include "test_reg.h" #include "test_tlb.h" +#include "test_dep.h" #define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); } #define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d") @@ -5509,6 +5510,64 @@ static void test_stub(void) CoUninitialize(); } +static void test_dep(void) { + HRESULT hr; + const char *filenameA; + WCHAR filenameW[MAX_PATH]; + ITypeLib *ptLib = NULL; + ITypeInfo *ptInfo = NULL; + ITypeInfo *ptInfoExt = NULL; + HREFTYPE refType; + + static const char *testTLBName = "test_tlb.tlb"; + static const WCHAR testTLBNameW[] = {'t','e','s','t','_','t','l','b','.','t','l','b',0}; + static const char *testTLBTmpName = "test_tlb.tlb.tmp"; + + trace("Starting typelib dependency tests\n"); + + hr = GetFileAttributesA(testTLBTmpName); + if(hr != INVALID_FILE_ATTRIBUTES) { + hr = DeleteFileA(testTLBTmpName); + ok(hr, "Stale %s could not be removed\n", testTLBTmpName); + } + + hr = GetFileAttributesA(testTLBName); + if(hr != INVALID_FILE_ATTRIBUTES) { + hr = MoveFileA(testTLBName, testTLBTmpName); + ok(hr, "%s could not be moved out of the way\n", testTLBName); + } + + hr = LoadTypeLibEx(testTLBNameW, REGKIND_NONE, &ptLib); + ok(hr != S_OK, "%s should not be loadable at this point\n", testTLBName); + + filenameA = create_test_typelib(4); + MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH); + hr = LoadTypeLibEx(filenameW, REGKIND_NONE, &ptLib); + ok(hr == S_OK, "got: %x\n", hr); + + hr = ITypeLib_GetTypeInfoOfGuid(ptLib, &IID_ITestDep, &ptInfo); + ok(hr == S_OK, "got: %x\n", hr); + + hr = ITypeInfo_GetRefTypeOfImplType(ptInfo, 0, &refType); + ok(hr == S_OK, "got: %x\n", hr); + + hr = ITypeInfo_GetRefTypeInfo(ptInfo, refType, &ptInfoExt); + todo_wine ok(hr == S_OK || broken(hr == TYPE_E_CANTLOADLIBRARY) /* win 2000 */, "got: %x\n", hr); + + ITypeInfo_Release(ptInfo); + if(ptInfoExt) + ITypeInfo_Release(ptInfoExt); + ITypeLib_Release(ptLib); + + DeleteFileW(filenameW); + + hr = GetFileAttributesA(testTLBTmpName); + if(hr != INVALID_FILE_ATTRIBUTES) { + hr = MoveFileA(testTLBTmpName, testTLBName); + ok(hr, "%s could not be moved back\n", testTLBName); + } +} + START_TEST(typelib) { const char *filename; @@ -5548,4 +5607,5 @@ START_TEST(typelib) test_LoadRegTypeLib(); test_GetLibAttr(); test_stub(); + test_dep(); }