/* Show Group Test. * DDE command, expected_result, and the group name to check for existence * if expected_result is DMLERR_NO_ERROR, test * 1. window is open */ static void ShowGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, const char *groupName, const char *windowTitle, int closeAfterShowing, int testParams) { HDDEDATA hData; UINT error; DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); /* todo_wine... Is expected to fail, wine stubbed functions DO fail */ /* TODO REMOVE THIS CODE!!! */ if (expected_result == DMLERR_NOTPROCESSED) { ok (expected_result == error, "ShowGroup %s: Expected Error %s, received %s.%s\n", groupName, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); } else { todo_wine { ok (expected_result == error, "ShowGroup %s: Expected Error %s, received %s.%s\n", groupName, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); } } if (error == DMLERR_NO_ERROR) { /* Check if Window is Open (polling) */ CheckWindowCreated(windowTitle, closeAfterShowing, testParams); } }
/* Create Group Test. * command and expected_result. * if expected_result is DMLERR_NO_ERROR, test * 1. group was created * 2. window is open */ static void CreateGroupTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, const char *groupName, const char *windowTitle, int testParams) { HDDEDATA hData; UINT error; /* Execute Command & Check Result */ DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); todo_wine { ok (expected_result == error, "CreateGroup %s: Expected Error %s, received %s.%s\n", groupName, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); } /* No Error */ if (error == DMLERR_NO_ERROR) { /* Check if Group Now Exists */ CheckFileExistsInProgramGroups(groupName, TRUE, TRUE, NULL, testParams); /* Check if Window is Open (polling) */ CheckWindowCreated(windowTitle, TRUE, testParams); } }
/* Compound Command Test. * not really generic, assumes command of the form: * [CreateGroup ...][AddItem ...][AddItem ...] * All samples I've seen using Compound were of this form (CreateGroup, * AddItems) so this covers minimum expected functionality. */ static HWND CompoundCommandTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, const char *groupName, const char *windowTitle, const char *fileName1, const char *fileName2, int testParams) { HDDEDATA hData; UINT error; HWND hwnd = 0; DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); todo_wine { ok (expected_result == error, "Compound String %s: Expected Error %s, received %s.%s\n", command, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); } if (error == DMLERR_NO_ERROR) { /* Check that File exists */ CheckFileExistsInProgramGroups(groupName, TRUE, TRUE, NULL, testParams); hwnd = CheckWindowCreated(windowTitle, FALSE, testParams); CheckFileExistsInProgramGroups(fileName1, TRUE, FALSE, groupName, testParams); CheckFileExistsInProgramGroups(fileName2, TRUE, FALSE, groupName, testParams); } return hwnd; }
/* Delete Item Test. * DDE command, expected result, and group and file name where it should exist. * checks to make sure error code matches expected error code * checks to make sure item does not exist if successful */ static void DeleteItemTest(DWORD instance, HCONV hConv, const char *command, UINT expected_result, const char *fileName, const char *groupName, int testParams) { HDDEDATA hData; UINT error; DdeExecuteCommand(instance, hConv, command, &hData, &error, testParams); todo_wine { ok (expected_result == error, "DeleteItem %s: Expected Error %s, received %s.%s\n", fileName, GetStringFromError(expected_result), GetStringFromError(error), GetStringFromTestParams(testParams)); } if (error == DMLERR_NO_ERROR) { /* Check that File does not exist */ CheckFileExistsInProgramGroups(fileName, FALSE, FALSE, groupName, testParams); } }
/* 1st set of tests */ static int DdeTestProgman(DWORD instance, HCONV hConv) { HDDEDATA hData; UINT error; int testnum; char temppath[MAX_PATH]; char f1g1[MAX_PATH], f2g1[MAX_PATH], f3g1[MAX_PATH], f1g3[MAX_PATH], f2g3[MAX_PATH]; char itemtext[MAX_PATH + 20]; char comptext[2 * (MAX_PATH + 20) + 21]; testnum = 1; /* Invalid Command */ DdeExecuteCommand(instance, hConv, "[InvalidCommand()]", &hData, &error, DDE_TEST_MISC|testnum++); ok (error == DMLERR_NOTPROCESSED, "InvalidCommand(), expected error %s, received %s.\n", GetStringFromError(DMLERR_NOTPROCESSED), GetStringFromError(error)); /* On Vista+ the files have to exist when adding a link */ GetTempPathA(MAX_PATH, temppath); GetTempFileNameA(temppath, "dde", 0, f1g1); GetTempFileNameA(temppath, "dde", 0, f2g1); GetTempFileNameA(temppath, "dde", 0, f3g1); GetTempFileNameA(temppath, "dde", 0, f1g3); GetTempFileNameA(temppath, "dde", 0, f2g3); /* CreateGroup Tests (including AddItem, DeleteItem) */ CreateGroupTest(instance, hConv, "[CreateGroup(Group1)]", DMLERR_NO_ERROR, "Group1", Group1Title, DDE_TEST_CREATEGROUP|testnum++); CreateAddItemText(itemtext, f1g1, "f1g1Name"); AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f1g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); CreateAddItemText(itemtext, f2g1, "f2g1Name"); AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f2g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); DeleteItemTest(instance, hConv, "[DeleteItem(f2g1Name)]", DMLERR_NO_ERROR, "f2g1Name.lnk", "Group1", DDE_TEST_DELETEITEM|testnum++); CreateAddItemText(itemtext, f3g1, "f3g1Name"); AddItemTest(instance, hConv, itemtext, DMLERR_NO_ERROR, "f3g1Name.lnk", "Group1", DDE_TEST_ADDITEM|testnum++); CreateGroupTest(instance, hConv, "[CreateGroup(Group2)]", DMLERR_NO_ERROR, "Group2", Group2Title, DDE_TEST_CREATEGROUP|testnum++); /* Create Group that already exists - same instance */ CreateGroupTest(instance, hConv, "[CreateGroup(Group1)]", DMLERR_NO_ERROR, "Group1", Group1Title, DDE_TEST_CREATEGROUP|testnum++); /* ShowGroup Tests */ ShowGroupTest(instance, hConv, "[ShowGroup(Group1)]", DMLERR_NOTPROCESSED, "Group1", Group1Title, TRUE, DDE_TEST_SHOWGROUP|testnum++); DeleteItemTest(instance, hConv, "[DeleteItem(f3g1Name)]", DMLERR_NO_ERROR, "f3g1Name.lnk", "Group1", DDE_TEST_DELETEITEM|testnum++); ShowGroupTest(instance, hConv, "[ShowGroup(Startup,0)]", DMLERR_NO_ERROR, "Startup", StartupTitle, TRUE, DDE_TEST_SHOWGROUP|testnum++); ShowGroupTest(instance, hConv, "[ShowGroup(Group1,0)]", DMLERR_NO_ERROR, "Group1", Group1Title, FALSE, DDE_TEST_SHOWGROUP|testnum++); /* DeleteGroup Test - Note that Window is Open for this test */ DeleteGroupTest(instance, hConv, "[DeleteGroup(Group1)]", DMLERR_NO_ERROR, "Group1", DDE_TEST_DELETEGROUP|testnum++); /* Compound Execute String Command */ lstrcpyA(comptext, "[CreateGroup(Group3)]"); CreateAddItemText(itemtext, f1g3, "f1g3Name"); lstrcatA(comptext, itemtext); CreateAddItemText(itemtext, f2g3, "f2g3Name"); lstrcatA(comptext, itemtext); CompoundCommandTest(instance, hConv, comptext, DMLERR_NO_ERROR, "Group3", Group3Title, "f1g3Name.lnk", "f2g3Name.lnk", DDE_TEST_COMPOUND|testnum++); DeleteGroupTest(instance, hConv, "[DeleteGroup(Group3)]", DMLERR_NO_ERROR, "Group3", DDE_TEST_DELETEGROUP|testnum++); /* Full Parameters of Add Item */ /* AddItem(CmdLine[,Name[,IconPath[,IconIndex[,xPos,yPos[,DefDir[,HotKey[,fMinimize[fSeparateSpace]]]]]]]) */ DeleteFileA(f1g1); DeleteFileA(f2g1); DeleteFileA(f3g1); DeleteFileA(f1g3); DeleteFileA(f2g3); return testnum; }
/* Helper Function to Transfer DdeGetLastError into a String */ static const char * GetDdeLastErrorStr(DWORD instance) { UINT err = DdeGetLastError(instance); return GetStringFromError(err); }