shell32/tests: Test that a folder can be named when clicking "Make New Folder"
Michael Mc Donnell
michael at mcdonnell.dk
Tue Aug 10 13:22:01 CDT 2010
When a user clicks the "Make New Folder" button a new folder is created.
The name of the folder is selected, and the dialog box waits for the user
to either accept the name or type in a new one. The test types in a
new folder name and checks that the new folder gets that name.
-------------- next part --------------
From c2cb0b2fa5705117ccc1289d167ddefd35f15f01 Mon Sep 17 00:00:00 2001
From: Michael Mc Donnell <michael at mcdonnell.dk>
Date: Tue, 10 Aug 2010 13:53:49 -0400
Subject: shell32/tests: Test that a folder can be named when clicking "Make New Folder"
To: wine-patches <wine-patches at winehq.org>
When a user clicks the "Make New Folder" button a new folder is created.
The name of the folder is selected, and the dialog box waits for the user
to either accept the name or type in a new one. The test types in a
new folder name and checks that the new folder gets that name.
---
dlls/shell32/tests/brsfolder.c | 57 ++++++++++++++++++++++++++++++---------
1 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/dlls/shell32/tests/brsfolder.c b/dlls/shell32/tests/brsfolder.c
index af2bc73..5cc3f96 100644
--- a/dlls/shell32/tests/brsfolder.c
+++ b/dlls/shell32/tests/brsfolder.c
@@ -1,7 +1,7 @@
/*
* Unit test of the SHBrowseForFolder function.
*
- * Copyright 2009 Michael Mc Donnell
+ * Copyright 2009-2010 Michael Mc Donnell
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,8 @@
#include <string.h>
#include "wine/test.h"
-#define IDD_MAKENEWFOLDER 0x3746 /* From "../shresdef.h" */
+
+static char new_folder_name[] = "foo";
/*
* Returns the number of folders in a folder.
@@ -64,19 +65,38 @@ static BOOL does_folder_or_file_exist(LPCSTR folder_path)
/*
* Callback used by test_click_make_new_folder_button for SHBrowseForFolder
- * dialog box. It clicks the "Make New Folder" button and then closes the dialog
- * box.
+ * dialog box. It activates the "Make New Folder" button, types in the new
+ * folder name, hits enter, and then closes the dialog box.
*/
static int CALLBACK create_new_folder_callback(HWND hwnd, UINT uMsg,
LPARAM lParam, LPARAM lpData)
{
+ int i = 0;
+ int new_folder_name_length = strlen(new_folder_name);
+
switch (uMsg)
{
case BFFM_INITIALIZED:
- /* Click "Make New Folder" button */
- SendMessage(hwnd, WM_COMMAND, IDD_MAKENEWFOLDER, 0);
+ /* Activate "Make New Folder" button using ALT+m */
+ SetFocus(hwnd);
+ keybd_event(VK_MENU, 0, 0, 0);
+ keybd_event(VkKeyScan('m'), 0, 0, 0);
+ keybd_event(VkKeyScan('m'), 0, KEYEVENTF_KEYUP, 0);
+ keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
+
+ /* Type in folder name followed by enter */
+ for (i = 0; i < new_folder_name_length; i++)
+ {
+ keybd_event(VkKeyScan(new_folder_name[i]), 0, 0, 0);
+ keybd_event(VkKeyScan(new_folder_name[i]), 0, KEYEVENTF_KEYUP, 0);
+ }
+ keybd_event(VK_RETURN, 0, 0, 0);
+ keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
+
/* Close dialog box */
- SendMessage(hwnd, WM_COMMAND, IDCANCEL, 0);
+ keybd_event(VK_RETURN, 0, 0, 0);
+ keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
+
return TRUE;
default:
return FALSE;
@@ -91,12 +111,14 @@ static int CALLBACK create_new_folder_callback(HWND hwnd, UINT uMsg,
* 1. Check that there is no "test_click_make_new_folder_button" folder.
* 2. Create a test folder called "test_click_make_new_folder_button".
* 3. Use the test folder as root for SHBrowseForFolder dialog box.
- * 3. Hook up SHBrowseForFolder dialog box with callback.
- * 4. Display SHBrowseForFolder dialog box.
- * 5. Callback clicks "Make New Folder" button (by sending a message).
- * 6. Callback closes SHBrowseForFolder dialog box.
- * 7. Check that there is a new folder inside the test folder.
- * 8. Remove the test folder and any subfolders.
+ * 4. Hook up SHBrowseForFolder dialog box with callback.
+ * 5. Display SHBrowseForFolder dialog box.
+ * 6. Callback activates "Make New Folder" button(using ALT-m).
+ * 7. Callback types in new folder name and hits enter.
+ * 8. Callback closes SHBrowseForFolder dialog box.
+ * 9. Check that there is a new folder inside the test folder.
+ * 10. Check that the new folder has the typed in name.
+ * 11. Remove the test folder and any subfolders.
*/
static void test_click_make_new_folder_button(void)
{
@@ -107,6 +129,7 @@ static void test_click_make_new_folder_button(void)
IShellFolder *test_folder_object;
char test_folder_path[MAX_PATH];
WCHAR test_folder_pathW[MAX_PATH];
+ char new_folder_path[MAX_PATH];
char selected_folder[MAX_PATH];
const CHAR title[] = "test_click_make_new_folder_button";
int number_of_folders = -1;
@@ -163,6 +186,14 @@ static void test_click_make_new_folder_button(void)
todo_wine ok(number_of_folders == 1 || broken(number_of_folders == 0) /* W98, W2K */,
"Clicking \"Make New Folder\" button did not result in a new folder.\n");
+ /* There should be a new folder foo inside the test folder */
+ strcpy(new_folder_path, test_folder_path);
+ strcat(new_folder_path, new_folder_name);
+
+ todo_wine ok(does_folder_or_file_exist(new_folder_path)
+ || broken(!does_folder_or_file_exist(new_folder_path)) /* W95, W98, W2K */,
+ "Expected a new folder called %s\n", new_folder_name);
+
/* Remove test folder and any subfolders created in this test */
shfileop.hwnd = NULL;
shfileop.wFunc = FO_DELETE;
--
1.7.0.4
More information about the wine-patches
mailing list