/*++ Copyright (c) 1995 Microsoft Corporation Module Name: itlgcs.c Abstract: This module contains the test functions for lineGetCallStatus Author: Oliver Wallace (OliverW) 17-Sep-1995 Revision History: --*/ #include "windows.h" #include "malloc.h" #include "string.h" #include "tapi.h" #include "ttest.h" #include "doline.h" #include "tcore.h" #include "tline.h" #define NUMTOTALSIZES 5 // lineGetCallStatus // // The following tests are made: // // ------------------------------------------------------------------------- // * 1) Uninitialized (called before any lines are initialized) // 2) Invalid hCalls // 3) Invalid lpCallStatus pointers // 4) Combinations of allocations and dwTotalSizes for lpCallStatus // // * = Stand-alone test BOOL TestLineGetCallStatus(BOOL fQuietMode, BOOL fStandAloneTest) { LPTAPILINETESTINFO lpTapiLineTestInfo; LPLINECALLSTATUS lpCallStatus; size_t CallStatusSize = sizeof(LINECALLSTATUS); DWORD dwFixedSize = sizeof(LINECALLSTATUS); DWORD dwTotalSizes[] = { 0x0, dwFixedSize - 1, 0x70000000, 0x7FFFFFFF, 0xFFFFFFFF }; #ifdef WUNICODE WCHAR wszValidAddress[] = L"55555"; #else CHAR szValidAddress[] = "55555"; #endif INT n; LONG lExpected; ESPDEVSPECIFICINFO info; BOOL fTestPassed = TRUE; InitTestNumber(); TapiLineTestInit(); lpTapiLineTestInfo = GetLineTestInfo(); lpTapiLineTestInfo->dwCallbackInstance = (DWORD) GetCallbackParams(); strcpy(lpTapiLineTestInfo->szTestFunc, "lineGetCallStatus"); TapiLogDetail( DBUG_SHOW_PASS, ">>>>>>>> Begin testing lineGetCallStatus <<<<<<<<" ); // Call lineSetCallPrivilege before any lines are initialized // Note: This test must be run in a stand-alone mode if (fStandAloneTest) { TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: uninitialized state", dwTestCase + 1); if (! DoLineGetCallStatus( lpTapiLineTestInfo, LINEERR_UNINITIALIZED)) { TLINE_FAIL(); } fTestPassed = ShowTestCase(fTestPassed); } lpTapiLineTestInfo->lpLineInitializeExParams = (LPLINEINITIALIZEEXPARAMS) AllocFromTestHeap ( sizeof(LINEINITIALIZEEXPARAMS)); lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS); lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW; lpTapiLineTestInfo->lpLineDevCaps = (LPLINEDEVCAPS) AllocFromTestHeap( sizeof(LINEDEVCAPS)); lpTapiLineTestInfo->lpLineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS); lpCallStatus = (LPLINECALLSTATUS) AllocFromTestHeap( CallStatusSize + 256); lpCallStatus->dwTotalSize = (DWORD) (CallStatusSize + 256); lpTapiLineTestInfo->lpCallStatus = lpCallStatus; // Test valid state and params TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: Success, valid state and params", dwTestCase + 1 ); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpsUserUserInfo = NULL; lpTapiLineTestInfo->lpCallStatus = lpCallStatus; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; // BUGBUG lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } if (! DoLineGetCallStatus(lpTapiLineTestInfo, TAPISUCCESS)) { TLINE_FAIL(); } fTestPassed = ShowTestCase(fTestPassed); // Stop, Drop, and Close to isolate test case if (! DoTapiLineFuncs( lpTapiLineTestInfo, LDROP | LDEALLOCATECALL | LCLOSE | LSHUTDOWN )) { TLINE_FAIL(); } // Try invalid hCalls TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: invalid hCall values", dwTestCase + 1 ); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpsUserUserInfo = NULL; lpTapiLineTestInfo->lpCallStatus = lpCallStatus; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; // BUGBUG lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } // Backup the valid call handle lpTapiLineTestInfo->hCall_Orig = *lpTapiLineTestInfo->lphCall; for (n = 0; n < NUMINVALIDHANDLES; n++) { *lpTapiLineTestInfo->lphCall = (HCALL) gdwInvalidHandles[n]; if (! DoLineGetCallStatus(lpTapiLineTestInfo, LINEERR_INVALCALLHANDLE)) { TLINE_FAIL(); } } fTestPassed = ShowTestCase(fTestPassed); // Restore the valid call handle //XYD *lpTapiLineTestInfo->lphCall = lpTapiLineTestInfo->hCall_Orig; lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall_Orig; // Shutdown to isolate the test case if (! DoTapiLineFuncs( lpTapiLineTestInfo, LDROP | LDEALLOCATECALL | LCLOSE | LSHUTDOWN )) { TLINE_FAIL(); } // Try invalid lpCallStatus pointers TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: invalid lpCallStatus pointers", dwTestCase + 1 ); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpsUserUserInfo = NULL; lpTapiLineTestInfo->lpCallStatus = lpCallStatus; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; // BUGBUG lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } for (n = 0; n < NUMINVALIDPOINTERS; n++) { TapiLogDetail( DBUG_SHOW_DETAIL, "n= %ld", n); lpTapiLineTestInfo->lpCallStatus = (LPLINECALLSTATUS) gdwInvalidPointers[n]; if (! DoLineGetCallStatus(lpTapiLineTestInfo, LINEERR_INVALPOINTER)) { TLINE_FAIL(); } } fTestPassed = ShowTestCase(fTestPassed); // Restore the LineCallStatus pointer lpTapiLineTestInfo->lpCallStatus = lpCallStatus; // Shutdown to isolate the test case if (! DoTapiLineFuncs( lpTapiLineTestInfo, LDROP | LDEALLOCATECALL | LCLOSE | LSHUTDOWN )) { TLINE_FAIL(); } TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: Bad dwTotalSize", dwTestCase + 1 ); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpsUserUserInfo = NULL; lpTapiLineTestInfo->lpCallStatus = lpCallStatus; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } for (n = 0; n < NUMTOTALSIZES; n++) { lpTapiLineTestInfo->lpCallStatus->dwTotalSize = dwTotalSizes[n]; if(dwTotalSizes[n] < dwFixedSize) lExpected = LINEERR_STRUCTURETOOSMALL; else lExpected = LINEERR_INVALPOINTER; TapiLogDetail( DBUG_SHOW_DETAIL, "dwTotalSize = %lx", dwTotalSizes[n]); if (! DoLineGetCallStatus(lpTapiLineTestInfo, lExpected)) { TLINE_FAIL(); } } fTestPassed = ShowTestCase(fTestPassed); lpTapiLineTestInfo->lpCallStatus->dwTotalSize = dwFixedSize; // Restore the LineCallStatus pointer lpTapiLineTestInfo->lpCallStatus = lpCallStatus; // Shutdown to isolate the test case if (! DoTapiLineFuncs( lpTapiLineTestInfo, LDROP | LDEALLOCATECALL | LCLOSE | LSHUTDOWN )) { TLINE_FAIL(); } FreeTestHeap(); lpTapiLineTestInfo->lpLineInitializeExParams = (LPLINEINITIALIZEEXPARAMS) AllocFromTestHeap ( sizeof(LINEINITIALIZEEXPARAMS)); lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS); lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW; n = ESP_RESULT_RETURNRESULT; TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: Success, completionID = %d", dwTestCase + 1, n ); TapiLineTestInit(); lpTapiLineTestInfo = GetLineTestInfo(); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpLineDevCaps = (LPLINEDEVCAPS) AllocFromTestHeap( sizeof(LINEDEVCAPS) ); lpTapiLineTestInfo->lpLineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS); lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; lpTapiLineTestInfo->dwSelect = LINECALLSELECT_ADDRESS; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif // Init a line if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } if(IsESPLineDevice(lpTapiLineTestInfo)) { info.dwKey = ESPDEVSPECIFIC_KEY; info.dwType = ESP_DEVSPEC_RESULT; info.u.EspResult.lResult = TAPISUCCESS; info.u.EspResult.dwCompletionType = n; lpTapiLineTestInfo->lpParams = (LPVOID)&info; lpTapiLineTestInfo->dwSize = sizeof(info); if(! DoLineDevSpecific(lpTapiLineTestInfo, TAPISUCCESS, TRUE)) { TLINE_FAIL(); } lpTapiLineTestInfo->lpCallStatus = (LPLINECALLSTATUS) AllocFromTestHeap( CallStatusSize + 256); lpCallStatus->dwTotalSize = (DWORD) (CallStatusSize + 256); if ( ! DoLineGetCallStatus(lpTapiLineTestInfo, info.u.EspResult.lResult)) { TLINE_FAIL(); } } fTestPassed = ShowTestCase(fTestPassed); if (! DoLineClose(lpTapiLineTestInfo, TAPISUCCESS)) { TLINE_FAIL(); } // Shutdown to isolate the test case if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS)) { TLINE_FAIL(); } // Free the memory allocated during the tests FreeTestHeap(); lpTapiLineTestInfo->lpLineInitializeExParams = (LPLINEINITIALIZEEXPARAMS) AllocFromTestHeap ( sizeof(LINEINITIALIZEEXPARAMS)); lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize = sizeof(LINEINITIALIZEEXPARAMS); lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW; TapiLogDetail( DBUG_SHOW_PASS, ">> Test Case %ld: Error, completionID = %d", dwTestCase + 1, n ); TapiLineTestInit(); lpTapiLineTestInfo = GetLineTestInfo(); lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1; lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1; lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion; lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0; lpTapiLineTestInfo->dwAPILowVersion = LOW_APIVERSION; lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION; lpTapiLineTestInfo->lpLineDevCaps = (LPLINEDEVCAPS) AllocFromTestHeap( sizeof(LINEDEVCAPS) ); lpTapiLineTestInfo->lpLineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS); lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM; lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER; lpTapiLineTestInfo->dwSelect = LINECALLSELECT_ADDRESS; #ifdef WUNICODE lpTapiLineTestInfo->lpwszDestAddress = wszValidAddress; #else lpTapiLineTestInfo->lpszDestAddress = szValidAddress; #endif // Init a line if (! DoTapiLineFuncs( lpTapiLineTestInfo, LINITIALIZEEX | LNEGOTIATEAPIVERSION | LGETDEVCAPS | LOPEN | LMAKECALL )) { TLINE_FAIL(); } if(IsESPLineDevice(lpTapiLineTestInfo)) { info.dwKey = ESPDEVSPECIFIC_KEY; info.dwType = ESP_DEVSPEC_RESULT; info.u.EspResult.lResult = LINEERR_INVALCALLHANDLE; info.u.EspResult.dwCompletionType = n; lpTapiLineTestInfo->lpParams = (LPVOID)&info; lpTapiLineTestInfo->dwSize = sizeof(info); if(! DoLineDevSpecific(lpTapiLineTestInfo, TAPISUCCESS, TRUE)) { TLINE_FAIL(); } lpTapiLineTestInfo->lpCallStatus = (LPLINECALLSTATUS) AllocFromTestHeap( CallStatusSize + 256); lpCallStatus->dwTotalSize = (DWORD) (CallStatusSize + 256); if ( ! DoLineGetCallStatus(lpTapiLineTestInfo, info.u.EspResult.lResult)) { TLINE_FAIL(); } } fTestPassed = ShowTestCase(fTestPassed); if (! DoLineClose(lpTapiLineTestInfo, TAPISUCCESS)) { TLINE_FAIL(); } // Shutdown to isolate the test case if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS)) { TLINE_FAIL(); } // Free the memory allocated during the tests FreeTestHeap(); TapiLogDetail( DBUG_SHOW_PASS, "@@ lineGetCallStatus: Total Test Case = %ld, Passed = %ld, Failed = %ld", dwTestCase, dwTestCasePassed, dwTestCaseFailed); TapiLogDetail( DBUG_SHOW_PASS, "@@ Total Test Case = %ld, Passed = %ld, Failed = %ld", dwglTestCase, dwglTestCasePassed, dwglTestCaseFailed); if(dwTestCaseFailed > 0) fTestPassed = FALSE; TapiLogDetail( DBUG_SHOW_PASS, ">>>>>>>> End testing lineGetCallStatus <<<<<<<<" ); return fTestPassed; }