Reverse the order for deleting the items in resetcontent to correctly
[wine] / dlls / oleaut32 / tests / typelib.c
1 /*
2  * ITypeLib and ITypeInfo test
3  *
4  * Copyright 2004 Jacek Caban
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #define COBJMACROS
22
23 #include <wine/test.h>
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "oleauto.h"
29
30 void ref_count_test(LPCWSTR type_lib)
31 {
32     ITypeLib *iface;
33     ITypeInfo *iti1, *iti2;
34     HRESULT hRes;
35     int ref_count;
36
37     trace("Loading type library\n");
38     hRes = LoadTypeLib(type_lib, &iface);
39     ok(hRes == S_OK, "Could not load type library\n");
40     if(hRes != S_OK)
41         return;
42
43     hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
44     ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
45     ok(ref_count=ITypeLib_Release(iface) > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
46     if(!ref_count)
47         return;
48
49     hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
50     ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
51     ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
52
53     ITypeLib_AddRef(iface);
54     ITypeInfo_Release(iti2);
55     ITypeInfo_Release(iti1);
56     ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
57 }
58
59 START_TEST(typelib)
60 {
61     static const WCHAR type_lib_olepro32[] = {'o','l','e','p','r','o','3','2','.','d','l','l',0};
62     static const WCHAR type_lib_stdole32[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
63
64     ref_count_test(type_lib_olepro32);
65     ref_count_test(type_lib_stdole32);
66 }