summaryrefslogtreecommitdiffstats
path: root/private/tapi/qa/trapper/itest/line/itls.c
blob: 00509ccd87fd0d121d53daf1baa9e1cd3ed41abb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
/*++

Copyright (c) 1995  Microsoft Corporation

Module Name:

    itls.c

Abstract:

    This module contains the test functions for lineShutdown

Author:

    Oliver Wallace (OliverW)    1-Aug-1995

Revision History:

--*/


#include "windows.h"
#include "malloc.h"
#include "string.h"
#include "tapi.h"
#include "trapper.h"
#include "ttest.h"
#include "doline.h"
#include "tline.h"


//  lineShutdown
//
//  The following tests are made:
//
//  -------------------------------------------------------------------------
//  *  1)  Uninitialized (called before any lines are initialized)
//     2)  Invalid hLineApps
//     3)  Verify hLineApp can't be reused (no other hLineApps exist)
//     4)  Verify hLineApp can't be reused (1 other hLineApp exists)
//     5)  Shutdown hLineApp after lineInitialize fails
//     6)  Verify LINECALLINFO/NUMMONITORS msg sent when hLineApp shutdown
//         (2 call clients [one owner, one monitor] on 2 different hLineApps)
//     7)  Verify LINECALLINFO/NUMOWNERDECR msg sent when hLineApp shutdown
//         (2 call clients [both owners] on 2 different hLineApps)
//     8)  Verify LINECALLINFO/NUMMONITORS msg sent when hLineApp shutdown
//         (2 call clients [both monitors] on 2 different hLineApps)
//     9)  Shutdown while a call is in progress and verify
//         that the call handle, line handle, and line app handle are
//         no longer valid
//    10)  Shutdown while a line is open with owner privilege and verify
//         line handle is invalid
//
//  *  =   Stand-alone test

BOOL TestLineShutdown(BOOL fQuietMode, BOOL fStandAloneTest)
{
    LPTAPILINETESTINFO  lpTapiLineTestInfo;
    LPCALLBACKPARAMS    lpCallbackParams;
    INT                 n;
    BOOL                fResult;
    ESPDEVSPECIFICINFO info;
    BOOL                fTestPassed       = TRUE;
    HCALL hCall;
 	 LPTAPIMSG lpTapiMsg = NULL;
    LPTAPIMSG lpMatch;
	 LONG lret;
	 LPTAPIMSG lpMsg;
    LINEINITIALIZEEXPARAMS 	lineInitializeExParams1;
    LINEINITIALIZEEXPARAMS 	lineInitializeExParams2;


    InitTestNumber();
	 TapiLineTestInit();

    lpTapiLineTestInfo                      = GetLineTestInfo();
    lpCallbackParams                        = GetCallbackParams();
    lpTapiLineTestInfo->lpExtID             = (LPLINEEXTENSIONID)
                                              AllocFromTestHeap(
                                                  sizeof(LINEEXTENSIONID)
                                                  );
    lpTapiLineTestInfo->dwPrivileges        = LINECALLPRIVILEGE_OWNER;
    lpTapiLineTestInfo->dwMediaModes        = LINEMEDIAMODE_DATAMODEM;
    lpTapiLineTestInfo->dwCallbackInstance  =
                      (DWORD) GetCallbackParams();
    strcpy(lpTapiLineTestInfo->szTestFunc, "lineShutdown");
    
    lpTapiLineTestInfo->dwCallbackInstance  =
            (DWORD) GetCallbackParams();


    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>>>>>>>  Begin testing lineShutdown  <<<<<<<<"
            );
            
    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: invalid hLineApp handles", dwTestCase + 1
            );
            
    lpTapiLineTestInfo->lpLineInitializeExParams =
         (LPLINEINITIALIZEEXPARAMS) AllocFromTestHeap (
         sizeof(LINEINITIALIZEEXPARAMS));
    lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize =
         sizeof(LINEINITIALIZEEXPARAMS);
    lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions =
         LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;


    // Test bad line app handles (uses &lpTapiLineTestInfo->hLineApp1)
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Use &hLineApp2 to test invalid handles
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp2);
    for (n = 0; n < NUMINVALIDHANDLES; n++)
    {
        *(lpTapiLineTestInfo->lphLineApp) = (HLINEAPP) gdwInvalidHandles[n];

        if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_INVALAPPHANDLE))
        {
            TLINE_FAIL();
        }
    }
   
    fTestPassed = ShowTestCase(fTestPassed);


    // Restore lpTapiLineTestInfo->lphLineApp to point to &hLineApp1
    // Note:  hLineApp1 is a valid initialized handle
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp1);

    // Might as well test valid shutdown now
    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: Success, valid params and state (no active calls)", dwTestCase + 1
            );
            
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);

    // Test that shutdown fails when there are no line handles initialized
    // no lines are initialized (hLineApp should be invalid)
    // If this is a stand-alone test (no other TAPI apps are running)
    // then LINEERR_UNINITIALIZED will be the expected return value.
    // Otherwise, LINEERR_INVALAPPHANDLE should be returned.
    if (fStandAloneTest)
    {
        TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: uninitialized state", dwTestCase + 1
            );

        if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_UNINITIALIZED))
        {
            TLINE_FAIL();
        }
    fTestPassed = ShowTestCase(fTestPassed);
    }
/*
    else
    {
    
        TapiLogDetail(
                DBUG_SHOW_PASS,
                ">>  Test Case %ld: invalid hLineApp handle", dwTestCase + 1
                );
            
        if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_INVALAPPHANDLE))
        {
            TLINE_FAIL();
        }
    fTestPassed = ShowTestCase(fTestPassed);

    }
*/

    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: hLineApp can't be shutdown if lineInitialize fails", dwTestCase + 1
            );
            
    // Initialize a valid line app instance to prevent the possibility
    // of receiving an UNINITIALIZED error during the next test
    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp3;
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }
    // Backup the hLineApp and use a different one for the next test
    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp2;

    // Verify that an app handle can't be used in a shutdown call
    // if lineInitialize returned an error prior to shutdown attempt
    lpTapiLineTestInfo->lpdwNumDevs = NULL;
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, LINEERR_INVALPOINTER))
    {
        TLINE_FAIL();
    }
    lpTapiLineTestInfo->lpdwNumDevs = &(lpTapiLineTestInfo->dwNumDevs);

    if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_INVALAPPHANDLE))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);


    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: hLineApp can't be used after shutdown (>= 1 hLineApps)", dwTestCase + 1
            );
            
    // Verify that an app handle can't be reused after it's been
    // shutdown by another line abstraction in use
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Store the initialized app handle
    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp1;

    // Initialize another app handle
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Shutdown a handle
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Shutdown another handle
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp2);
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // make sure app handle can't be reused (1 other hLineApp exists).
    // Test first app handle shutdown
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp1);
    if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_INVALAPPHANDLE))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);


    // Prepare to open a line, make a call, and try shutting it down.
    // Next verify that the hCall, the hLine, and the hLineApp
    // are no longer valid after the shutdown.

    // First, initialize a spare hLineApp to prevent UNINITIALIZED errors
    // from being returned if this is the only TAPI app running.

    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: hLine, hCall, and hLineApp are invalid after shutdown", dwTestCase + 1
            );

                        
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp1);
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }


    // Negotiate the API version
    lpTapiLineTestInfo->dwAPILowVersion  = LOW_APIVERSION;
    lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION;
    if (! DoLineNegotiateAPIVersion(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Allocate lpLineDevCaps
    lpTapiLineTestInfo->lpLineDevCaps = (LPLINEDEVCAPS) AllocFromTestHeap(
            sizeof(LINEDEVCAPS));
    lpTapiLineTestInfo->lpLineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS);

    if (! DoLineGetDevCaps(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    if (! DoLineMakeCall(lpTapiLineTestInfo, TAPISUCCESS, TRUE))
    {
        TLINE_FAIL();
    }

    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Call handle should be invalid
    if (! DoLineDeallocateCall(lpTapiLineTestInfo, LINEERR_INVALCALLHANDLE))
    {
        TLINE_FAIL();
    }

    // The line should be closed
    if (! DoLineClose(lpTapiLineTestInfo, LINEERR_INVALLINEHANDLE))
    {
        TLINE_FAIL();
    }

    // The line app instance should be invalid
    if (! DoLineShutdown(lpTapiLineTestInfo, LINEERR_INVALAPPHANDLE))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);

    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: valid shutdown of opened line with owner privilege", dwTestCase + 1
            );
            
    // Take the remaining hLineApp, open a line with owner privilege,
    // and shutdown (Verifies NT BUG #10179 is fixed)
    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp3;
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }


    fTestPassed = ShowTestCase(fTestPassed);

    // Currently, there should be no lines initialized from this thread.
    // First, initialize a couple of different line app instances.
    // Open the same line device for each hLineApp (one as owner and
    // one as monitor).  Next, make a call with the owner.  After the
    // call proceeds to the connected state, shutdown the monitor.
    // The owner should receive a LINE_CALLINFO/NUMMONITORS message
    // to indicate that the number of monitors has decremented.
    //
    // Note:  To be sure that this message is sent as a result of the
    //        shutdown in this thread, no other threads or applications
    //        can be using the device during the test.
    //

    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: LINE_CALLINFO/NUMMONITORS message sent to owner\r\n" \
            ">>  (same hLineApp)", dwTestCase + 1
            );
            
    // Initialize 2 hLineApps
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp1);
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->hLineApp2 = *(lpTapiLineTestInfo->lphLineApp);
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Negotiate the API version (It's been done before, but doing it again
    // removes dependencies from previous test results).
    if (! DoLineNegotiateAPIVersion(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Allocate a new lpLineDevCaps pointer
    lpTapiLineTestInfo->lpLineDevCaps = (LPLINEDEVCAPS) AllocFromTestHeap(
            sizeof(LINEDEVCAPS));
    lpTapiLineTestInfo->lpLineDevCaps->dwTotalSize = sizeof(LINEDEVCAPS);

    if (! DoLineGetDevCaps(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Open a line device as monitor (dwMediaModes is ignored)
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_MONITOR;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Open a line with a different line app registration as owner with
    // dwMediaModes set equal to what the line device can accomodate
    lpTapiLineTestInfo->lphLineApp   = &(lpTapiLineTestInfo->hLineApp2);
    lpTapiLineTestInfo->lphLine      = &(lpTapiLineTestInfo->hLine2);
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER;
    lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM;
// BUGBUG
//          lpTapiLineTestInfo->lpLineDevCaps->dwMediaModes;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Make a call on the line opened as owner
    if (! DoLineMakeCall(lpTapiLineTestInfo, TAPISUCCESS, TRUE))
    {
        TLINE_FAIL();
    }

    // Shutdown the monitor and verify that the owner receives a message
    // indicating the number of monitors on the line has changed
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp1);
    fResult = DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS);
    if (! fResult)
    {
        TLINE_FAIL();
    }

    // Add the expected LINE_CALLINFO message to the list of
    // expected TAPI messages and wait for it
    // Note:  The lpCallbackParams value will make this expected message
    //        unique.  Therefore, if another app is monitoring this line
    //        and it is closed, the message will not precisely match.
    if (fResult)
    {
        AddMessage(
            LINE_CALLINFO,
            (DWORD) *lpTapiLineTestInfo->lphCall,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG | TAPIMSG_HDEVCALL | TAPIMSG_DWCALLBACKINST |
                    TAPIMSG_DWPARAM1
            );
    }

    // If the wait succeeds, then the LINE_CALLINFO message was received
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    // Drop the call by closing the line (lpTapiLineTestInfo->lphLine
    // still points to the line handle of the owner)
    if (! DoLineClose(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);

    // Next open the same line device on two different app registrations.
    // Initially, open one as owner, and the other as a monitor.  Make a
    // call via the owner.  Set the call privilege of the monitor to owner.
    // Go ahead and verify that a LINE_CALLINFO/NUMOWNERINCR message is
    // sent.  Shutdown one of the owners and verify that a LINE_CALLINFO/
    // NUMOWNERDECR message is sent to the other owner after the shutdown.

    FreeTestHeap();

    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: LINE_CALLINFO/NUMOWNERINCR & DECR msgs are sent\r\n" \
            ">>  (different hLineApps)", dwTestCase + 1
            );

	 TapiLineTestInit();

    lpTapiLineTestInfo                      = GetLineTestInfo();
    lpCallbackParams                        = GetCallbackParams();
    lpTapiLineTestInfo->lpExtID             = (LPLINEEXTENSIONID)
                                              AllocFromTestHeap(
                                                  sizeof(LINEEXTENSIONID)
                                                  );
 
    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp1;
    lpTapiLineTestInfo->lpLineInitializeExParams = &lineInitializeExParams1;

    lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize =
         sizeof(LINEINITIALIZEEXPARAMS);
    lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions =
         LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;

    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp2;
    lpTapiLineTestInfo->lpLineInitializeExParams = &lineInitializeExParams2;
    lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize =
         sizeof(LINEINITIALIZEEXPARAMS);
    lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions =
         LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;

    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp1;
    lpTapiLineTestInfo->dwAPILowVersion  = LOW_APIVERSION;
    lpTapiLineTestInfo->dwAPIHighVersion = HIGH_APIVERSION;
    if (! DoLineNegotiateAPIVersion(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLine      = &lpTapiLineTestInfo->hLine1;
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER;
    lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp2;
    lpTapiLineTestInfo->lphLine      = &lpTapiLineTestInfo->hLine2;
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_MONITOR;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp1;
    lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1;
    lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1;

    fResult = DoLineMakeCall(lpTapiLineTestInfo, TAPISUCCESS, TRUE);
 
    if (! fResult)
    {
        TLINE_FAIL();
    }

    lpMsg = AddMessage(LINE_CALLSTATE, 0, 0, 0, 0, 0, TAPIMSG_DWMSG);
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
     }

   lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp2;

   lpMatch = (LPTAPIMSG) AllocFromTestHeap (sizeof(TAPIMSG));

	lpMatch->dwMsg = LINE_CALLSTATE;
	lpMatch->dwParam1 = 0;
   lpMatch->dwParam3 = 0;
	lpMatch->dwFlags = TAPIMSG_DWMSG;

	if(FindReceivedMsgs(&lpTapiMsg, lpMatch, FALSE))
	{
   lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall2;
 	*lpTapiLineTestInfo->lphCall = (HCALL)(lpTapiMsg->hDevCall);
	}
   else
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp1;
    lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1;
    lpTapiLineTestInfo->dwCallPrivilege = LINECALLPRIVILEGE_MONITOR;
    fResult = DoLineSetCallPrivilege(lpTapiLineTestInfo, TAPISUCCESS);
    if (! fResult)
    {
        TLINE_FAIL();
    }


    // Add the messages only if lineSetCallPrivilege succeeded
    if (fResult)
    {
        AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS | LINECALLINFOSTATE_NUMOWNERDECR,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG 
//| TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
//                    TAPIMSG_HDEVCALL
            );
    }

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->dwCallPrivilege = LINECALLPRIVILEGE_OWNER;
    fResult = DoLineSetCallPrivilege(lpTapiLineTestInfo, TAPISUCCESS);
    if (! fResult)
    {
        TLINE_FAIL();
    }


    if (fResult)
    {
        AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS | LINECALLINFOSTATE_NUMOWNERINCR,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG 
//| TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
//                    TAPIMSG_HDEVCALL
            );
    }

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    if (! DoLineDeallocateCall(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

     AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMOWNERDECR,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG 
// | TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
//                    TAPIMSG_HDEVCALL
            );

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }


    lpTapiLineTestInfo->lpCallList = (LPLINECALLLIST) AllocFromTestHeap(
            sizeof(LINECALLLIST) + sizeof(HCALL) );
    lpTapiLineTestInfo->lpCallList->dwTotalSize = sizeof(LINECALLLIST) + sizeof(HCALL);

    lpTapiLineTestInfo->dwSelect = LINECALLSELECT_LINE;

    if (! DoLineGetNewCalls(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }
 
     GetVarField(
            (LPVOID) lpTapiLineTestInfo->lpCallList,
            (LPVOID) &lpTapiLineTestInfo->hCall1,
            4,
            lpTapiLineTestInfo->lpCallList->dwCallsOffset
            );

     AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG 
// | TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
//                    TAPIMSG_HDEVCALL
            );

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp2;
 	 lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine2;
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

     AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall1,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG 
// | TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
//                    TAPIMSG_HDEVCALL
            );

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLine = &lpTapiLineTestInfo->hLine1;
    if (! DoLineClose(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp1;
 
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }
    fTestPassed = ShowTestCase(fTestPassed);

	 FreeTestHeap();



/*
    TapiLogDetail(
            DBUG_SHOW_PASS,
            ">>  Test Case %ld: LINE_CALLINFO/NUMOWNERINCR & DECR msgs are sent\r\n" \
            ">>  (different hLineApps)", dwTestCase + 1
            );

	 TapiLineTestInit();

    lpTapiLineTestInfo                      = GetLineTestInfo();
    lpCallbackParams                        = GetCallbackParams();
    lpTapiLineTestInfo->lpExtID             = (LPLINEEXTENSIONID)
                                              AllocFromTestHeap(
                                                  sizeof(LINEEXTENSIONID)
                                                  );
 
    lpTapiLineTestInfo->lphLineApp   = &lpTapiLineTestInfo->hLineApp1;
    lpTapiLineTestInfo->lphLine      = &lpTapiLineTestInfo->hLine1;
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_OWNER;
    lpTapiLineTestInfo->dwMediaModes = LINEMEDIAMODE_DATAMODEM;

    lpTapiLineTestInfo->lpLineInitializeExParams =
         (LPLINEINITIALIZEEXPARAMS) AllocFromTestHeap (
         sizeof(LINEINITIALIZEEXPARAMS));
    lpTapiLineTestInfo->lpLineInitializeExParams->dwTotalSize =
         sizeof(LINEINITIALIZEEXPARAMS);
    lpTapiLineTestInfo->lpLineInitializeExParams->dwOptions =
         LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;

    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;
    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Initialize a second line app (lpTapiLineTestInfo->hLineApp2).
    lpTapiLineTestInfo->lphLineApp = &(lpTapiLineTestInfo->hLineApp2);
    lpTapiLineTestInfo->lphLine    = &(lpTapiLineTestInfo->hLine2);
    lpTapiLineTestInfo->lpdwAPIVersion = &lpTapiLineTestInfo->dwAPIVersion;
    lpTapiLineTestInfo->dwAPIVersion = TAPI_VERSION2_0;

    if (! DoLineInitializeEx(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    // Open as a monitor (assume the device caps haven't changed, and
    // the same device is being used as in the previous test).
    lpTapiLineTestInfo->dwPrivileges = LINECALLPRIVILEGE_MONITOR;
    if (! DoLineOpen(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }
    
    // Make a call with the owner
    lpTapiLineTestInfo->lphLine = &(lpTapiLineTestInfo->hLine1);
    lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1;

    fResult = DoLineMakeCall(lpTapiLineTestInfo, TAPISUCCESS, TRUE);
    if (! fResult)
    {
        TLINE_FAIL();
    }

    if (fResult)
    {
        // Add an expected message for the monitor to receive a LINE_CALLSTATE
        // message informing the app that an outbound call has been established
        // on the line
        lpMsg = AddMessage(
            LINE_CALLSTATE,
            0x00000000,
            (DWORD) lpCallbackParams,
            LINECALLSTATE_UNKNOWN,
            0x00000000,
            LINECALLPRIVILEGE_MONITOR,
            TAPIMSG_DWMSG | TAPIMSG_DWCALLBACKINST | 
                    TAPIMSG_DWPARAM1 |
                    TAPIMSG_DWPARAM3
                );
      lpMsg = AddMessage(LINE_CALLSTATE, 0, 0, 0, 0, 0, TAPIMSG_DWMSG);
    }

    // Wait for the asynchronous reply to the owner and the callstate
    // message to the monitor.
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
     }


    // Change the call privilege of the monitor to owner and see if
    // LINE_CALLINFO/NUMMONITORS and LINE_CALLINFO/NUMOWNERINCR messages
    // are received.

    // Store the call handle for the owner with hLine2 and hLineApp2
    lpTapiLineTestInfo->hCall2 = *(lpTapiLineTestInfo->lphCall);
 
    // Get the call handle from the LINECALLSTATE message that the monitor
    // received.
     XYD
    *lpTapiLineTestInfo->lphCall = (HCALL) CallbackParamsGetDevCallHandle(
            lpCallbackParams,
            LINE_CALLSTATE
            );
    

   lpMatch = (LPTAPIMSG) AllocFromTestHeap (sizeof(TAPIMSG));

	lpMatch->dwMsg = LINE_CALLSTATE;
	lpMatch->dwParam1 = LINECALLSTATE_DIALING;
	lpMatch->dwParam3 = LINECALLPRIVILEGE_MONITOR;
	lpMatch->dwFlags = TAPIMSG_DWMSG | TAPIMSG_DWPARAM3;

	if(FindReceivedMsgs(&lpTapiMsg, lpMatch, FALSE))
	{
   lpTapiLineTestInfo->lphCall = &lpTapiLineTestInfo->hCall1;
 	*lpTapiLineTestInfo->lphCall = (HCALL)(lpTapiMsg->hDevCall);
	}
   else
    {
        TLINE_FAIL();
    }


    // Take ownership of the call (After this is called, there will be two
    // owners of the call on different line app registrations.).
    lpTapiLineTestInfo->dwCallPrivilege = LINECALLPRIVILEGE_OWNER;
    fResult = DoLineSetCallPrivilege(lpTapiLineTestInfo, TAPISUCCESS);
    if (! fResult)
    {
        TLINE_FAIL();
    }


    // Add the messages only if lineSetCallPrivilege succeeded
    if (fResult)
    {
        // Add an expected message for the original owner to receive a
        // LINE_CALLINFOSTATE message informing the app that the number of
        // monitors on the line has changed (decremented by 1) and the
        // number of owners has increased.
        AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMMONITORS | LINECALLINFOSTATE_NUMOWNERINCR,
            0x00000000,
            0x00000000,
            TAPIMSG_DWMSG | TAPIMSG_DWCALLBACKINST | TAPIMSG_DWPARAM1 |
                    TAPIMSG_HDEVCALL
            );
    }

    // Wait for the unsolicited messages to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    // Shutdown one of the line apps and see if the other owner receives
    // a LINE_CALLINFOSTATE message informing the app that the number of
    // owners has decreased.
    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp1;
    fResult = DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS);
    if (! fResult)
    {
        TLINE_FAIL();
    }

    // Only add the message if the shutdown succeeded
    if (fResult)
    {
        AddMessage(
            LINE_CALLINFO,
            (DWORD) lpTapiLineTestInfo->hCall2,
            (DWORD) lpCallbackParams,
            LINECALLINFOSTATE_NUMOWNERDECR,
            0x00000000,
            0x00000000,
            TAPIMSG_ALL
            );
    }

    // Wait for the unsolicited message to be sent
    if (! WaitForAllMessages())
    {
        TLINE_FAIL();
    }

    // Shutdown the other line app
    lpTapiLineTestInfo->lphLineApp = &lpTapiLineTestInfo->hLineApp2;
    if (! DoLineShutdown(lpTapiLineTestInfo, TAPISUCCESS))
    {
        TLINE_FAIL();
    }

    fTestPassed = ShowTestCase(fTestPassed);

    // Free the memory taken from the heap
    FreeTestHeap();
*/ 

	 TapiLogDetail(
      DBUG_SHOW_PASS,
      "@@ lineShutdown: 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 lineShutdown  <<<<<<<<"
            );
            
    return fTestPassed;
}