ReactOS  0.4.13-dev-982-g9853eab
format.c File Reference
#include <stdio.h>
#include <windows.h>
#include <shlwapi.h>
#include <msi.h>
#include <msiquery.h>
#include "wine/test.h"
Include dependency graph for format.c:

Go to the source code of this file.

Functions

static UINT package_from_db (MSIHANDLE hdb, MSIHANDLE *handle)
 
static UINT helper_createpackage (const char *szName, MSIHANDLE *handle)
 
static void test_createpackage (void)
 
static void test_formatrecord (void)
 

Variables

static const char msifile [] = "winetest-format.msi"
 

Function Documentation

◆ helper_createpackage()

static UINT helper_createpackage ( const char szName,
MSIHANDLE handle 
)
static

Definition at line 54 of file format.c.

55 {
56  MSIHANDLE hPackage, suminfo, hdb = 0;
57  UINT res;
58  WCHAR *nameW;
59  int len;
60 
62 
63  len = MultiByteToWideChar( CP_ACP, 0, szName, -1, NULL, 0 );
64  if (!(nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
65  return ERROR_OUTOFMEMORY;
67 
68  /* create an empty database */
70  HeapFree( GetProcessHeap(), 0, nameW );
71  ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
72  if (res != ERROR_SUCCESS)
73  return res;
74 
75  res = MsiDatabaseCommit( hdb );
76  ok( res == ERROR_SUCCESS , "Failed to commit database %u\n", res );
77 
78  /* build summary info */
80  ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
81 
83  "Installation Database");
84  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
85 
87  "Installation Database");
88  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
89 
91  "Wine Hackers");
92  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
93 
95  ";1033");
96  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
97 
99  "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
100  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
101 
103  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
104 
106  ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
107 
109  ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
110 
112  ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
113 
114  res = package_from_db( hdb, &hPackage );
115  MsiCloseHandle(hdb);
116 
117  if (res != ERROR_SUCCESS)
118  DeleteFileA( szName );
119  else
120  *handle = hPackage;
121 
122  return res;
123 }
static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
Definition: format.c:32
Definition: compat.h:1939
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CP_ACP
Definition: compat.h:99
unsigned long MSIHANDLE
Definition: msiserver.idl:25
static const CHAR suminfo[]
Definition: db.c:2211
UINT WINAPI MsiSummaryInfoSetPropertyA(MSIHANDLE handle, UINT uiProperty, UINT uiDataType, INT iValue, FILETIME *pftValue, LPCSTR szValue)
Definition: suminfo.c:863
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
static const WCHAR nameW[]
Definition: main.c:46
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MSIDBOPEN_CREATEDIRECT
Definition: msiquery.h:70
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
Definition: suminfo.c:586
GLenum GLsizei len
Definition: glext.h:6722
Ulong res
Definition: format.c:278
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:813
#define ok(value,...)
Definition: atltest.h:57
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:303
unsigned int UINT
Definition: ndis.h:50
#define MultiByteToWideChar
Definition: compat.h:100
UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE handle)
Definition: suminfo.c:1152
static const WCHAR szName[]
Definition: msipriv.h:1194
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by test_createpackage().

◆ package_from_db()

static UINT package_from_db ( MSIHANDLE  hdb,
MSIHANDLE handle 
)
static

Definition at line 32 of file format.c.

33 {
34  UINT res;
35  CHAR szPackage[12];
36  MSIHANDLE hPackage;
37 
38  sprintf(szPackage, "#%u", hdb);
39  res = MsiOpenPackageA(szPackage, &hPackage);
40  if (res != ERROR_SUCCESS)
41  return res;
42 
43  res = MsiCloseHandle(hdb);
44  if (res != ERROR_SUCCESS)
45  {
46  MsiCloseHandle(hPackage);
47  return res;
48  }
49 
50  *handle = hPackage;
51  return ERROR_SUCCESS;
52 }
UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
Definition: package.c:1687
#define ERROR_SUCCESS
Definition: deptool.c:10
char CHAR
Definition: xmlstorage.h:175
unsigned long MSIHANDLE
Definition: msiserver.idl:25
#define sprintf(buf, format,...)
Definition: sprintf.c:55
Ulong res
Definition: format.c:278
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
unsigned int UINT
Definition: ndis.h:50
GLuint res
Definition: glext.h:9613

Referenced by helper_createpackage().

◆ test_createpackage()

static void test_createpackage ( void  )
static

Definition at line 125 of file format.c.

126 {
127  MSIHANDLE hPackage = 0;
128  UINT res;
129 
130  res = helper_createpackage( msifile, &hPackage );
132  {
133  skip("Not enough rights to perform tests\n");
134  return;
135  }
136  ok( res == ERROR_SUCCESS, "Failed to create package %u\n", res );
137 
138  res = MsiCloseHandle( hPackage );
139  ok( res == ERROR_SUCCESS , "Failed to close package %u\n", res );
140 
141  DeleteFileA( msifile );
142 }
static const char msifile[]
Definition: format.c:30
#define ERROR_INSTALL_PACKAGE_REJECTED
Definition: winerror.h:983
#define ERROR_SUCCESS
Definition: deptool.c:10
unsigned long MSIHANDLE
Definition: msiserver.idl:25
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Ulong res
Definition: format.c:278
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:270
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
static UINT helper_createpackage(const char *szName, MSIHANDLE *handle)
Definition: format.c:54

◆ test_formatrecord()

static void test_formatrecord ( void  )
static

Definition at line 144 of file format.c.

Variable Documentation

◆ msifile

const char msifile[] = "winetest-format.msi"
static

Definition at line 30 of file format.c.

Referenced by test_createpackage().