2 * Unit test of the Program Manager DDE Interfaces
4 * Copyright 2009 Mikey Alexander
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 /* DDE Program Manager Tests
22 * - Covers basic CreateGroup, ShowGroup, DeleteGroup, AddItem, and DeleteItem
24 * - Todo: Handle CommonGroupFlag
25 * Better AddItem Tests (Lots of parameters to test)
26 * Tests for Invalid Characters in Names / Invalid Parameters
30 #include <wine/test.h>
37 /* Timeout on DdeClientTransaction Call */
38 #define MS_TIMEOUT_VAL 1000
39 /* # of times to poll for window creation */
40 #define PDDE_POLL_NUM 150
41 /* time to sleep between polls */
42 #define PDDE_POLL_TIME 300
45 #define DDE_TEST_MISC 0x00010000
46 #define DDE_TEST_CREATEGROUP 0x00020000
47 #define DDE_TEST_DELETEGROUP 0x00030000
48 #define DDE_TEST_SHOWGROUP 0x00040000
49 #define DDE_TEST_ADDITEM 0x00050000
50 #define DDE_TEST_DELETEITEM 0x00060000
51 #define DDE_TEST_COMPOUND 0x00070000
52 #define DDE_TEST_CALLMASK 0x00ff0000
54 #define DDE_TEST_NUMMASK 0x0000ffff
56 static HRESULT (WINAPI
*pSHGetLocalizedName
)(LPCWSTR
, LPWSTR
, UINT
, int *);
57 static BOOL (WINAPI
*pSHGetSpecialFolderPathA
)(HWND
, LPSTR
, int, BOOL
);
58 static BOOL (WINAPI
*pReadCabinetState
)(CABINETSTATE
*, int);
60 static void init_function_pointers(void)
64 hmod
= GetModuleHandleA("shell32.dll");
65 pSHGetLocalizedName
= (void*)GetProcAddress(hmod
, "SHGetLocalizedName");
66 pSHGetSpecialFolderPathA
= (void*)GetProcAddress(hmod
, "SHGetSpecialFolderPathA");
67 pReadCabinetState
= (void*)GetProcAddress(hmod
, "ReadCabinetState");
68 if (!pReadCabinetState
)
69 pReadCabinetState
= (void*)GetProcAddress(hmod
, (LPSTR
)651);
72 static BOOL
use_common(void)
75 static BOOL (WINAPI
*pIsNTAdmin
)(DWORD
, LPDWORD
);
77 /* IsNTAdmin() is available on all platforms. */
78 hmod
= LoadLibraryA("advpack.dll");
79 pIsNTAdmin
= (void*)GetProcAddress(hmod
, "IsNTAdmin");
81 if (!pIsNTAdmin(0, NULL
))
83 /* We are definitely not an administrator */
89 /* If we end up here we are on NT4+ as Win9x and WinMe don't have the
90 * notion of administrators (as we need it).
93 /* As of Vista we should always use the users directory. Tests with the
94 * real Administrator account on Windows 7 proved this.
96 * FIXME: We need a better way of identifying Vista+ as currently this check
97 * also covers Wine and we don't know yet which behavior we want to follow.
99 if (pSHGetLocalizedName
)
105 static BOOL
full_title(void)
109 memset(&cs
, 0, sizeof(cs
));
110 if (pReadCabinetState
)
112 pReadCabinetState(&cs
, sizeof(cs
));
119 win_skip("ReadCabinetState is not available, reading registry directly\n");
120 RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState", &key
);
122 RegQueryValueExA(key
, "Settings", NULL
, NULL
, (LPBYTE
)&cs
, &size
);
126 return (cs
.fFullPathTitle
== -1);
129 static char ProgramsDir
[MAX_PATH
];
131 static char Group1Title
[MAX_PATH
] = "Group1";
132 static char Group2Title
[MAX_PATH
] = "Group2";
133 static char Group3Title
[MAX_PATH
] = "Group3";
134 static char StartupTitle
[MAX_PATH
] = "Startup";
136 static void init_strings(void)
138 char startup
[MAX_PATH
];
139 char commonprograms
[MAX_PATH
];
140 char programs
[MAX_PATH
];
142 if (pSHGetSpecialFolderPathA
)
144 pSHGetSpecialFolderPathA(NULL
, programs
, CSIDL_PROGRAMS
, FALSE
);
145 pSHGetSpecialFolderPathA(NULL
, commonprograms
, CSIDL_COMMON_PROGRAMS
, FALSE
);
146 pSHGetSpecialFolderPathA(NULL
, startup
, CSIDL_STARTUP
, FALSE
);
153 /* Older Win9x and NT4 */
155 RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key
);
156 size
= sizeof(programs
);
157 RegQueryValueExA(key
, "Programs", NULL
, NULL
, (LPBYTE
)&programs
, &size
);
158 size
= sizeof(startup
);
159 RegQueryValueExA(key
, "Startup", NULL
, NULL
, (LPBYTE
)&startup
, &size
);
162 RegOpenKeyA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", &key
);
163 size
= sizeof(commonprograms
);
164 RegQueryValueExA(key
, "Common Programs", NULL
, NULL
, (LPBYTE
)&commonprograms
, &size
);
168 /* ProgramsDir on Vista+ is always the users one (CSIDL_PROGRAMS). Before Vista
169 * it depends on whether the user is an administrator (CSIDL_COMMON_PROGRAMS) or
170 * not (CSIDL_PROGRAMS).
173 lstrcpyA(ProgramsDir
, commonprograms
);
175 lstrcpyA(ProgramsDir
, programs
);
179 lstrcpyA(Group1Title
, ProgramsDir
);
180 lstrcatA(Group1Title
, "\\Group1");
181 lstrcpyA(Group2Title
, ProgramsDir
);
182 lstrcatA(Group2Title
, "\\Group2");
183 lstrcpyA(Group3Title
, ProgramsDir
);
184 lstrcatA(Group3Title
, "\\Group3");
186 lstrcpyA(StartupTitle
, startup
);
190 /* Vista has the nice habit of displaying the full path in English
191 * and the short one localized. CSIDL_STARTUP on Vista gives us the
192 * English version so we have to 'translate' this one.
194 * MSDN claims it should be used for files not folders but this one
195 * suits our purposes just fine.
197 if (pSHGetLocalizedName
)
199 WCHAR startupW
[MAX_PATH
];
200 WCHAR module
[MAX_PATH
];
201 WCHAR module_expanded
[MAX_PATH
];
202 WCHAR localized
[MAX_PATH
];
206 MultiByteToWideChar(CP_ACP
, 0, startup
, -1, startupW
, sizeof(startupW
)/sizeof(WCHAR
));
207 hr
= pSHGetLocalizedName(startupW
, module
, MAX_PATH
, &id
);
208 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
209 /* check to be removed when SHGetLocalizedName is implemented */
212 ExpandEnvironmentStringsW(module
, module_expanded
, MAX_PATH
);
213 LoadStringW(GetModuleHandleW(module_expanded
), id
, localized
, MAX_PATH
);
215 WideCharToMultiByte(CP_ACP
, 0, localized
, -1, StartupTitle
, sizeof(StartupTitle
), NULL
, NULL
);
218 lstrcpyA(StartupTitle
, (strrchr(startup
, '\\') + 1));
222 lstrcpyA(StartupTitle
, (strrchr(startup
, '\\') + 1));
227 static HDDEDATA CALLBACK
DdeCallback(UINT type
, UINT format
, HCONV hConv
, HSZ hsz1
, HSZ hsz2
,
228 HDDEDATA hDDEData
, ULONG_PTR data1
, ULONG_PTR data2
)
230 trace("Callback: type=%i, format=%i\n", type
, format
);
235 * Encoded String for Error Messages so that inner failures can determine
236 * what test is failing. Format is: [Code:TestNum]
238 static const char * GetStringFromTestParams(int testParams
)
241 static char testParamString
[64];
244 testNum
= testParams
& DDE_TEST_NUMMASK
;
245 switch (testParams
& DDE_TEST_CALLMASK
)
251 case DDE_TEST_CREATEGROUP
:
254 case DDE_TEST_DELETEGROUP
:
257 case DDE_TEST_SHOWGROUP
:
260 case DDE_TEST_ADDITEM
:
263 case DDE_TEST_DELETEITEM
:
266 case DDE_TEST_COMPOUND
:
271 sprintf(testParamString
, " [%s:%i]", callId
, testNum
);
272 return testParamString
;
275 /* Transfer DMLERR's into text readable strings for Error Messages */
276 #define DMLERR_TO_STR(x) case x: return#x;
277 static const char * GetStringFromError(UINT err
)
281 DMLERR_TO_STR(DMLERR_NO_ERROR
);
282 DMLERR_TO_STR(DMLERR_ADVACKTIMEOUT
);
283 DMLERR_TO_STR(DMLERR_BUSY
);
284 DMLERR_TO_STR(DMLERR_DATAACKTIMEOUT
);
285 DMLERR_TO_STR(DMLERR_DLL_NOT_INITIALIZED
);
286 DMLERR_TO_STR(DMLERR_DLL_USAGE
);
287 DMLERR_TO_STR(DMLERR_EXECACKTIMEOUT
);
288 DMLERR_TO_STR(DMLERR_INVALIDPARAMETER
);
289 DMLERR_TO_STR(DMLERR_LOW_MEMORY
);
290 DMLERR_TO_STR(DMLERR_MEMORY_ERROR
);
291 DMLERR_TO_STR(DMLERR_NOTPROCESSED
);
292 DMLERR_TO_STR(DMLERR_NO_CONV_ESTABLISHED
);
293 DMLERR_TO_STR(DMLERR_POKEACKTIMEOUT
);
294 DMLERR_TO_STR(DMLERR_POSTMSG_FAILED
);
295 DMLERR_TO_STR(DMLERR_REENTRANCY
);
296 DMLERR_TO_STR(DMLERR_SERVER_DIED
);
297 DMLERR_TO_STR(DMLERR_SYS_ERROR
);
298 DMLERR_TO_STR(DMLERR_UNADVACKTIMEOUT
);
299 DMLERR_TO_STR(DMLERR_UNFOUND_QUEUE_ID
);
301 return "Unknown DML Error";
305 /* Helper Function to Transfer DdeGetLastError into a String */
306 static const char * GetDdeLastErrorStr(DWORD instance
)
308 UINT err
= DdeGetLastError(instance
);
310 return GetStringFromError(err
);
313 /* Execute a Dde Command and return the error & result */
314 /* Note: Progman DDE always returns a pointer to 0x00000001 on a successful result */
315 static void DdeExecuteCommand(DWORD instance
, HCONV hConv
, const char *strCmd
, HDDEDATA
*hData
, UINT
*err
, int testParams
)
319 command
= DdeCreateDataHandle(instance
, (LPBYTE
) strCmd
, strlen(strCmd
)+1, 0, 0L, 0, 0);
320 ok (command
!= NULL
, "DdeCreateDataHandle Error %s.%s\n",
321 GetDdeLastErrorStr(instance
), GetStringFromTestParams(testParams
));
322 *hData
= DdeClientTransaction((void *) command
,
331 /* hData is technically a pointer, but for Program Manager,
332 * it is NULL (error) or 1 (success)
333 * TODO: Check other versions of Windows to verify 1 is returned.
334 * While it is unlikely that anyone is actually testing that the result is 1
335 * if all versions of windows return 1, Wine should also.
339 *err
= DdeGetLastError(instance
);
343 *err
= DMLERR_NO_ERROR
;
346 ok(*hData
== (HDDEDATA
) 1, "Expected HDDEDATA Handle == 1, actually %p.%s\n",
347 *hData
, GetStringFromTestParams(testParams
));
350 DdeFreeDataHandle(command
);
354 * Check if Window is onscreen with the appropriate name.
356 * Windows are not created synchronously. So we do not know
357 * when and if the window will be created/shown on screen.
358 * This function implements a polling mechanism to determine
360 * A more complicated method would be to use SetWindowsHookEx.
361 * Since polling worked fine in my testing, no reason to implement
362 * the other. Comments about other methods of determining when
363 * window creation happened were not encouraging (not including
366 static HWND
CheckWindowCreated(const char *winName
, BOOL closeWindow
, int testParams
)
371 /* Poll for Window Creation */
372 for (i
= 0; window
== NULL
&& i
< PDDE_POLL_NUM
; i
++)
374 Sleep(PDDE_POLL_TIME
);
375 /* Specify the window class name to make sure what we find is really an
376 * Explorer window. Explorer used two different window classes so try
379 window
= FindWindowA("ExplorerWClass", winName
);
381 window
= FindWindowA("CabinetWClass", winName
);
383 ok (window
!= NULL
, "Window \"%s\" was not created in %i seconds - assumed failure.%s\n",
384 winName
, PDDE_POLL_NUM
*PDDE_POLL_TIME
/1000, GetStringFromTestParams(testParams
));
386 /* Close Window as desired. */
387 if (window
!= NULL
&& closeWindow
)
389 SendMessageA(window
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
395 /* Check for Existence (or non-existence) of a file or group
396 * When testing for existence of a group, groupName is not needed
398 static void CheckFileExistsInProgramGroups(const char *nameToCheck
, BOOL shouldExist
, BOOL isGroup
,
399 const char *groupName
, int testParams
)
405 lstrcpyA(path
, ProgramsDir
);
407 len
= strlen(path
) + strlen(nameToCheck
)+1;
408 if (groupName
!= NULL
)
410 len
+= strlen(groupName
)+1;
412 ok (len
<= MAX_PATH
, "Path Too Long.%s\n", GetStringFromTestParams(testParams
));
415 if (groupName
!= NULL
)
418 strcat(path
, groupName
);
421 strcat(path
, nameToCheck
);
422 attributes
= GetFileAttributesA(path
);
425 ok (attributes
== INVALID_FILE_ATTRIBUTES
, "File exists and shouldn't %s.%s\n",
426 path
, GetStringFromTestParams(testParams
));
428 if (attributes
== INVALID_FILE_ATTRIBUTES
)
430 ok (FALSE
, "Created File %s doesn't exist.%s\n", path
, GetStringFromTestParams(testParams
));
431 } else if (isGroup
) {
432 ok (attributes
& FILE_ATTRIBUTE_DIRECTORY
, "%s is not a folder (attr=%x).%s\n",
433 path
, attributes
, GetStringFromTestParams(testParams
));
435 ok (attributes
& FILE_ATTRIBUTE_ARCHIVE
, "Created File %s has wrong attributes (%x).%s\n",
436 path
, attributes
, GetStringFromTestParams(testParams
));
442 /* Create Group Test.
443 * command and expected_result.
444 * if expected_result is DMLERR_NO_ERROR, test
445 * 1. group was created
448 static void CreateGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
449 const char *groupName
, const char *windowTitle
, int testParams
)
454 /* Execute Command & Check Result */
455 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
458 ok (expected_result
== error
, "CreateGroup %s: Expected Error %s, received %s.%s\n",
459 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
460 GetStringFromTestParams(testParams
));
464 if (error
== DMLERR_NO_ERROR
)
467 /* Check if Group Now Exists */
468 CheckFileExistsInProgramGroups(groupName
, TRUE
, TRUE
, NULL
, testParams
);
469 /* Check if Window is Open (polling) */
470 CheckWindowCreated(windowTitle
, TRUE
, testParams
);
475 * DDE command, expected_result, and the group name to check for existence
476 * if expected_result is DMLERR_NO_ERROR, test
479 static HWND
ShowGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
480 const char *groupName
, const char *windowTitle
, BOOL closeAfterShowing
, int testParams
)
486 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
487 /* todo_wine... Is expected to fail, wine stubbed functions DO fail */
488 /* TODO REMOVE THIS CODE!!! */
489 todo_wine_if (expected_result
!= DMLERR_NOTPROCESSED
)
490 ok (expected_result
== error
, "ShowGroup %s: Expected Error %s, received %s.%s\n",
491 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
492 GetStringFromTestParams(testParams
));
494 if (error
== DMLERR_NO_ERROR
)
496 /* Check if Window is Open (polling) */
497 hwnd
= CheckWindowCreated(windowTitle
, closeAfterShowing
, testParams
);
502 /* Delete Group Test.
503 * DDE command, expected_result, and the group name to check for existence
504 * if expected_result is DMLERR_NO_ERROR, test
505 * 1. group does not exist
507 static void DeleteGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
508 const char *groupName
, int testParams
)
513 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
516 ok (expected_result
== error
, "DeleteGroup %s: Expected Error %s, received %s.%s\n",
517 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
518 GetStringFromTestParams(testParams
));
521 if (error
== DMLERR_NO_ERROR
)
523 /* Check that Group does not exist */
524 CheckFileExistsInProgramGroups(groupName
, FALSE
, TRUE
, NULL
, testParams
);
529 * DDE command, expected result, and group and file name where it should exist.
530 * checks to make sure error code matches expected error code
531 * checks to make sure item exists if successful
533 static void AddItemTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
534 const char *fileName
, const char *groupName
, int testParams
)
539 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
542 ok (expected_result
== error
, "AddItem %s: Expected Error %s, received %s.%s\n",
543 fileName
, GetStringFromError(expected_result
), GetStringFromError(error
),
544 GetStringFromTestParams(testParams
));
547 if (error
== DMLERR_NO_ERROR
)
549 /* Check that File exists */
550 CheckFileExistsInProgramGroups(fileName
, TRUE
, FALSE
, groupName
, testParams
);
555 * DDE command, expected result, and group and file name where it should exist.
556 * checks to make sure error code matches expected error code
557 * checks to make sure item does not exist if successful
559 static void DeleteItemTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
560 const char *fileName
, const char *groupName
, int testParams
)
565 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
568 ok (expected_result
== error
, "DeleteItem %s: Expected Error %s, received %s.%s\n",
569 fileName
, GetStringFromError(expected_result
), GetStringFromError(error
),
570 GetStringFromTestParams(testParams
));
573 if (error
== DMLERR_NO_ERROR
)
575 /* Check that File does not exist */
576 CheckFileExistsInProgramGroups(fileName
, FALSE
, FALSE
, groupName
, testParams
);
580 /* Compound Command Test.
581 * not really generic, assumes command of the form:
582 * [CreateGroup ...][AddItem ...][AddItem ...]
583 * All samples I've seen using Compound were of this form (CreateGroup,
584 * AddItems) so this covers minimum expected functionality.
586 static HWND
CompoundCommandTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
587 const char *groupName
, const char *windowTitle
, const char *fileName1
,
588 const char *fileName2
, int testParams
)
594 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
597 ok (expected_result
== error
, "Compound String %s: Expected Error %s, received %s.%s\n",
598 command
, GetStringFromError(expected_result
), GetStringFromError(error
),
599 GetStringFromTestParams(testParams
));
602 if (error
== DMLERR_NO_ERROR
)
604 /* Check that File exists */
605 CheckFileExistsInProgramGroups(groupName
, TRUE
, TRUE
, NULL
, testParams
);
606 hwnd
= CheckWindowCreated(windowTitle
, FALSE
, testParams
);
607 CheckFileExistsInProgramGroups(fileName1
, TRUE
, FALSE
, groupName
, testParams
);
608 CheckFileExistsInProgramGroups(fileName2
, TRUE
, FALSE
, groupName
, testParams
);
613 static void CreateAddItemText(char *itemtext
, const char *cmdline
, const char *name
)
615 lstrcpyA(itemtext
, "[AddItem(");
616 lstrcatA(itemtext
, cmdline
);
617 lstrcatA(itemtext
, ",");
618 lstrcatA(itemtext
, name
);
619 lstrcatA(itemtext
, ")]");
622 /* 1st set of tests */
623 static int DdeTestProgman(DWORD instance
, HCONV hConv
)
628 char temppath
[MAX_PATH
];
629 char f1g1
[MAX_PATH
], f2g1
[MAX_PATH
], f3g1
[MAX_PATH
], f1g3
[MAX_PATH
], f2g3
[MAX_PATH
];
630 char itemtext
[MAX_PATH
+ 20];
631 char comptext
[2 * (MAX_PATH
+ 20) + 21];
635 /* Invalid Command */
636 DdeExecuteCommand(instance
, hConv
, "[InvalidCommand()]", &hData
, &error
, DDE_TEST_MISC
|testnum
++);
637 ok (error
== DMLERR_NOTPROCESSED
, "InvalidCommand(), expected error %s, received %s.\n",
638 GetStringFromError(DMLERR_NOTPROCESSED
), GetStringFromError(error
));
640 /* On Vista+ the files have to exist when adding a link */
641 GetTempPathA(MAX_PATH
, temppath
);
642 GetTempFileNameA(temppath
, "dde", 0, f1g1
);
643 GetTempFileNameA(temppath
, "dde", 0, f2g1
);
644 GetTempFileNameA(temppath
, "dde", 0, f3g1
);
645 GetTempFileNameA(temppath
, "dde", 0, f1g3
);
646 GetTempFileNameA(temppath
, "dde", 0, f2g3
);
648 /* CreateGroup Tests (including AddItem, DeleteItem) */
649 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, DDE_TEST_CREATEGROUP
|testnum
++);
650 CreateAddItemText(itemtext
, f1g1
, "f1g1Name");
651 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f1g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
652 CreateAddItemText(itemtext
, f2g1
, "f2g1Name");
653 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f2g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
654 DeleteItemTest(instance
, hConv
, "[DeleteItem(f2g1Name)]", DMLERR_NO_ERROR
, "f2g1Name.lnk", "Group1", DDE_TEST_DELETEITEM
|testnum
++);
655 CreateAddItemText(itemtext
, f3g1
, "f3g1Name");
656 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f3g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
657 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", Group2Title
, DDE_TEST_CREATEGROUP
|testnum
++);
658 /* Create Group that already exists - same instance */
659 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, DDE_TEST_CREATEGROUP
|testnum
++);
661 /* ShowGroup Tests */
662 ShowGroupTest(instance
, hConv
, "[ShowGroup(Group1)]", DMLERR_NOTPROCESSED
, "Group1", Group1Title
, TRUE
, DDE_TEST_SHOWGROUP
|testnum
++);
663 DeleteItemTest(instance
, hConv
, "[DeleteItem(f3g1Name)]", DMLERR_NO_ERROR
, "f3g1Name.lnk", "Group1", DDE_TEST_DELETEITEM
|testnum
++);
664 ShowGroupTest(instance
, hConv
, "[ShowGroup(Startup,0)]", DMLERR_NO_ERROR
, "Startup", StartupTitle
, TRUE
, DDE_TEST_SHOWGROUP
|testnum
++);
665 hwnd
= ShowGroupTest(instance
, hConv
, "[ShowGroup(Group1,0)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, FALSE
, DDE_TEST_SHOWGROUP
|testnum
++);
667 /* DeleteGroup Test - Note that Window is Open for this test */
668 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", DDE_TEST_DELETEGROUP
|testnum
++);
669 if (hwnd
) SendMessageA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
671 /* Compound Execute String Command */
672 lstrcpyA(comptext
, "[CreateGroup(Group3)]");
673 CreateAddItemText(itemtext
, f1g3
, "f1g3Name");
674 lstrcatA(comptext
, itemtext
);
675 CreateAddItemText(itemtext
, f2g3
, "f2g3Name");
676 lstrcatA(comptext
, itemtext
);
677 hwnd
= CompoundCommandTest(instance
, hConv
, comptext
, DMLERR_NO_ERROR
, "Group3", Group3Title
, "f1g3Name.lnk", "f2g3Name.lnk", DDE_TEST_COMPOUND
|testnum
++);
679 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group3)]", DMLERR_NO_ERROR
, "Group3", DDE_TEST_DELETEGROUP
|testnum
++);
680 if (hwnd
) SendMessageA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
682 /* Full Parameters of Add Item */
683 /* AddItem(CmdLine[,Name[,IconPath[,IconIndex[,xPos,yPos[,DefDir[,HotKey[,fMinimize[fSeparateSpace]]]]]]]) */
694 /* 2nd set of tests - 2nd connection */
695 static void DdeTestProgman2(DWORD instance
, HCONV hConv
, int testnum
)
697 /* Create Group that already exists on a separate connection */
698 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", Group2Title
, DDE_TEST_CREATEGROUP
|testnum
++);
699 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", DDE_TEST_DELETEGROUP
|testnum
++);
702 START_TEST(progman_dde
)
710 init_function_pointers();
713 /* Initialize DDE Instance */
714 err
= DdeInitializeA(&instance
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
715 ok (err
== DMLERR_NO_ERROR
, "DdeInitialize Error %s\n", GetStringFromError(err
));
717 /* Create Connection */
718 hszProgman
= DdeCreateStringHandleA(instance
, "PROGMAN", CP_WINANSI
);
719 ok (hszProgman
!= NULL
, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance
));
720 hConv
= DdeConnect(instance
, hszProgman
, hszProgman
, NULL
);
721 ok (DdeFreeStringHandle(instance
, hszProgman
), "DdeFreeStringHandle failure\n");
722 /* Seeing failures on early versions of Windows Connecting to progman, exit if connection fails */
725 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");
730 testnum
= DdeTestProgman(instance
, hConv
);
733 ok (DdeDisconnect(hConv
), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance
));
734 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");
736 /* 2nd Instance (Followup Tests) */
737 /* Initialize DDE Instance */
739 err
= DdeInitializeA(&instance
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
740 ok (err
== DMLERR_NO_ERROR
, "DdeInitialize Error %s\n", GetStringFromError(err
));
742 /* Create Connection */
743 hszProgman
= DdeCreateStringHandleA(instance
, "PROGMAN", CP_WINANSI
);
744 ok (hszProgman
!= NULL
, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance
));
745 hConv
= DdeConnect(instance
, hszProgman
, hszProgman
, NULL
);
746 ok (hConv
!= NULL
, "DdeConnect Error %s\n", GetDdeLastErrorStr(instance
));
747 ok (DdeFreeStringHandle(instance
, hszProgman
), "DdeFreeStringHandle failure\n");
750 DdeTestProgman2(instance
, hConv
, testnum
);
753 ok (DdeDisconnect(hConv
), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance
));
754 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");