Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Felix Münchhalfen
wine
Commits
7787ca61
Commit
7787ca61
authored
19 years ago
by
James Hawkins
Committed by
Alexandre Julliard
19 years ago
Browse files
Options
Downloads
Patches
Plain Diff
advpack: Add tests for the TranslateInfStringEx trio of functions and
fix the errors.
parent
790f4523
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/advpack/advpack.c
+8
-2
8 additions, 2 deletions
dlls/advpack/advpack.c
dlls/advpack/tests/advpack.c
+123
-1
123 additions, 1 deletion
dlls/advpack/tests/advpack.c
with
131 additions
and
3 deletions
dlls/advpack/advpack.c
+
8
−
2
View file @
7787ca61
...
...
@@ -123,6 +123,9 @@ HRESULT WINAPI CloseINFEngine(HINF hInf)
{
TRACE
(
"(%p)
\n
"
,
hInf
);
if
(
!
hInf
)
return
E_INVALIDARG
;
SetupCloseInfFile
(
hInf
);
return
S_OK
;
}
...
...
@@ -270,7 +273,7 @@ HRESULT WINAPI OpenINFEngineA(LPCSTR pszInfFilename, LPCSTR pszInstallSection,
TRACE
(
"(%p, %p, %ld, %p, %p)
\n
"
,
pszInfFilename
,
pszInstallSection
,
dwFlags
,
phInf
,
pvReserved
);
if
(
!
phInf
)
if
(
!
pszInfFilename
||
!
phInf
)
return
E_INVALIDARG
;
*
phInf
=
SetupOpenInfFileA
(
pszInfFilename
,
NULL
,
INF_STYLE_WIN4
,
NULL
);
...
...
@@ -472,6 +475,9 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
pszTranslateSection
,
pszTranslateKey
,
pszBuffer
,
dwBufferSize
,
pdwRequiredSize
,
pvReserved
);
if
(
!
hInf
||
!
pszInfFilename
||
!
pszTranslateSection
||
!
pszTranslateKey
)
return
E_INVALIDARG
;
if
(
!
SetupGetLineTextA
(
NULL
,
hInf
,
pszTranslateSection
,
pszTranslateKey
,
pszBuffer
,
dwBufferSize
,
pdwRequiredSize
))
{
...
...
@@ -481,7 +487,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
return
SPAPI_E_LINE_NOT_FOUND
;
}
return
E_FAIL
;
return
S_OK
;
}
/***********************************************************************
...
...
This diff is collapsed.
Click to expand it.
dlls/advpack/tests/advpack.c
+
123
−
1
View file @
7787ca61
...
...
@@ -28,9 +28,12 @@
#define TEST_STRING1 "\\Application Name"
#define TEST_STRING2 "%49001%\\Application Name"
static
HRESULT
(
WINAPI
*
pCloseINFEngine
)(
HINF
);
static
HRESULT
(
WINAPI
*
pDelNode
)(
LPCSTR
,
DWORD
);
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
*
pTranslateInfStringEx
)(
HINF
,
PCSTR
,
PCSTR
,
PCSTR
,
PSTR
,
DWORD
,
PDWORD
,
PVOID
);
static
BOOL
init_function_pointers
(
void
)
{
...
...
@@ -39,11 +42,15 @@ static BOOL init_function_pointers(void)
if
(
!
hAdvPack
)
return
FALSE
;
pCloseINFEngine
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"CloseINFEngine"
);
pDelNode
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"DelNode"
);
pGetVersionFromFile
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"GetVersionFromFile"
);
pOpenINFEngine
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"OpenINFEngine"
);
pTranslateInfString
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"TranslateInfString"
);
pTranslateInfStringEx
=
(
void
*
)
GetProcAddress
(
hAdvPack
,
"TranslateInfStringEx"
);
if
(
!
pDelNode
||
!
pGetVersionFromFile
||
!
pTranslateInfString
)
if
(
!
pCloseINFEngine
||
!
pDelNode
||
!
pGetVersionFromFile
||
!
pOpenINFEngine
||
!
pTranslateInfString
)
return
FALSE
;
return
TRUE
;
...
...
@@ -271,6 +278,120 @@ static void translateinfstring_test()
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
)
{
if
(
!
init_function_pointers
())
...
...
@@ -279,4 +400,5 @@ START_TEST(advpack)
version_test
();
delnode_test
();
translateinfstring_test
();
translateinfstringex_test
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment