[Wine-patches] Added test for IShellLinkW_GetPath

Dmitriy Kolmykov codelock на etersoft.ru
Вт Апр 26 13:19:50 MSD 2011


----------- следующая часть -----------
From a4c77aa3a0af789ecfabd0777d5d61fee1e10c6a Mon Sep 17 00:00:00 2001
From: Dmitriy Kolmykov <codelock на etersoft.ru>
Date: Tue, 26 Apr 2011 13:16:10 +0400
Subject: [PATCH] Added test for IShellLinkW_GetPath

---
 dlls/shell32/tests/shelllink.c |   57 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index d28cff0..1a16340 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -999,6 +999,62 @@ static void test_GetIconLocation(void)
     IShellLinkA_Release(sl);
 }
 
+/*
+ * Creates a temporary file in the reserved temporary directory.
+ * Then procedure creates a link to the temporary file and gets a path by this link.
+ */
+
+static void test_GetPath(void)
+{
+    HRESULT hRes;
+    IShellLinkW * psl;
+    IPersistFile * ppf;
+    WIN32_FIND_DATAW pfd;
+
+    WCHAR tmpDir[MAX_PATH];
+    static const WCHAR prefix[] = { 't','m','p',0 };
+    static const WCHAR testWord[] = { 's','t','r','i','n','g',0 };
+    static const WCHAR linkName[] = { 'l','i','n','k','.','l','n','k',0 };
+    WCHAR fileName[MAX_PATH];
+    WCHAR buffer[MAX_PATH];
+    DWORD len;
+
+    /* WinXP returns a short path */
+    len = GetTempPathW(sizeof(buffer) / sizeof(WCHAR), buffer);
+    ok(len != 0, "GetTempPath failed (0x%08x)\n", GetLastError());
+    len = GetLongPathNameW(buffer, tmpDir, sizeof(tmpDir) / sizeof(WCHAR));
+    ok(len != 0, "GetLongPathNameW failed (0x%08x)\n", GetLastError());
+    len = GetTempFileNameW(tmpDir, prefix, 0, fileName);
+    ok(len != 0, "GetTempFileName failed (0x%08x)\n", GetLastError());
+
+    hRes = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+                            &IID_IShellLinkW, (void **)&psl);
+    ok(hRes == S_OK, "no IID_IShellLinkW\n");
+    hRes = IShellLinkW_SetPath(psl, fileName);
+    ok(hRes == S_OK, "SetPath failed (0x%08x)\n", hRes);
+    hRes = IShellLinkW_SetShowCmd(psl, SW_SHOWNORMAL);
+    ok(hRes == S_OK, "SetShowCmd failed (0x%08x)\n", hRes);
+    hRes = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (void **)&ppf);
+    ok(hRes == S_OK, "no IID_IPersistFile\n");
+
+    wcscat(tmpDir, linkName);
+    hRes = IPersistFile_Save(ppf, tmpDir, TRUE);
+    ok(hRes == S_OK, "Save failed (0x%08x)\n", hRes);
+    hRes = IPersistFile_Load(ppf, tmpDir, 0);
+    ok(hRes == S_OK, "load failed (0x%08x)\n", hRes);
+
+    pfd.dwFileAttributes = 0x1234;
+    wcscpy(pfd.cFileName, testWord);
+    hRes = IShellLinkW_GetPath(psl, buffer, sizeof(buffer) / sizeof(WCHAR), &pfd, SLGP_RAWPATH);
+    ok(hRes == S_OK && wcscmp(buffer, fileName) == 0, "GetPath failed (0x%08x)\n", hRes);
+    ok(pfd.dwFileAttributes != 0x1234 && wcscmp(pfd.cFileName, testWord) != 0, "WIN32_FIND_DATAW structure is not filled\n");
+    
+    DeleteFileW(tmpDir);
+    DeleteFileW(fileName);
+    IPersistFile_Release(ppf);
+    IShellLinkW_Release(psl);
+}
+
 START_TEST(shelllink)
 {
     HRESULT r;
@@ -1023,6 +1079,7 @@ START_TEST(shelllink)
     test_datalink();
     test_shdefextracticon();
     test_GetIconLocation();
+    test_GetPath();
 
     CoUninitialize();
 }
-- 
1.7.1


Подробная информация о списке рассылки Wine-patches