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
];
205 MultiByteToWideChar(CP_ACP
, 0, startup
, -1, startupW
, sizeof(startupW
)/sizeof(WCHAR
));
206 pSHGetLocalizedName(startupW
, module
, MAX_PATH
, &id
);
207 ExpandEnvironmentStringsW(module
, module_expanded
, MAX_PATH
);
208 LoadStringW(GetModuleHandleW(module_expanded
), id
, localized
, MAX_PATH
);
210 WideCharToMultiByte(CP_ACP
, 0, localized
, -1, StartupTitle
, sizeof(StartupTitle
), NULL
, NULL
);
214 lstrcpyA(StartupTitle
, (strrchr(startup
, '\\') + 1));
219 static HDDEDATA CALLBACK
DdeCallback(UINT type
, UINT format
, HCONV hConv
, HSZ hsz1
, HSZ hsz2
,
220 HDDEDATA hDDEData
, ULONG_PTR data1
, ULONG_PTR data2
)
222 trace("Callback: type=%i, format=%i\n", type
, format
);
227 * Encoded String for Error Messages so that inner failures can determine
228 * what test is failing. Format is: [Code:TestNum]
230 static const char * GetStringFromTestParams(int testParams
)
233 static char testParamString
[64];
236 testNum
= testParams
& DDE_TEST_NUMMASK
;
237 switch (testParams
& DDE_TEST_CALLMASK
)
243 case DDE_TEST_CREATEGROUP
:
246 case DDE_TEST_DELETEGROUP
:
249 case DDE_TEST_SHOWGROUP
:
252 case DDE_TEST_ADDITEM
:
255 case DDE_TEST_DELETEITEM
:
258 case DDE_TEST_COMPOUND
:
263 sprintf(testParamString
, " [%s:%i]", callId
, testNum
);
264 return testParamString
;
267 /* Transfer DMLERR's into text readable strings for Error Messages */
268 #define DMLERR_TO_STR(x) case x: return#x;
269 static const char * GetStringFromError(UINT err
)
273 DMLERR_TO_STR(DMLERR_NO_ERROR
);
274 DMLERR_TO_STR(DMLERR_ADVACKTIMEOUT
);
275 DMLERR_TO_STR(DMLERR_BUSY
);
276 DMLERR_TO_STR(DMLERR_DATAACKTIMEOUT
);
277 DMLERR_TO_STR(DMLERR_DLL_NOT_INITIALIZED
);
278 DMLERR_TO_STR(DMLERR_DLL_USAGE
);
279 DMLERR_TO_STR(DMLERR_EXECACKTIMEOUT
);
280 DMLERR_TO_STR(DMLERR_INVALIDPARAMETER
);
281 DMLERR_TO_STR(DMLERR_LOW_MEMORY
);
282 DMLERR_TO_STR(DMLERR_MEMORY_ERROR
);
283 DMLERR_TO_STR(DMLERR_NOTPROCESSED
);
284 DMLERR_TO_STR(DMLERR_NO_CONV_ESTABLISHED
);
285 DMLERR_TO_STR(DMLERR_POKEACKTIMEOUT
);
286 DMLERR_TO_STR(DMLERR_POSTMSG_FAILED
);
287 DMLERR_TO_STR(DMLERR_REENTRANCY
);
288 DMLERR_TO_STR(DMLERR_SERVER_DIED
);
289 DMLERR_TO_STR(DMLERR_SYS_ERROR
);
290 DMLERR_TO_STR(DMLERR_UNADVACKTIMEOUT
);
291 DMLERR_TO_STR(DMLERR_UNFOUND_QUEUE_ID
);
293 return "Unknown DML Error";
297 /* Helper Function to Transfer DdeGetLastError into a String */
298 static const char * GetDdeLastErrorStr(DWORD instance
)
300 UINT err
= DdeGetLastError(instance
);
302 return GetStringFromError(err
);
305 /* Execute a Dde Command and return the error & result */
306 /* Note: Progman DDE always returns a pointer to 0x00000001 on a successful result */
307 static void DdeExecuteCommand(DWORD instance
, HCONV hConv
, const char *strCmd
, HDDEDATA
*hData
, UINT
*err
, int testParams
)
311 command
= DdeCreateDataHandle(instance
, (LPBYTE
) strCmd
, strlen(strCmd
)+1, 0, 0L, 0, 0);
312 ok (command
!= NULL
, "DdeCreateDataHandle Error %s.%s\n",
313 GetDdeLastErrorStr(instance
), GetStringFromTestParams(testParams
));
314 *hData
= DdeClientTransaction((void *) command
,
323 /* hData is technically a pointer, but for Program Manager,
324 * it is NULL (error) or 1 (success)
325 * TODO: Check other versions of Windows to verify 1 is returned.
326 * While it is unlikely that anyone is actually testing that the result is 1
327 * if all versions of windows return 1, Wine should also.
331 *err
= DdeGetLastError(instance
);
335 *err
= DMLERR_NO_ERROR
;
338 ok(*hData
== (HDDEDATA
) 1, "Expected HDDEDATA Handle == 1, actually %p.%s\n",
339 *hData
, GetStringFromTestParams(testParams
));
342 DdeFreeDataHandle(command
);
346 * Check if Window is onscreen with the appropriate name.
348 * Windows are not created synchronously. So we do not know
349 * when and if the window will be created/shown on screen.
350 * This function implements a polling mechanism to determine
352 * A more complicated method would be to use SetWindowsHookEx.
353 * Since polling worked fine in my testing, no reason to implement
354 * the other. Comments about other methods of determining when
355 * window creation happened were not encouraging (not including
358 static void CheckWindowCreated(const char *winName
, int closeWindow
, int testParams
)
363 /* Poll for Window Creation */
364 for (i
= 0; window
== NULL
&& i
< PDDE_POLL_NUM
; i
++)
366 Sleep(PDDE_POLL_TIME
);
367 window
= FindWindowA(NULL
, winName
);
369 ok (window
!= NULL
, "Window \"%s\" was not created in %i seconds - assumed failure.%s\n",
370 winName
, PDDE_POLL_NUM
*PDDE_POLL_TIME
/1000, GetStringFromTestParams(testParams
));
372 /* Close Window as desired. */
373 if (window
!= NULL
&& closeWindow
)
375 SendMessageA(window
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
379 /* Check for Existence (or non-existence) of a file or group
380 * When testing for existence of a group, groupName is not needed
382 static void CheckFileExistsInProgramGroups(const char *nameToCheck
, int shouldExist
, int isGroup
,
383 const char *groupName
, int testParams
)
389 lstrcpyA(path
, ProgramsDir
);
391 len
= strlen(path
) + strlen(nameToCheck
)+1;
392 if (groupName
!= NULL
)
394 len
+= strlen(groupName
)+1;
396 ok (len
<= MAX_PATH
, "Path Too Long.%s\n", GetStringFromTestParams(testParams
));
399 if (groupName
!= NULL
)
402 strcat(path
, groupName
);
405 strcat(path
, nameToCheck
);
406 attributes
= GetFileAttributes(path
);
409 ok (attributes
== INVALID_FILE_ATTRIBUTES
, "File exists and shouldn't %s.%s\n",
410 path
, GetStringFromTestParams(testParams
));
412 if (attributes
== INVALID_FILE_ATTRIBUTES
)
414 ok (FALSE
, "Created File %s doesn't exist.%s\n", path
, GetStringFromTestParams(testParams
));
415 } else if (isGroup
) {
416 ok (attributes
& FILE_ATTRIBUTE_DIRECTORY
, "%s is not a folder (attr=%x).%s\n",
417 path
, attributes
, GetStringFromTestParams(testParams
));
419 ok (attributes
& FILE_ATTRIBUTE_ARCHIVE
, "Created File %s has wrong attributes (%x).%s\n",
420 path
, attributes
, GetStringFromTestParams(testParams
));
426 /* Create Group Test.
427 * command and expected_result.
428 * if expected_result is DMLERR_NO_ERROR, test
429 * 1. group was created
432 static void CreateGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
433 const char *groupName
, const char *windowTitle
, int testParams
)
438 /* Execute Command & Check Result */
439 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
442 ok (expected_result
== error
, "CreateGroup %s: Expected Error %s, received %s.%s\n",
443 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
444 GetStringFromTestParams(testParams
));
448 if (error
== DMLERR_NO_ERROR
)
451 /* Check if Group Now Exists */
452 CheckFileExistsInProgramGroups(groupName
, TRUE
, TRUE
, NULL
, testParams
);
453 /* Check if Window is Open (polling) */
454 CheckWindowCreated(windowTitle
, TRUE
, testParams
);
459 * DDE command, expected_result, and the group name to check for existence
460 * if expected_result is DMLERR_NO_ERROR, test
463 static void ShowGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
464 const char *groupName
, const char *windowTitle
, int closeAfterShowing
, int testParams
)
469 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
470 /* todo_wine... Is expected to fail, wine stubbed functions DO fail */
471 /* TODO REMOVE THIS CODE!!! */
472 if (expected_result
== DMLERR_NOTPROCESSED
)
474 ok (expected_result
== error
, "ShowGroup %s: Expected Error %s, received %s.%s\n",
475 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
476 GetStringFromTestParams(testParams
));
480 ok (expected_result
== error
, "ShowGroup %s: Expected Error %s, received %s.%s\n",
481 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
482 GetStringFromTestParams(testParams
));
486 if (error
== DMLERR_NO_ERROR
)
488 /* Check if Window is Open (polling) */
489 CheckWindowCreated(windowTitle
, closeAfterShowing
, testParams
);
493 /* Delete Group Test.
494 * DDE command, expected_result, and the group name to check for existence
495 * if expected_result is DMLERR_NO_ERROR, test
496 * 1. group does not exist
498 static void DeleteGroupTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
499 const char *groupName
, int testParams
)
504 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
507 ok (expected_result
== error
, "DeleteGroup %s: Expected Error %s, received %s.%s\n",
508 groupName
, GetStringFromError(expected_result
), GetStringFromError(error
),
509 GetStringFromTestParams(testParams
));
512 if (error
== DMLERR_NO_ERROR
)
514 /* Check that Group does not exist */
515 CheckFileExistsInProgramGroups(groupName
, FALSE
, TRUE
, NULL
, testParams
);
520 * DDE command, expected result, and group and file name where it should exist.
521 * checks to make sure error code matches expected error code
522 * checks to make sure item exists if successful
524 static void AddItemTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
525 const char *fileName
, const char *groupName
, int testParams
)
530 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
533 ok (expected_result
== error
, "AddItem %s: Expected Error %s, received %s.%s\n",
534 fileName
, GetStringFromError(expected_result
), GetStringFromError(error
),
535 GetStringFromTestParams(testParams
));
538 if (error
== DMLERR_NO_ERROR
)
540 /* Check that File exists */
541 CheckFileExistsInProgramGroups(fileName
, TRUE
, FALSE
, groupName
, testParams
);
546 * DDE command, expected result, and group and file name where it should exist.
547 * checks to make sure error code matches expected error code
548 * checks to make sure item does not exist if successful
550 static void DeleteItemTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
551 const char *fileName
, const char *groupName
, int testParams
)
556 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
559 ok (expected_result
== error
, "DeleteItem %s: Expected Error %s, received %s.%s\n",
560 fileName
, GetStringFromError(expected_result
), GetStringFromError(error
),
561 GetStringFromTestParams(testParams
));
564 if (error
== DMLERR_NO_ERROR
)
566 /* Check that File does not exist */
567 CheckFileExistsInProgramGroups(fileName
, FALSE
, FALSE
, groupName
, testParams
);
571 /* Compound Command Test.
572 * not really generic, assumes command of the form:
573 * [CreateGroup ...][AddItem ...][AddItem ...]
574 * All samples I've seen using Compound were of this form (CreateGroup,
575 * AddItems) so this covers minimum expected functionality.
577 static void CompoundCommandTest(DWORD instance
, HCONV hConv
, const char *command
, UINT expected_result
,
578 const char *groupName
, const char *windowTitle
, const char *fileName1
,
579 const char *fileName2
, int testParams
)
584 DdeExecuteCommand(instance
, hConv
, command
, &hData
, &error
, testParams
);
587 ok (expected_result
== error
, "Compound String %s: Expected Error %s, received %s.%s\n",
588 command
, GetStringFromError(expected_result
), GetStringFromError(error
),
589 GetStringFromTestParams(testParams
));
592 if (error
== DMLERR_NO_ERROR
)
594 /* Check that File exists */
595 CheckFileExistsInProgramGroups(groupName
, TRUE
, TRUE
, NULL
, testParams
);
596 CheckWindowCreated(windowTitle
, FALSE
, testParams
);
597 CheckFileExistsInProgramGroups(fileName1
, TRUE
, FALSE
, groupName
, testParams
);
598 CheckFileExistsInProgramGroups(fileName2
, TRUE
, FALSE
, groupName
, testParams
);
602 static void CreateAddItemText(char *itemtext
, const char *cmdline
, const char *name
)
604 lstrcpyA(itemtext
, "[AddItem(");
605 lstrcatA(itemtext
, cmdline
);
606 lstrcatA(itemtext
, ",");
607 lstrcatA(itemtext
, name
);
608 lstrcatA(itemtext
, ")]");
611 /* 1st set of tests */
612 static int DdeTestProgman(DWORD instance
, HCONV hConv
)
617 char temppath
[MAX_PATH
];
618 char f1g1
[MAX_PATH
], f2g1
[MAX_PATH
], f3g1
[MAX_PATH
], f1g3
[MAX_PATH
], f2g3
[MAX_PATH
];
619 char itemtext
[MAX_PATH
+ 20];
620 char comptext
[2 * (MAX_PATH
+ 20) + 21];
623 /* Invalid Command */
624 DdeExecuteCommand(instance
, hConv
, "[InvalidCommand()]", &hData
, &error
, DDE_TEST_MISC
|testnum
++);
625 ok (error
== DMLERR_NOTPROCESSED
, "InvalidCommand(), expected error %s, received %s.\n",
626 GetStringFromError(DMLERR_NOTPROCESSED
), GetStringFromError(error
));
628 /* On Vista+ the files have to exist when adding a link */
629 GetTempPathA(MAX_PATH
, temppath
);
630 GetTempFileNameA(temppath
, "dde", 0, f1g1
);
631 GetTempFileNameA(temppath
, "dde", 0, f2g1
);
632 GetTempFileNameA(temppath
, "dde", 0, f3g1
);
633 GetTempFileNameA(temppath
, "dde", 0, f1g3
);
634 GetTempFileNameA(temppath
, "dde", 0, f2g3
);
636 /* CreateGroup Tests (including AddItem, DeleteItem) */
637 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, DDE_TEST_CREATEGROUP
|testnum
++);
638 CreateAddItemText(itemtext
, f1g1
, "f1g1Name");
639 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f1g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
640 CreateAddItemText(itemtext
, f2g1
, "f2g1Name");
641 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f2g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
642 DeleteItemTest(instance
, hConv
, "[DeleteItem(f2g1Name)]", DMLERR_NO_ERROR
, "f2g1Name.lnk", "Group1", DDE_TEST_DELETEITEM
|testnum
++);
643 CreateAddItemText(itemtext
, f3g1
, "f3g1Name");
644 AddItemTest(instance
, hConv
, itemtext
, DMLERR_NO_ERROR
, "f3g1Name.lnk", "Group1", DDE_TEST_ADDITEM
|testnum
++);
645 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", Group2Title
, DDE_TEST_CREATEGROUP
|testnum
++);
646 /* Create Group that already exists - same instance */
647 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, DDE_TEST_CREATEGROUP
|testnum
++);
649 /* ShowGroup Tests */
650 ShowGroupTest(instance
, hConv
, "[ShowGroup(Group1)]", DMLERR_NOTPROCESSED
, "Group1", Group1Title
, TRUE
, DDE_TEST_SHOWGROUP
|testnum
++);
651 DeleteItemTest(instance
, hConv
, "[DeleteItem(f3g1Name)]", DMLERR_NO_ERROR
, "f3g1Name.lnk", "Group1", DDE_TEST_DELETEITEM
|testnum
++);
652 ShowGroupTest(instance
, hConv
, "[ShowGroup(Startup,0)]", DMLERR_NO_ERROR
, "Startup", StartupTitle
, TRUE
, DDE_TEST_SHOWGROUP
|testnum
++);
653 ShowGroupTest(instance
, hConv
, "[ShowGroup(Group1,0)]", DMLERR_NO_ERROR
, "Group1", Group1Title
, FALSE
, DDE_TEST_SHOWGROUP
|testnum
++);
655 /* DeleteGroup Test - Note that Window is Open for this test */
656 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group1)]", DMLERR_NO_ERROR
, "Group1", DDE_TEST_DELETEGROUP
|testnum
++);
658 /* Compound Execute String Command */
659 lstrcpyA(comptext
, "[CreateGroup(Group3)]");
660 CreateAddItemText(itemtext
, f1g3
, "f1g3Name");
661 lstrcatA(comptext
, itemtext
);
662 CreateAddItemText(itemtext
, f2g3
, "f2g3Name");
663 lstrcatA(comptext
, itemtext
);
664 CompoundCommandTest(instance
, hConv
, comptext
, DMLERR_NO_ERROR
, "Group3", Group3Title
, "f1g3Name.lnk", "f2g3Name.lnk", DDE_TEST_COMPOUND
|testnum
++);
666 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group3)]", DMLERR_NO_ERROR
, "Group3", DDE_TEST_DELETEGROUP
|testnum
++);
668 /* Full Parameters of Add Item */
669 /* AddItem(CmdLine[,Name[,IconPath[,IconIndex[,xPos,yPos[,DefDir[,HotKey[,fMinimize[fSeparateSpace]]]]]]]) */
680 /* 2nd set of tests - 2nd connection */
681 static void DdeTestProgman2(DWORD instance
, HCONV hConv
, int testnum
)
683 /* Create Group that already exists on a separate connection */
684 CreateGroupTest(instance
, hConv
, "[CreateGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", Group2Title
, DDE_TEST_CREATEGROUP
|testnum
++);
685 DeleteGroupTest(instance
, hConv
, "[DeleteGroup(Group2)]", DMLERR_NO_ERROR
, "Group2", DDE_TEST_DELETEGROUP
|testnum
++);
688 START_TEST(progman_dde
)
696 init_function_pointers();
699 /* Initialize DDE Instance */
700 err
= DdeInitialize(&instance
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
701 ok (err
== DMLERR_NO_ERROR
, "DdeInitialize Error %s\n", GetStringFromError(err
));
703 /* Create Connection */
704 hszProgman
= DdeCreateStringHandle(instance
, "PROGMAN", CP_WINANSI
);
705 ok (hszProgman
!= NULL
, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance
));
706 hConv
= DdeConnect(instance
, hszProgman
, hszProgman
, NULL
);
707 ok (DdeFreeStringHandle(instance
, hszProgman
), "DdeFreeStringHandle failure\n");
708 /* Seeing failures on early versions of Windows Connecting to progman, exit if connection fails */
711 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");
716 testnum
= DdeTestProgman(instance
, hConv
);
719 ok (DdeDisconnect(hConv
), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance
));
720 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");
722 /* 2nd Instance (Followup Tests) */
723 /* Initialize DDE Instance */
725 err
= DdeInitialize(&instance
, DdeCallback
, APPCMD_CLIENTONLY
, 0);
726 ok (err
== DMLERR_NO_ERROR
, "DdeInitialize Error %s\n", GetStringFromError(err
));
728 /* Create Connection */
729 hszProgman
= DdeCreateStringHandle(instance
, "PROGMAN", CP_WINANSI
);
730 ok (hszProgman
!= NULL
, "DdeCreateStringHandle Error %s\n", GetDdeLastErrorStr(instance
));
731 hConv
= DdeConnect(instance
, hszProgman
, hszProgman
, NULL
);
732 ok (hConv
!= NULL
, "DdeConnect Error %s\n", GetDdeLastErrorStr(instance
));
733 ok (DdeFreeStringHandle(instance
, hszProgman
), "DdeFreeStringHandle failure\n");
736 DdeTestProgman2(instance
, hConv
, testnum
);
739 ok (DdeDisconnect(hConv
), "DdeDisonnect Error %s\n", GetDdeLastErrorStr(instance
));
740 ok (DdeUninitialize(instance
), "DdeUninitialize failed\n");