Module: wine Branch: master Commit: c1645b6dfdd0a42cc51e3200b02db8559db08f6a URL: http://source.winehq.org/git/wine.git/?a=commit;h=c1645b6dfdd0a42cc51e3200b0...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Sun Jan 8 21:54:46 2017 +0300
shell32/tests: Some tests for ExtractIcon().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/shell32/tests/shelllink.c | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index 8af3c97..293f69c 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -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(); }