Skip to content

Commit 45a3a9f

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi/tests: Test registration of a valid typelib.
Signed-off-by: Zebediah Figura <[email protected]> Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id f5da1902aa24433375fc3c99eaadad00917daa9f by Zebediah Figura <[email protected]>
1 parent b493df6 commit 45a3a9f

File tree

4 files changed

+84
-11
lines changed

4 files changed

+84
-11
lines changed

modules/rostests/winetests/msi/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,26 @@ list(APPEND SOURCE
1616
patch.c
1717
record.c
1818
source.c
19-
suminfo.c)
19+
suminfo.c
20+
typelib.idl)
2021

2122
list(APPEND PCH_SKIP_SOURCE
23+
${CMAKE_CURRENT_BINARY_DIR}/typelib_i.c
2224
testlist.c)
2325

2426
# CMake 3.9 and higher requires to specify this dependency manually
2527
# see https://gitlab.kitware.com/cmake/cmake/issues/19933
26-
set_property(SOURCE msi_winetest.rc PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom.dll)
28+
set_property(SOURCE msi_winetest.rc PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom.dll ${CMAKE_CURRENT_BINARY_DIR}/typelib.tlb)
2729

2830
add_executable(msi_winetest
2931
${SOURCE}
3032
${PCH_SKIP_SOURCE}
3133
msi_winetest.rc)
3234

35+
add_idl_headers(msi_winetest_idlheader typelib.idl)
36+
generate_idl_iids(typelib.idl)
37+
add_typelib(typelib.idl)
38+
3339
target_compile_definitions(msi_winetest PRIVATE __WINESRC__ USE_WINE_TODOS)
3440

3541
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
@@ -46,4 +52,4 @@ set_module_type(msi_winetest win32cui)
4652
add_importlibs(msi_winetest cabinet msi shell32 ole32 oleaut32 odbccp32 user32 advapi32 version msvcrt kernel32)
4753
add_pch(msi_winetest precomp.h "${PCH_SKIP_SOURCE}")
4854
add_rostests_file(TARGET msi_winetest)
49-
add_dependencies(msi_winetest custom)
55+
add_dependencies(msi_winetest custom msi_winetest_idlheader stdole2)

modules/rostests/winetests/msi/action.c

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <stdio.h>
2424
#include <stdlib.h>
2525

26+
#define COBJMACROS
2627
#include <windows.h>
2728
#include <msiquery.h>
2829
#include <msidefs.h>
@@ -33,9 +34,13 @@
3334
#include <shellapi.h>
3435
#include <winsvc.h>
3536
#include <odbcinst.h>
37+
#ifdef __REACTOS__
38+
#include <oleauto.h>
39+
#endif
3640

3741
#include "wine/test.h"
3842
#include "utils.h"
43+
#include "typelib.h"
3944

4045
static UINT (WINAPI *pMsiQueryComponentStateA)
4146
(LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPCSTR, INSTALLSTATE *);
@@ -1003,10 +1008,10 @@ static const char tl_install_exec_seq_dat[] =
10031008
"InstallValidate\t\t1400\n"
10041009
"InstallInitialize\t\t1500\n"
10051010
"ProcessComponents\t\t1600\n"
1006-
"RemoveFiles\t\t1700\n"
1007-
"InstallFiles\t\t2000\n"
1008-
"RegisterTypeLibraries\tREGISTER_TYPELIB=1\t3000\n"
10091011
"UnregisterTypeLibraries\t\t3100\n"
1012+
"RemoveFiles\t\t3200\n"
1013+
"InstallFiles\t\t3300\n"
1014+
"RegisterTypeLibraries\t\t3400\n"
10101015
"RegisterProduct\t\t5100\n"
10111016
"PublishFeatures\t\t5200\n"
10121017
"PublishProduct\t\t5300\n"
@@ -2647,6 +2652,24 @@ static DWORD get_estimated_size(void)
26472652
return size;
26482653
}
26492654

2655+
static void extract_resource(const char *name, const char *type, const char *path)
2656+
{
2657+
DWORD written;
2658+
HANDLE file;
2659+
HRSRC res;
2660+
void *ptr;
2661+
2662+
file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
2663+
ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError());
2664+
2665+
res = FindResourceA(NULL, name, type);
2666+
ok( res != 0, "couldn't find resource\n" );
2667+
ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
2668+
WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
2669+
ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
2670+
CloseHandle( file );
2671+
}
2672+
26502673
static void test_register_product(void)
26512674
{
26522675
UINT r;
@@ -5594,6 +5617,8 @@ static void test_install_remove_odbc(void)
55945617

55955618
static void test_register_typelib(void)
55965619
{
5620+
ITypeLib *tlb;
5621+
HRESULT hr;
55975622
UINT r;
55985623

55995624
if (is_process_limited())
@@ -5602,26 +5627,37 @@ static void test_register_typelib(void)
56025627
return;
56035628
}
56045629

5630+
/* UnregisterTypeLibraries action fails in 64-bit Windows <= 7 */
5631+
if (sizeof(void *) == 8)
5632+
{
5633+
win_skip("broken on 64-bit Windows\n");
5634+
return;
5635+
}
5636+
56055637
create_test_files();
5606-
create_file("msitest\\typelib.dll", 1000);
5638+
extract_resource("typelib.tlb", "TYPELIB", "msitest\\typelib.dll");
56075639
create_database(msifile, tl_tables, sizeof(tl_tables) / sizeof(msi_table));
56085640

56095641
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
56105642

5611-
r = MsiInstallProductA(msifile, "REGISTER_TYPELIB=1");
5643+
r = MsiInstallProductA(msifile, NULL);
56125644
if (r == ERROR_INSTALL_PACKAGE_REJECTED)
56135645
{
56145646
skip("Not enough rights to perform tests\n");
56155647
goto error;
56165648
}
5617-
ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
5649+
ok(r == ERROR_SUCCESS, "got %u\n", r);
56185650

5619-
r = MsiInstallProductA(msifile, NULL);
5620-
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
5651+
hr = LoadRegTypeLib(&LIBID_register_test, 7, 1, 0, &tlb);
5652+
ok(hr == S_OK, "got %#x\n", hr);
5653+
ITypeLib_Release(tlb);
56215654

56225655
r = MsiInstallProductA(msifile, "REMOVE=ALL");
56235656
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
56245657

5658+
hr = LoadRegTypeLib(&LIBID_register_test, 7, 1, 0, &tlb);
5659+
ok(hr == TYPE_E_LIBNOTREGISTERED, "got %#x\n", hr);
5660+
56255661
ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n");
56265662
ok(!delete_pf("msitest", FALSE), "directory not removed\n");
56275663

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11

22
CUSTOM.DLL TESTDLL "custom.dll"
3+
4+
typelib.tlb TYPELIB "typelib.tlb"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2018 Zebediah Figura
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2.1 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17+
*/
18+
19+
#pragma makedep ident
20+
#pragma makedep typelib
21+
#pragma makedep header
22+
23+
[
24+
uuid(eac5166a-9734-4d91-878f-1dd02304c66c),
25+
version(7.1)
26+
]
27+
library register_test
28+
{
29+
}

0 commit comments

Comments
 (0)