[PATCH 6/6] Clean make new folder test (Valgrind)
Nikolay Sivov
nsivov at codeweavers.com
Sat Jan 29 04:39:12 CST 2011
---
dlls/shell32/tests/brsfolder.c | 64 ++++++++++++++++++++-------------------
1 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/dlls/shell32/tests/brsfolder.c b/dlls/shell32/tests/brsfolder.c
index fd547cb..9a1c927 100644
--- a/dlls/shell32/tests/brsfolder.c
+++ b/dlls/shell32/tests/brsfolder.c
@@ -17,10 +17,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <windows.h>
-#include <shlobj.h>
-#include <shobjidl.h>
-#include <string.h>
+
+#define COBJMACROS
+#define CONST_VTABLE
+
+#include "windows.h"
+#include "shlobj.h"
#include "wine/test.h"
#define IDD_MAKENEWFOLDER 0x3746 /* From "../shresdef.h" */
@@ -147,18 +149,17 @@ static int CALLBACK create_new_folder_callback(HWND hwnd, UINT uMsg,
*/
static void test_click_make_new_folder_button(void)
{
- HRESULT resCoInit;
- BROWSEINFO bi;
- LPITEMIDLIST pidl = NULL;
+ HRESULT hr;
+ BROWSEINFOA bi;
+ LPITEMIDLIST pidl;
LPITEMIDLIST test_folder_pidl;
- IShellFolder *test_folder_object;
+ IShellFolder *desktop = NULL;
char test_folder_path[MAX_PATH];
WCHAR test_folder_pathW[MAX_PATH];
CHAR new_folder_path[MAX_PATH];
CHAR new_folder_pidl_path[MAX_PATH];
- char selected_folder[MAX_PATH];
const CHAR title[] = "test_click_make_new_folder_button";
- int number_of_folders = -1;
+ int number_of_folders, ret;
SHFILEOPSTRUCT shfileop;
if (does_folder_or_file_exist(title))
@@ -168,8 +169,8 @@ static void test_click_make_new_folder_button(void)
}
/* Must initialize COM if using the NEWDIAlOGSTYLE according to MSDN. */
- resCoInit = CoInitialize(NULL);
- if(!(resCoInit == S_OK || resCoInit == S_FALSE))
+ hr = CoInitialize(NULL);
+ if(hr != S_OK)
{
skip("COM could not be initialized %u\n", GetLastError());
return;
@@ -191,18 +192,21 @@ static void test_click_make_new_folder_button(void)
return;
}
- /* Initialize browse info struct for SHBrowseForFolder */
+ hr = SHGetDesktopFolder(&desktop);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ /* Use test folder as the root folder for dialog box */
+ MultiByteToWideChar(CP_ACP, 0, test_folder_path, -1,
+ test_folder_pathW, MAX_PATH);
+ hr = IShellFolder_ParseDisplayName(desktop, NULL, NULL,
+ test_folder_pathW, 0, &test_folder_pidl, 0);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
bi.hwndOwner = NULL;
- bi.pszDisplayName = (LPTSTR) &selected_folder;
- bi.lpszTitle = (LPTSTR) title;
+ bi.pszDisplayName = NULL;
+ bi.lpszTitle = title;
bi.ulFlags = BIF_NEWDIALOGSTYLE;
bi.lpfn = create_new_folder_callback;
- /* Use test folder as the root folder for dialog box */
- MultiByteToWideChar(CP_UTF8, 0, test_folder_path, MAX_PATH,
- test_folder_pathW, MAX_PATH);
- SHGetDesktopFolder(&test_folder_object);
- test_folder_object->lpVtbl->ParseDisplayName(test_folder_object, NULL, NULL,
- test_folder_pathW, 0UL, &test_folder_pidl, 0UL);
bi.pidlRoot = test_folder_pidl;
/* Display dialog box and let callback click the buttons */
@@ -230,19 +234,17 @@ static void test_click_make_new_folder_button(void)
/* Remove test folder and any subfolders created in this test */
shfileop.hwnd = NULL;
shfileop.wFunc = FO_DELETE;
- /* Path must be double NULL terminated */
- test_folder_path[strlen(test_folder_path)+1] = '\0';
+ /* Path must be double NULL terminated, also trims a slash */
+ test_folder_path[strlen(test_folder_path)-1] = '\0';
shfileop.pFrom = test_folder_path;
shfileop.pTo = NULL;
shfileop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT;
- SHFileOperation(&shfileop);
-
- if (pidl)
- CoTaskMemFree(pidl);
- if (test_folder_pidl)
- CoTaskMemFree(test_folder_pidl);
- if (test_folder_object)
- test_folder_object->lpVtbl->Release(test_folder_object);
+ ret = SHFileOperation(&shfileop);
+ ok(ret == 0, "got %d, %s\n", ret, test_folder_path);
+
+ ILFree(pidl);
+ ILFree(test_folder_pidl);
+ if (desktop) IShellFolder_Release(desktop);
CoUninitialize();
}
--
1.5.6.5
--------------000302050501050404090200--
More information about the wine-patches
mailing list