mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 05:05:09 +00:00
[SHELL32_APITEST]
- Fix the names of some expected return values get from the APIs; - Move a bit the TestShellLink() function. - When displaying hexadecimal, prepend the "0x" string (otherwise, when you see: "hr = 10", is it 10 in decimal or in hex??) - Call CoUninitialize() at the end of the tests. svn path=/trunk/; revision=73559
This commit is contained in:
parent
8a75088c41
commit
a6b1351921
|
@ -15,25 +15,26 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <shellutils.h>
|
#include <shellutils.h>
|
||||||
|
|
||||||
typedef
|
/* Test IShellLink::SetPath with environment-variables, existing, non-existing, ...*/
|
||||||
struct _TestShellLinkDef
|
typedef struct
|
||||||
{
|
{
|
||||||
const WCHAR* pathIn;
|
PCWSTR pathIn;
|
||||||
HRESULT hrSetPath;
|
HRESULT hrSetPath;
|
||||||
|
|
||||||
/* Test 1 - hrGetPathX = IShellLink::GetPath(pathOutX, ... , flagsX); */
|
/* Test 1 - hrGetPathX = IShellLink::GetPath(pathOutX, ... , flagsX); */
|
||||||
const WCHAR* pathOut1;
|
PCWSTR pathOut1;
|
||||||
DWORD flags1;
|
DWORD flags1;
|
||||||
HRESULT hrGetPath1;
|
HRESULT hrGetPath1;
|
||||||
bool expandPathOut1;
|
BOOL expandPathOut1;
|
||||||
|
|
||||||
/* Test 2 */
|
/* Test 2 */
|
||||||
const WCHAR* pathOut2;
|
PCWSTR pathOut2;
|
||||||
DWORD flags2;
|
DWORD flags2;
|
||||||
HRESULT hrGetPath2;
|
HRESULT hrGetPath2;
|
||||||
bool expandPathOut2;
|
BOOL expandPathOut2;
|
||||||
} TestShellLinkDef;
|
} TEST_SHELL_LINK_DEF;
|
||||||
|
|
||||||
/* Test IShellLink::SetPath with environment-variables, existing, non-existing, ...*/
|
static TEST_SHELL_LINK_DEF linkTestList[] =
|
||||||
static struct _TestShellLinkDef linkTestList[] =
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
L"%comspec%", S_OK,
|
L"%comspec%", S_OK,
|
||||||
|
@ -42,8 +43,8 @@ static struct _TestShellLinkDef linkTestList[] =
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
L"%anyvar%", E_INVALIDARG,
|
L"%anyvar%", E_INVALIDARG,
|
||||||
L"", SLGP_SHORTPATH, ERROR_INVALID_FUNCTION, FALSE,
|
L"", SLGP_SHORTPATH, S_FALSE, FALSE,
|
||||||
L"", SLGP_RAWPATH, ERROR_INVALID_FUNCTION, FALSE
|
L"", SLGP_RAWPATH, S_FALSE, FALSE
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
L"%anyvar%%comspec%", S_OK,
|
L"%anyvar%%comspec%", S_OK,
|
||||||
|
@ -82,21 +83,21 @@ static struct _TestShellLinkDef linkTestList[] =
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
L"non-existent-file", E_INVALIDARG,
|
L"non-existent-file", E_INVALIDARG,
|
||||||
L"", SLGP_SHORTPATH, ERROR_INVALID_FUNCTION, FALSE,
|
L"", SLGP_SHORTPATH, S_FALSE, FALSE,
|
||||||
L"", SLGP_RAWPATH, ERROR_INVALID_FUNCTION, FALSE
|
L"", SLGP_RAWPATH, S_FALSE, FALSE
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
test_checklinkpath(UINT i, TestShellLinkDef* testDef)
|
test_checklinkpath(UINT i, TEST_SHELL_LINK_DEF* testDef)
|
||||||
{
|
{
|
||||||
static WCHAR evVar[MAX_PATH];
|
static WCHAR evVar[MAX_PATH];
|
||||||
|
|
||||||
HRESULT hr, expectedHr;
|
HRESULT hr, expectedHr;
|
||||||
WCHAR wPathOut[MAX_PATH];
|
WCHAR wPathOut[MAX_PATH];
|
||||||
bool expandPathOut;
|
BOOL expandPathOut;
|
||||||
const WCHAR* expectedPathOut;
|
PCWSTR expectedPathOut;
|
||||||
IShellLinkW *psl;
|
IShellLinkW *psl;
|
||||||
UINT i1;
|
UINT i1;
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
|
@ -105,7 +106,7 @@ static WCHAR evVar[MAX_PATH];
|
||||||
NULL,
|
NULL,
|
||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
IID_PPV_ARG(IShellLinkW, &psl));
|
IID_PPV_ARG(IShellLinkW, &psl));
|
||||||
ok(hr == S_OK, "CoCreateInstance, hr = %lx\n", hr);
|
ok(hr == S_OK, "CoCreateInstance, hr = 0x%lx\n", hr);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
skip("Could not instantiate CShellLink\n");
|
skip("Could not instantiate CShellLink\n");
|
||||||
|
@ -113,19 +114,19 @@ static WCHAR evVar[MAX_PATH];
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = psl->SetPath(testDef->pathIn);
|
hr = psl->SetPath(testDef->pathIn);
|
||||||
ok(hr == testDef->hrSetPath, "IShellLink::SetPath(%d), got hr = %lx, expected %lx\n", i, hr, testDef->hrSetPath);
|
ok(hr == testDef->hrSetPath, "IShellLink::SetPath(%d), got hr = 0x%lx, expected 0x%lx\n", i, hr, testDef->hrSetPath);
|
||||||
|
|
||||||
expectedPathOut = NULL;
|
expectedPathOut = NULL;
|
||||||
for (i1 = 0; i1 <= 1; i1++ )
|
for (i1 = 0; i1 <= 1; i1++)
|
||||||
{
|
{
|
||||||
if (i1 == 1)
|
if (i1 == 1) /* Usually SLGP_RAWPATH */
|
||||||
{
|
{
|
||||||
flags = testDef->flags1;
|
flags = testDef->flags1;
|
||||||
expandPathOut = testDef->expandPathOut1;
|
expandPathOut = testDef->expandPathOut1;
|
||||||
expectedPathOut = testDef->pathOut1;
|
expectedPathOut = testDef->pathOut1;
|
||||||
expectedHr = testDef->hrGetPath1;
|
expectedHr = testDef->hrGetPath1;
|
||||||
}
|
}
|
||||||
else
|
else /* Usually SLGP_SHORTPATH */
|
||||||
{
|
{
|
||||||
flags = testDef->flags2;
|
flags = testDef->flags2;
|
||||||
expandPathOut = testDef->expandPathOut2;
|
expandPathOut = testDef->expandPathOut2;
|
||||||
|
@ -134,7 +135,7 @@ static WCHAR evVar[MAX_PATH];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Patch some variables */
|
/* Patch some variables */
|
||||||
if (expandPathOut == TRUE)
|
if (expandPathOut)
|
||||||
{
|
{
|
||||||
ExpandEnvironmentStringsW(expectedPathOut, evVar, _countof(evVar));
|
ExpandEnvironmentStringsW(expectedPathOut, evVar, _countof(evVar));
|
||||||
DPRINT("** %S **\n",evVar);
|
DPRINT("** %S **\n",evVar);
|
||||||
|
@ -143,65 +144,16 @@ static WCHAR evVar[MAX_PATH];
|
||||||
|
|
||||||
hr = psl->GetPath(wPathOut, _countof(wPathOut), NULL, flags);
|
hr = psl->GetPath(wPathOut, _countof(wPathOut), NULL, flags);
|
||||||
ok(hr == expectedHr,
|
ok(hr == expectedHr,
|
||||||
"IShellLink::GetPath(%d), flags %lx, got hr = %lx, expected %lx\n",
|
"IShellLink::GetPath(%d), flags 0x%lx, got hr = 0x%lx, expected 0x%lx\n",
|
||||||
i, flags, hr, expectedHr);
|
i, flags, hr, expectedHr);
|
||||||
ok(wcsicmp(wPathOut, expectedPathOut) == 0,
|
ok(wcsicmp(wPathOut, expectedPathOut) == 0,
|
||||||
"IShellLink::GetPath(%d), flags %lx, in %S, got %S, expected %S\n",
|
"IShellLink::GetPath(%d), flags 0x%lx, in %S, got %S, expected %S\n",
|
||||||
i, flags, testDef->pathIn, wPathOut, expectedPathOut);
|
i, flags, testDef->pathIn, wPathOut, expectedPathOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
psl->Release();
|
psl->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
VOID
|
|
||||||
TestDescription(void)
|
|
||||||
{
|
|
||||||
HRESULT hr;
|
|
||||||
IShellLinkW *psl;
|
|
||||||
WCHAR buffer[64];
|
|
||||||
PCWSTR testDescription = L"This is a test description";
|
|
||||||
|
|
||||||
/* Test SetDescription */
|
|
||||||
hr = CoCreateInstance(CLSID_ShellLink,
|
|
||||||
NULL,
|
|
||||||
CLSCTX_INPROC_SERVER,
|
|
||||||
IID_PPV_ARG(IShellLinkW, &psl));
|
|
||||||
ok(hr == S_OK, "CoCreateInstance, hr = %lx\n", hr);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
skip("Could not instantiate CShellLink\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(buffer, 0x55, sizeof(buffer));
|
|
||||||
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
|
||||||
ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
|
|
||||||
ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
|
|
||||||
ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
|
|
||||||
|
|
||||||
hr = psl->SetDescription(testDescription);
|
|
||||||
ok(hr == S_OK, "IShellLink::SetDescription returned hr = %lx\n", hr);
|
|
||||||
|
|
||||||
memset(buffer, 0x55, sizeof(buffer));
|
|
||||||
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
|
||||||
ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
|
|
||||||
ok(buffer[wcslen(testDescription)] == 0, "buffer[n] = %x\n", buffer[wcslen(testDescription)]);
|
|
||||||
ok(buffer[wcslen(testDescription) + 1] == 0x5555, "buffer[n+1] = %x\n", buffer[wcslen(testDescription) + 1]);
|
|
||||||
ok(!wcscmp(buffer, testDescription), "buffer = '%ls'\n", buffer);
|
|
||||||
|
|
||||||
hr = psl->SetDescription(NULL);
|
|
||||||
ok(hr == S_OK, "IShellLink::SetDescription returned hr = %lx\n", hr);
|
|
||||||
|
|
||||||
memset(buffer, 0x55, sizeof(buffer));
|
|
||||||
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
|
||||||
ok(hr == S_OK, "IShellLink::GetDescription returned hr = %lx\n", hr);
|
|
||||||
ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
|
|
||||||
ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
|
|
||||||
|
|
||||||
psl->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
TestShellLink(void)
|
TestShellLink(void)
|
||||||
|
@ -220,10 +172,61 @@ TestShellLink(void)
|
||||||
SetEnvironmentVariableW(L"shell",NULL);
|
SetEnvironmentVariableW(L"shell",NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
TestDescription(void)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
IShellLinkW *psl;
|
||||||
|
WCHAR buffer[64];
|
||||||
|
PCWSTR testDescription = L"This is a test description";
|
||||||
|
|
||||||
|
/* Test SetDescription */
|
||||||
|
hr = CoCreateInstance(CLSID_ShellLink,
|
||||||
|
NULL,
|
||||||
|
CLSCTX_INPROC_SERVER,
|
||||||
|
IID_PPV_ARG(IShellLinkW, &psl));
|
||||||
|
ok(hr == S_OK, "CoCreateInstance, hr = 0x%lx\n", hr);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
skip("Could not instantiate CShellLink\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
||||||
|
ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
|
||||||
|
ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
|
||||||
|
ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
|
||||||
|
|
||||||
|
hr = psl->SetDescription(testDescription);
|
||||||
|
ok(hr == S_OK, "IShellLink::SetDescription returned hr = 0x%lx\n", hr);
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
||||||
|
ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
|
||||||
|
ok(buffer[wcslen(testDescription)] == 0, "buffer[n] = %x\n", buffer[wcslen(testDescription)]);
|
||||||
|
ok(buffer[wcslen(testDescription) + 1] == 0x5555, "buffer[n+1] = %x\n", buffer[wcslen(testDescription) + 1]);
|
||||||
|
ok(!wcscmp(buffer, testDescription), "buffer = '%ls'\n", buffer);
|
||||||
|
|
||||||
|
hr = psl->SetDescription(NULL);
|
||||||
|
ok(hr == S_OK, "IShellLink::SetDescription returned hr = 0x%lx\n", hr);
|
||||||
|
|
||||||
|
memset(buffer, 0x55, sizeof(buffer));
|
||||||
|
hr = psl->GetDescription(buffer, RTL_NUMBER_OF(buffer));
|
||||||
|
ok(hr == S_OK, "IShellLink::GetDescription returned hr = 0x%lx\n", hr);
|
||||||
|
ok(buffer[0] == 0, "buffer[0] = %x\n", buffer[0]);
|
||||||
|
ok(buffer[1] == 0x5555, "buffer[1] = %x\n", buffer[1]);
|
||||||
|
|
||||||
|
psl->Release();
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(CShellLink)
|
START_TEST(CShellLink)
|
||||||
{
|
{
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
TestShellLink();
|
TestShellLink();
|
||||||
TestDescription();
|
TestDescription();
|
||||||
|
|
||||||
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue