Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
7787ca61
Commit
7787ca61
authored
Feb 27, 2006
by
James Hawkins
Committed by
Alexandre Julliard
Feb 28, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advpack: Add tests for the TranslateInfStringEx trio of functions and
fix the errors.
parent
790f4523
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
131 additions
and
3 deletions
+131
-3
advpack.c
dlls/advpack/advpack.c
+8
-2
advpack.c
dlls/advpack/tests/advpack.c
+123
-1
No files found.
dlls/advpack/advpack.c
View file @
7787ca61
...
@@ -123,6 +123,9 @@ HRESULT WINAPI CloseINFEngine(HINF hInf)
...
@@ -123,6 +123,9 @@ HRESULT WINAPI CloseINFEngine(HINF hInf)
{
{
TRACE
(
"(%p)
\n
"
,
hInf
);
TRACE
(
"(%p)
\n
"
,
hInf
);
if
(
!
hInf
)
return
E_INVALIDARG
;
SetupCloseInfFile
(
hInf
);
SetupCloseInfFile
(
hInf
);
return
S_OK
;
return
S_OK
;
}
}
...
@@ -270,7 +273,7 @@ HRESULT WINAPI OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection,
...
@@ -270,7 +273,7 @@ HRESULT WINAPI OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection,
TRACE
(
"(%p, %p, %ld, %p, %p)
\n
"
,
pszInfFilename
,
pszInstallSection
,
TRACE
(
"(%p, %p, %ld, %p, %p)
\n
"
,
pszInfFilename
,
pszInstallSection
,
dwFlags
,
phInf
,
pvReserved
);
dwFlags
,
phInf
,
pvReserved
);
if
(
!
phInf
)
if
(
!
p
szInfFilename
||
!
p
hInf
)
return
E_INVALIDARG
;
return
E_INVALIDARG
;
*
phInf
=
SetupOpenInfFileA
(
pszInfFilename
,
NULL
,
INF_STYLE_WIN4
,
NULL
);
*
phInf
=
SetupOpenInfFileA
(
pszInfFilename
,
NULL
,
INF_STYLE_WIN4
,
NULL
);
...
@@ -472,6 +475,9 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
...
@@ -472,6 +475,9 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
pszTranslateSection
,
pszTranslateKey
,
pszBuffer
,
dwBufferSize
,
pszTranslateSection
,
pszTranslateKey
,
pszBuffer
,
dwBufferSize
,
pdwRequiredSize
,
pvReserved
);
pdwRequiredSize
,
pvReserved
);
if
(
!
hInf
||
!
pszInfFilename
||
!
pszTranslateSection
||
!
pszTranslateKey
)
return
E_INVALIDARG
;
if
(
!
SetupGetLineTextA
(
NULL
,
hInf
,
pszTranslateSection
,
pszTranslateKey
,
if
(
!
SetupGetLineTextA
(
NULL
,
hInf
,
pszTranslateSection
,
pszTranslateKey
,
pszBuffer
,
dwBufferSize
,
pdwRequiredSize
))
pszBuffer
,
dwBufferSize
,
pdwRequiredSize
))
{
{
...
@@ -481,7 +487,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
...
@@ -481,7 +487,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
return
SPAPI_E_LINE_NOT_FOUND
;
return
SPAPI_E_LINE_NOT_FOUND
;
}
}
return
E_FAIL
;
return
S_OK
;
}
}
/***********************************************************************
/***********************************************************************
...
...
dlls/advpack/tests/advpack.c
View file @
7787ca61
...
@@ -28,9 +28,12 @@
...
@@ -28,9 +28,12 @@
#define TEST_STRING1 "\\Application Name"
#define TEST_STRING1 "\\Application Name"
#define TEST_STRING2 "%49001%\\Application Name"
#define TEST_STRING2 "%49001%\\Application Name"
static
HRESULT
(
WINAPI
*
pCloseINFEngine
)(
HINF
);
static
HRESULT
(
WINAPI
*
pDelNode
)(
LPCSTR
,
DWORD
);
static
HRESULT
(
WINAPI
*
pDelNode
)(
LPCSTR
,
DWORD
);
static
HRESULT
(
WINAPI
*
pGetVersionFromFile
)(
LPSTR
,
LPDWORD
,
LPDWORD
,
BOOL
);
static
HRESULT
(
WINAPI
*
pGetVersionFromFile
)(
LPSTR
,
LPDWORD
,
LPDWORD
,
BOOL
);
static
HRESULT
(
WINAPI
*
pOpenINFEngine
)(
PCSTR
,
PCSTR
,
DWORD
,
HINF
*
,
PVOID
);
static
HRESULT
(
WINAPI
*
pTranslateInfString
)(
LPSTR
,
LPSTR
,
LPSTR
,
LPSTR
,
LPSTR
,
DWORD
,
LPDWORD
,
LPVOID
);
static
HRESULT
(
WINAPI
*
pTranslateInfString
)(
LPSTR
,
LPSTR
,
LPSTR
,
LPSTR
,
LPSTR
,
DWORD
,
LPDWORD
,
LPVOID
);
static
HRESULT
(
WINAPI
*
pTranslateInfStringEx
)(
HINF
,
PCSTR
,
PCSTR
,
PCSTR
,
PSTR
,
DWORD
,
PDWORD
,
PVOID
);
static
BOOL
init_function_pointers
(
void
)
static
BOOL
init_function_pointers
(
void
)
{
{
...
@@ -39,11 +42,15 @@ static BOOL init_function_pointers(void)
...
@@ -39,11 +42,15 @@ static BOOL init_function_pointers(void)
if
(
!
hAdvPack
)
if
(
!
hAdvPack
)
return
FALSE
;
return
FALSE
;
pCloseINFEngine
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"CloseINFEngine"
);
pDelNode
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"DelNode"
);
pDelNode
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"DelNode"
);
pGetVersionFromFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"GetVersionFromFile"
);
pGetVersionFromFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"GetVersionFromFile"
);
pOpenINFEngine
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"OpenINFEngine"
);
pTranslateInfString
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"TranslateInfString"
);
pTranslateInfString
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"TranslateInfString"
);
pTranslateInfStringEx
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"TranslateInfStringEx"
);
if
(
!
pDelNode
||
!
pGetVersionFromFile
||
!
pTranslateInfString
)
if
(
!
pCloseINFEngine
||
!
pDelNode
||
!
pGetVersionFromFile
||
!
pOpenINFEngine
||
!
pTranslateInfString
)
return
FALSE
;
return
FALSE
;
return
TRUE
;
return
TRUE
;
...
@@ -271,6 +278,120 @@ static void translateinfstring_test()
...
@@ -271,6 +278,120 @@ static void translateinfstring_test()
DeleteFile
(
"c:
\\
test.inf"
);
DeleteFile
(
"c:
\\
test.inf"
);
}
}
static
void
translateinfstringex_test
(
void
)
{
HINF
hinf
;
HKEY
hkey
;
HRESULT
hr
;
char
buffer
[
MAX_PATH
];
char
progfiles
[
MAX_PATH
];
DWORD
size
=
MAX_PATH
;
create_inf_file
();
RegOpenKeyA
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Microsoft
\\
Windows
\\
CurrentVersion"
,
&
hkey
);
RegQueryValueExA
(
hkey
,
"ProgramFilesDir"
,
NULL
,
NULL
,
(
LPBYTE
)
progfiles
,
&
size
);
lstrcatA
(
progfiles
,
TEST_STRING1
);
/* need to see if there are any flags */
/* try a NULL filename */
hr
=
pOpenINFEngine
(
NULL
,
"Options.NTx86"
,
0
,
&
hinf
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* try an empty filename */
hr
=
pOpenINFEngine
(
""
,
"Options.NTx86"
,
0
,
&
hinf
,
NULL
);
ok
(
hr
==
HRESULT_FROM_WIN32
(
ERROR_FILE_NOT_FOUND
),
"Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %ld
\n
"
,
hr
);
/* try a NULL hinf */
hr
=
pOpenINFEngine
(
"c:
\\
test.inf"
,
"Options.NTx86"
,
0
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* open the INF without the Install section specified */
hr
=
pOpenINFEngine
(
"c:
\\
test.inf"
,
NULL
,
0
,
&
hinf
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
/* try a NULL hinf */
hr
=
pTranslateInfStringEx
(
NULL
,
"c:
\\
test.inf"
,
"Options.NTx86"
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* try a NULL filename */
hr
=
pTranslateInfStringEx
(
hinf
,
NULL
,
"Options.NTx86"
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* try an empty filename */
size
=
MAX_PATH
;
hr
=
pTranslateInfStringEx
(
hinf
,
""
,
"Options.NTx86"
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
(
UINT
)
hr
);
todo_wine
{
ok
(
!
strcmp
(
buffer
,
TEST_STRING2
),
"Expected %s, got %s
\n
"
,
TEST_STRING2
,
buffer
);
ok
(
size
==
25
,
"Expected size 25, got %ld
\n
"
,
size
);
}
/* try a NULL translate section */
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
NULL
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* try an empty translate section */
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
""
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
SPAPI_E_LINE_NOT_FOUND
,
"Expected SPAPI_E_LINE_NOT_FOUND, got %ld
\n
"
,
hr
);
/* try a NULL translate key */
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
"Options.NTx86"
,
NULL
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* try an empty translate key */
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
"Options.NTx86"
,
""
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
SPAPI_E_LINE_NOT_FOUND
,
"Expected SPAPI_E_LINE_NOT_FOUND, got %ld
\n
"
,
hr
);
/* successfully translate the string */
size
=
MAX_PATH
;
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
"Options.NTx86"
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
todo_wine
{
ok
(
!
strcmp
(
buffer
,
TEST_STRING2
),
"Expected %s, got %s
\n
"
,
TEST_STRING2
,
buffer
);
ok
(
size
==
25
,
"Expected size 25, got %ld
\n
"
,
size
);
}
/* try a NULL hinf */
hr
=
pCloseINFEngine
(
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"Expected E_INVALIDARG, got %ld
\n
"
,
hr
);
/* successfully close the hinf */
hr
=
pCloseINFEngine
(
hinf
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
/* open the inf with the install section */
hr
=
pOpenINFEngine
(
"c:
\\
test.inf"
,
"section"
,
0
,
&
hinf
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
/* translate the string with the install section specified */
size
=
MAX_PATH
;
hr
=
pTranslateInfStringEx
(
hinf
,
"c:
\\
test.inf"
,
"Options.NTx86"
,
"InstallDir"
,
buffer
,
size
,
&
size
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
ok
(
!
strcmp
(
buffer
,
progfiles
),
"Expected %s, got %s
\n
"
,
progfiles
,
buffer
);
ok
(
size
==
lstrlenA
(
progfiles
)
+
1
,
"Expected size %i, got %ld
\n
"
,
lstrlenA
(
progfiles
)
+
1
,
size
);
/* close the INF again */
hr
=
pCloseINFEngine
(
hinf
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %ld
\n
"
,
hr
);
DeleteFileA
(
"c:
\\
test.inf"
);
}
START_TEST
(
advpack
)
START_TEST
(
advpack
)
{
{
if
(
!
init_function_pointers
())
if
(
!
init_function_pointers
())
...
@@ -279,4 +400,5 @@ START_TEST(advpack)
...
@@ -279,4 +400,5 @@ START_TEST(advpack)
version_test
();
version_test
();
delnode_test
();
delnode_test
();
translateinfstring_test
();
translateinfstring_test
();
translateinfstringex_test
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment