ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/testsuite/Test10.pas
(Generate patch)

Comparing ibx/trunk/fbintf/testsuite/Test10.pas (file contents):
Revision 46 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC

# Line 36 | Line 36 | type
36      FEventSignalled: boolean;
37      procedure EventsTest(Attachment: IAttachment);
38      procedure EventReport(Sender: IEvents);
39 +    procedure ShowEventCounts(Intf: IEvents);
40    public
41      function TestTitle: string; override;
42      procedure RunTest(CharSet: string; SQLDialect: integer); override;
# Line 51 | Line 52 | const
52  
53   procedure TTest10.EventsTest(Attachment: IAttachment);
54   var EventHandler: IEvents;
54    EventCounts: TEventCounts;
55      i: integer;
56      WaitCount: integer;
57   begin
58 +  FEventSignalled := false;
59    EventHandler := Attachment.GetEventHandler('TESTEVENT');
60    writeln(OutFile,'Call Async Wait');
61    EventHandler.AsyncWaitForEvent(@EventReport);
62    writeln(OutFile,'Async Wait Called');
63 <
63 >  sleep(500);
64 >  if FEventSignalled then
65 >  begin
66 >    writeln(OutFile,'First Event - usually ignored');
67 >    FEventSignalled := false;
68 >    EventHandler.AsyncWaitForEvent(@EventReport);
69 >    sleep(100);
70 >    if FEventSignalled then
71 >    begin
72 >      writeln(OutFile,'Unexpected Event 1');
73 >      Exit;
74 >    end;
75 >  end;
76    writeln(OutFile,'Signal Event');
77    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
78 <  while not FEventSignalled do;
79 <  writeln(OutFile,'Event Signalled');
67 <  EventCounts := EventHandler.ExtractEventCounts;
68 <  for i := 0 to length(EventCounts) - 1 do
69 <    writeln(OutFile,'Event: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count);
78 >  while not FEventSignalled do Sleep(50);
79 >  ShowEventCounts(EventHandler);
80    FEventSignalled := false;
81  
82    writeln(OutFile,'Two more events');
83    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
84    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
85 +  if FEventSignalled then
86 +  begin
87 +    writeln(OutFile,'Unexpected Event 2');
88 +    FEventSignalled := false
89 +  end;
90    writeln(OutFile,'Call Async Wait');
91    EventHandler.AsyncWaitForEvent(@EventReport);
92    writeln(OutFile,'Async Wait Called');
93 +  sleep(500);
94 +  if FEventSignalled then
95 +  begin
96 +    writeln(OutFile,'Deferred Events Caught');
97 +    ShowEventCounts(EventHandler);
98 +    FEventSignalled := false;
99 +    EventHandler.AsyncWaitForEvent(@EventReport);
100 +    sleep(100);
101 +    if FEventSignalled then
102 +      writeln(OutFile,'Unexpected Event 3');
103 +  end;
104    writeln(OutFile,'Signal Event');
105    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
106    while not FEventSignalled do;
107 <  writeln(OutFile,'Event Signalled');
82 <  EventCounts := EventHandler.ExtractEventCounts;
83 <  for i := 0 to length(EventCounts) - 1 do
84 <    writeln(OutFile,'Event: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count);
107 >  ShowEventCounts(EventHandler);
108  
109    FEventSignalled := false;
110    writeln(OutFile,'Async Wait: Test Cancel');
111    EventHandler.AsyncWaitForEvent(@EventReport);
112    writeln(OutFile,'Async Wait Called');
113    EventHandler.Cancel;
114 +  writeln(OutFile,'Event Cancelled');
115 +  FEventSignalled := false;
116    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
117    WaitCount := 100000000;
118    while not FEventSignalled and (WaitCount > 0) do Dec(WaitCount);
# Line 99 | Line 124 | begin
124    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
125    EventHandler.WaitForEvent;
126    writeln(OutFile,'Event Signalled');
127 <  EventCounts := EventHandler.ExtractEventCounts;
128 <  for i := 0 to length(EventCounts) - 1 do
104 <    writeln(OutFile,'Event: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count);
127 >  ShowEventCounts(EventHandler);
128 >  EventHandler := nil;
129   end;
130  
131   procedure TTest10.EventReport(Sender: IEvents);
132   begin
133    FEventSignalled := true;
134 +  writeln(OutFile,'Event Signalled');
135 + end;
136 +
137 + procedure TTest10.ShowEventCounts(Intf: IEvents);
138 + var
139 +  i: integer;
140 +  EventCounts: TEventCounts;
141 + begin
142 +  EventCounts := Intf.ExtractEventCounts;
143 +  for i := 0 to length(EventCounts) - 1 do
144 +    writeln(OutFile,'Event Counts: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count);
145   end;
146  
147   function TTest10.TestTitle: string;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines