1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for Control_RunDLLW 5 * PROGRAMMER: Giannis Adamopoulos 6 */ 7 8 #include "shelltest.h" 9 10 #include <cpl.h> 11 #include <stdio.h> 12 13 #define NDEBUG 14 #include <debug.h> 15 16 extern "C" 17 void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow); 18 19 int g_iParams; 20 int g_iClk; 21 WCHAR g_wstrParams[MAX_PATH]; 22 23 extern "C" 24 LONG CALLBACK 25 CPlApplet(HWND hwndCPl, 26 UINT uMsg, 27 LPARAM lParam1, 28 LPARAM lParam2) 29 { 30 INT i = (INT)lParam1; 31 32 switch (uMsg) 33 { 34 case CPL_INIT: 35 return TRUE; 36 37 case CPL_GETCOUNT: 38 return 2; 39 40 case CPL_INQUIRE: 41 { 42 CPLINFO *CPlInfo = (CPLINFO*)lParam2; 43 CPlInfo->lData = 0; 44 CPlInfo->idIcon = CPL_DYNAMIC_RES ; 45 CPlInfo->idName = CPL_DYNAMIC_RES ; 46 CPlInfo->idInfo = CPL_DYNAMIC_RES ; 47 } 48 break; 49 case CPL_NEWINQUIRE: 50 { 51 LPNEWCPLINFOW pinfo = (LPNEWCPLINFOW)lParam2; 52 53 memset(pinfo, 0, sizeof(NEWCPLINFOW)); 54 pinfo->dwSize = sizeof(NEWCPLINFOW); 55 pinfo->hIcon = LoadIcon(NULL, IDI_APPLICATION); 56 if (i == 0) 57 { 58 wcscpy(pinfo->szName, L"name0"); 59 wcscpy(pinfo->szInfo, L"info0"); 60 wcscpy(pinfo->szHelpFile, L"help0"); 61 } 62 else 63 { 64 wcscpy(pinfo->szName, L"name1"); 65 wcscpy(pinfo->szInfo, L"info1"); 66 wcscpy(pinfo->szHelpFile, L"help1"); 67 } 68 break; 69 } 70 case CPL_DBLCLK: 71 g_iClk = i; 72 break; 73 case CPL_STARTWPARMSW: 74 g_iParams = i; 75 ok(lParam2 != NULL, "Got NULL lParam2!\n"); 76 if (lParam2) 77 wcscpy(g_wstrParams, (LPCWSTR)lParam2); 78 break; 79 } 80 81 return FALSE; 82 } 83 84 85 #define MSG_NOT_CALLED -1 86 87 struct param_test 88 { 89 int srcLine; 90 LPCWSTR cmd; 91 INT iStartParams; /* MSG_NOT_CALLED when CPL_STARTWPARMS is not sent */ 92 LPCWSTR params; /* second param of CPL_STARTWPARMS */ 93 INT iClick; /* MSG_NOT_CALLED when CPL_DBLCLK is not sent */ 94 }; 95 96 struct param_test tests[] = 97 { 98 {__LINE__, L"", MSG_NOT_CALLED, L"", 0}, 99 {__LINE__, L",name0", MSG_NOT_CALLED, L"", 0}, 100 {__LINE__, L",name1", MSG_NOT_CALLED, L"", 1}, 101 {__LINE__, L",@0", MSG_NOT_CALLED, L"", 0}, 102 {__LINE__, L",@1", MSG_NOT_CALLED, L"", 1}, 103 {__LINE__, L",0", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 104 {__LINE__, L",1", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 105 {__LINE__, L",@name0", MSG_NOT_CALLED, L"", 0}, 106 {__LINE__, L",@name1", MSG_NOT_CALLED, L"", 0}, 107 {__LINE__, L" name0", MSG_NOT_CALLED, L"", 0}, 108 {__LINE__, L" name1", MSG_NOT_CALLED, L"", 1}, 109 {__LINE__, L" @0", MSG_NOT_CALLED, L"", 0}, 110 {__LINE__, L" @1", MSG_NOT_CALLED, L"", 1}, 111 {__LINE__, L" 0", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 112 {__LINE__, L" 1", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 113 {__LINE__, L" @name0", MSG_NOT_CALLED, L"", 0}, 114 {__LINE__, L" @name1", MSG_NOT_CALLED, L"", 0}, 115 {__LINE__, L"\"name0\"", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 116 {__LINE__, L"\"name1\"", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 117 {__LINE__, L",\"name0\"", MSG_NOT_CALLED, L"", 0}, 118 {__LINE__, L",\"name1\"", MSG_NOT_CALLED, L"", 1}, 119 {__LINE__, L"\",name0\"", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 120 {__LINE__, L"\",name1\"", MSG_NOT_CALLED, L"", MSG_NOT_CALLED}, 121 {__LINE__, L",name0,@1", 0, L"@1", 0}, 122 {__LINE__, L",name1,@0", 1, L"@0", 1}, 123 {__LINE__, L",name0, ", 0, L" ", 0}, 124 {__LINE__, L",name1, ", 1, L" ", 1}, 125 {__LINE__, L",@0,@1", 0, L"@1", 0}, 126 {__LINE__, L",@1,@0", 1, L"@0", 1}, 127 {__LINE__, L",\"@0\",@1", 0, L"@1", 0}, 128 {__LINE__, L",\"@1\",@0", 1, L"@0", 1}, 129 {__LINE__, L",\"@0\",\"@1\"", 0, L"\"@1\"", 0}, 130 {__LINE__, L",\"@1\",\"@0\"", 1, L"\"@0\"", 1}, 131 {__LINE__, L",\"@0\",@1,2,3,4,5", 0, L"@1,2,3,4,5", 0}, 132 {__LINE__, L",\"@1\",@0,2,3,4,5", 1, L"@0,2,3,4,5", 1}, 133 {__LINE__, L",\"@0\",@1,2,\"3\",4,5", 0, L"@1,2,\"3\",4,5", 0}, 134 {__LINE__, L",\"@1\",@0,2,\"3\",4,5", 1, L"@0,2,\"3\",4,5", 1}, 135 {__LINE__, L",\"@0\", @1 , 2 , 3 , 4 , 5", 0, L" @1 , 2 , 3 , 4 , 5", 0}, 136 {__LINE__, L",\"@1\", @0 , 2 , 3 , 4 , 5", 1, L" @0 , 2 , 3 , 4 , 5", 1}, 137 {__LINE__, L",\"@0\", @1 , 2 , /3 , 4 , 5", 0, L" @1 , 2 , /3 , 4 , 5", 0}, 138 {__LINE__, L",\"@1\", @0 , 2 , /3 , 4 , 5", 1, L" @0 , 2 , /3 , 4 , 5", 1}, 139 {__LINE__, L",\"@0\", @1 , 2 , /3 , 4 , 5", 0, L" @1 , 2 , /3 , 4 , 5", 0}, 140 {__LINE__, L",\"@1\", @0 , 2 , /3 , 4 , 5", 1, L" @0 , 2 , /3 , 4 , 5", 1}, 141 142 }; 143 144 START_TEST(Control_RunDLLW) 145 { 146 WCHAR finename[MAX_PATH]; 147 WCHAR buffer[MAX_PATH]; 148 149 GetModuleFileNameW(NULL, finename, MAX_PATH); 150 151 for (UINT i = 0; i < _countof(tests); i++) 152 { 153 swprintf(buffer, L"%s%s", finename, tests[i].cmd); 154 155 g_iClk = MSG_NOT_CALLED; 156 g_iParams = MSG_NOT_CALLED; 157 g_wstrParams[0] = 0; 158 Control_RunDLLW( GetDesktopWindow (), 0, buffer, 0); 159 ok (tests[i].iClick == g_iClk, "%d, CPL_DBLCLK: expected %d got %d\n", tests[i].srcLine, tests[i].iClick, g_iClk); 160 ok (tests[i].iStartParams == g_iParams, "%d, CPL_STARTWPARMSW: expected %d got %d\n", tests[i].srcLine, tests[i].iStartParams, g_iParams); 161 ok (wcscmp(tests[i].params, g_wstrParams) == 0, "%d, CPL_STARTWPARMSW: expected %S got %S\n", tests[i].srcLine, tests[i].params, g_wstrParams); 162 } 163 }