shell32/tests: Some tests for ExtractIcon().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b9181615a9
commit
c1645b6dfd
|
@ -1150,6 +1150,102 @@ static void test_propertystore(void)
|
|||
IShellLinkW_Release(linkW);
|
||||
}
|
||||
|
||||
static void test_ExtractIcon(void)
|
||||
{
|
||||
static const WCHAR nameW[] = {'\\','e','x','t','r','a','c','t','i','c','o','n','_','t','e','s','t','.','t','x','t',0};
|
||||
static const WCHAR shell32W[] = {'s','h','e','l','l','3','2','.','d','l','l',0};
|
||||
WCHAR pathW[MAX_PATH];
|
||||
HICON hicon, hicon2;
|
||||
char path[MAX_PATH];
|
||||
HANDLE file;
|
||||
int r;
|
||||
|
||||
/* specified instance handle */
|
||||
hicon = ExtractIconA(GetModuleHandleA("shell32.dll"), NULL, 0);
|
||||
todo_wine
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
hicon2 = ExtractIconA(GetModuleHandleA("shell32.dll"), "shell32.dll", -1);
|
||||
ok(hicon2 != NULL, "Got icon %p\n", hicon2);
|
||||
|
||||
/* existing index */
|
||||
hicon = ExtractIconA(NULL, "shell32.dll", 0);
|
||||
ok(hicon != NULL && HandleToLong(hicon) != -1, "Got icon %p\n", hicon);
|
||||
DestroyIcon(hicon);
|
||||
|
||||
/* returns number of resources */
|
||||
hicon = ExtractIconA(NULL, "shell32.dll", -1);
|
||||
ok(HandleToLong(hicon) > 1 && hicon == hicon2, "Got icon %p\n", hicon);
|
||||
|
||||
/* invalid index, valid dll name */
|
||||
hicon = ExtractIconA(NULL, "shell32.dll", 3000);
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
/* Create a temporary non-executable file */
|
||||
GetTempPathA(sizeof(path), path);
|
||||
strcat(path, "\\extracticon_test.txt");
|
||||
file = CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ok(file != INVALID_HANDLE_VALUE, "Failed to create a test file\n");
|
||||
CloseHandle(file);
|
||||
|
||||
hicon = ExtractIconA(NULL, path, 0);
|
||||
todo_wine
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
hicon = ExtractIconA(NULL, path, -1);
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
hicon = ExtractIconA(NULL, path, 1);
|
||||
todo_wine
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
r = DeleteFileA(path);
|
||||
ok(r, "failed to delete file %s (%d)\n", path, GetLastError());
|
||||
|
||||
/* same for W variant */
|
||||
if (0)
|
||||
{
|
||||
/* specified instance handle, crashes on XP, 2k3 */
|
||||
hicon = ExtractIconW(GetModuleHandleA("shell32.dll"), NULL, 0);
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
}
|
||||
hicon2 = ExtractIconW(GetModuleHandleA("shell32.dll"), shell32W, -1);
|
||||
ok(hicon2 != NULL, "Got icon %p\n", hicon2);
|
||||
|
||||
/* existing index */
|
||||
hicon = ExtractIconW(NULL, shell32W, 0);
|
||||
ok(hicon != NULL && HandleToLong(hicon) != -1, "Got icon %p\n", hicon);
|
||||
DestroyIcon(hicon);
|
||||
|
||||
/* returns number of resources */
|
||||
hicon = ExtractIconW(NULL, shell32W, -1);
|
||||
ok(HandleToLong(hicon) > 1 && hicon == hicon2, "Got icon %p\n", hicon);
|
||||
|
||||
/* invalid index, valid dll name */
|
||||
hicon = ExtractIconW(NULL, shell32W, 3000);
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
/* Create a temporary non-executable file */
|
||||
GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
|
||||
lstrcatW(pathW, nameW);
|
||||
file = CreateFileW(pathW, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
ok(file != INVALID_HANDLE_VALUE, "Failed to create a test file\n");
|
||||
CloseHandle(file);
|
||||
|
||||
hicon = ExtractIconW(NULL, pathW, 0);
|
||||
todo_wine
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
hicon = ExtractIconW(NULL, pathW, -1);
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
hicon = ExtractIconW(NULL, pathW, 1);
|
||||
todo_wine
|
||||
ok(hicon == NULL, "Got icon %p\n", hicon);
|
||||
|
||||
r = DeleteFileW(pathW);
|
||||
ok(r, "failed to delete file %s (%d)\n", path, GetLastError());
|
||||
}
|
||||
|
||||
START_TEST(shelllink)
|
||||
{
|
||||
HRESULT r;
|
||||
|
@ -1178,6 +1274,7 @@ START_TEST(shelllink)
|
|||
test_SHGetStockIconInfo();
|
||||
test_SHExtractIcons();
|
||||
test_propertystore();
|
||||
test_ExtractIcon();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue