[Wine-patches] Added test for IShellLinkW_GetPath

Dmitriy Kolmykov codelock на etersoft.ru
Чт Апр 21 14:30:14 MSD 2011


----------- следующая часть -----------
From 072f472ad9fe67627857cb8c76fe7fc5ad8c5ff2 Mon Sep 17 00:00:00 2001
From: codelock <codelock на etersoft.ru>
Date: Thu, 21 Apr 2011 14:27:34 +0400
Subject: [PATCH] Added test for IShellLinkW_GetPath

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

diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index d28cff0..42fd773 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -999,6 +999,65 @@ 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_get_path( void )
+{
+	HRESULT hRes;
+	IShellLinkW * psl;
+	IPersistFile * ppf;
+	WIN32_FIND_DATAW pfd;
+
+	WCHAR tmpDir[ MAX_PATH ];
+	const WCHAR prefix[] = { 't','m','p', 0 };
+	const WCHAR testWord[] = { 's','t','r','i','n','g', 0 };
+	const WCHAR linkName[] = { 'l','i','n','k','.','l','n','k', 0 };
+	WCHAR fileName[ MAX_PATH ];
+	WCHAR buffer[ MAX_PATH ];
+	DWORD errorCode;
+	
+
+	errorCode = GetTempPathW( sizeof(buffer) / sizeof(WCHAR), buffer );
+	ok( errorCode != 0, "GetTempPath failed (0x%08x)\n", GetLastError() );
+	errorCode = GetLongPathNameW( buffer, tmpDir, sizeof(tmpDir) / sizeof(WCHAR) );
+	ok( errorCode != 0, "GetLongPathNameW failed (0x%08x)\n", GetLastError() );
+	errorCode = GetTempFileNameW( tmpDir, prefix, 0, fileName );
+	ok( errorCode != 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_IShellLinkA\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 +1082,7 @@ START_TEST(shelllink)
     test_datalink();
     test_shdefextracticon();
     test_GetIconLocation();
+    test_get_path();
 
     CoUninitialize();
 }
-- 
1.7.1


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