[Wine-patches] Added test for IShellLinkW_GetPath

Dmitriy Kolmykov codelock на etersoft.ru
Ср Апр 20 15:08:41 MSD 2011


----------- следующая часть -----------
From 94b323863d035b205b547a723d8f80a38875a09e Mon Sep 17 00:00:00 2001
From: codelock <codelock на etersoft.ru>
Date: Wed, 20 Apr 2011 15:06:49 +0400
Subject: [PATCH] Added test for IShellLinkW_GetPath

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

diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index d28cff0..a91549e 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -999,6 +999,61 @@ static void test_GetIconLocation(void)
     IShellLinkA_Release(sl);
 }
 
+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) / 2, buffer );
+	ok( errorCode != 0, "GetTempPath failed (0x%08x)\n", GetLastError() );
+	errorCode = GetLongPathNameW( buffer, tmpDir, sizeof(tmpDir) );
+	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 );
+	wcscpy( buffer, testWord );
+
+	pfd.dwFileAttributes = 0x1234;
+	wcscpy( pfd.cFileName, testWord );
+	hRes = IShellLinkW_GetPath( psl, buffer, sizeof(buffer) / 2, & 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_DATAA structure is not filled\n" );
+
+	DeleteFileW( tmpDir );
+	DeleteFileW( fileName );
+
+	IPersistFile_Release( ppf );
+	IShellLinkW_Release( psl );
+}
+
 START_TEST(shelllink)
 {
     HRESULT r;
@@ -1023,6 +1078,7 @@ START_TEST(shelllink)
     test_datalink();
     test_shdefextracticon();
     test_GetIconLocation();
+    test_get_path();
 
     CoUninitialize();
 }
-- 
1.7.1


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