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

Comparing ibx/trunk/fbintf/testsuite/Test10.pas (file contents):
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 224 by tony, Mon Mar 19 10:53:56 2018 UTC

# Line 1 | Line 1
1   unit Test10;
2 + {$IFDEF MSWINDOWS}
3 + {$DEFINE WINDOWS}
4 + {$ENDIF}
5  
6 < {$mode objfpc}{$H+}
6 > {$IFDEF FPC}
7 > {$mode delphi}
8   {$codepage utf8}
9 + {$ENDIF}
10  
11   {Test 10: Event Handling}
12  
# Line 36 | Line 41 | type
41      FEventSignalled: boolean;
42      procedure EventsTest(Attachment: IAttachment);
43      procedure EventReport(Sender: IEvents);
44 +    procedure ShowEventReport;
45      procedure ShowEventCounts(Intf: IEvents);
46    public
47 <    function TestTitle: string; override;
48 <    procedure RunTest(CharSet: string; SQLDialect: integer); override;
47 >    function TestTitle: AnsiString; override;
48 >    procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override;
49    end;
50  
51  
# Line 58 | Line 64 | begin
64    FEventSignalled := false;
65    EventHandler := Attachment.GetEventHandler('TESTEVENT');
66    writeln(OutFile,'Call Async Wait');
67 <  EventHandler.AsyncWaitForEvent(@EventReport);
67 >  EventHandler.AsyncWaitForEvent(EventReport);
68    writeln(OutFile,'Async Wait Called');
69    sleep(500);
70 +  CheckSynchronize;
71    if FEventSignalled then
72    begin
73      writeln(OutFile,'First Event - usually ignored');
74      FEventSignalled := false;
75 <    EventHandler.AsyncWaitForEvent(@EventReport);
75 >    EventHandler.AsyncWaitForEvent(EventReport);
76      sleep(100);
77 +    CheckSynchronize;
78      if FEventSignalled then
79      begin
80        writeln(OutFile,'Unexpected Event 1');
# Line 88 | Line 96 | begin
96      FEventSignalled := false
97    end;
98    writeln(OutFile,'Call Async Wait');
99 <  EventHandler.AsyncWaitForEvent(@EventReport);
99 >  EventHandler.AsyncWaitForEvent(EventReport);
100    writeln(OutFile,'Async Wait Called');
101    sleep(500);
102 +  CheckSynchronize;
103    if FEventSignalled then
104    begin
105      writeln(OutFile,'Deferred Events Caught');
106      ShowEventCounts(EventHandler);
107      FEventSignalled := false;
108 <    EventHandler.AsyncWaitForEvent(@EventReport);
108 >    EventHandler.AsyncWaitForEvent(EventReport);
109 >    CheckSynchronize;
110      sleep(100);
111      if FEventSignalled then
112        writeln(OutFile,'Unexpected Event 3');
# Line 108 | Line 118 | begin
118  
119    FEventSignalled := false;
120    writeln(OutFile,'Async Wait: Test Cancel');
121 <  EventHandler.AsyncWaitForEvent(@EventReport);
121 >  EventHandler.AsyncWaitForEvent(EventReport);
122 >  CheckSynchronize;
123    writeln(OutFile,'Async Wait Called');
124    EventHandler.Cancel;
125    writeln(OutFile,'Event Cancelled');
# Line 121 | Line 132 | begin
132      writeln(OutFile,'Event called - so Cancel failed');
133  
134    writeln(OutFile,'Sync wait');
135 +  CheckSynchronize;
136    Attachment.ExecImmediate([isc_tpb_write,isc_tpb_nowait,isc_tpb_concurrency],sqlEvent);
137    EventHandler.WaitForEvent;
138    writeln(OutFile,'Event Signalled');
139    ShowEventCounts(EventHandler);
140    EventHandler := nil;
141 +  CheckSynchronize;
142   end;
143  
144   procedure TTest10.EventReport(Sender: IEvents);
145   begin
146    FEventSignalled := true;
147 +  TThread.Synchronize(nil,ShowEventReport);
148 + end;
149 +
150 + procedure TTest10.ShowEventReport;
151 + begin
152    writeln(OutFile,'Event Signalled');
153   end;
154  
# Line 144 | Line 162 | begin
162      writeln(OutFile,'Event Counts: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count);
163   end;
164  
165 < function TTest10.TestTitle: string;
165 > function TTest10.TestTitle: AnsiString;
166   begin
167    Result := 'Test 10: Event Handling';
168   end;
169  
170 < procedure TTest10.RunTest(CharSet: string; SQLDialect: integer);
170 > procedure TTest10.RunTest(CharSet: AnsiString; SQLDialect: integer);
171   var Attachment: IAttachment;
172      DPB: IDPB;
173   begin

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines