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 |
|
|
43 |
|
procedure EventReport(Sender: IEvents); |
44 |
|
procedure ShowEventCounts(Intf: IEvents); |
45 |
|
public |
46 |
< |
function TestTitle: string; override; |
47 |
< |
procedure RunTest(CharSet: string; SQLDialect: integer); override; |
46 |
> |
function TestTitle: AnsiString; override; |
47 |
> |
procedure RunTest(CharSet: AnsiString; SQLDialect: integer); override; |
48 |
|
end; |
49 |
|
|
50 |
|
|
63 |
|
FEventSignalled := false; |
64 |
|
EventHandler := Attachment.GetEventHandler('TESTEVENT'); |
65 |
|
writeln(OutFile,'Call Async Wait'); |
66 |
< |
EventHandler.AsyncWaitForEvent(@EventReport); |
66 |
> |
EventHandler.AsyncWaitForEvent(EventReport); |
67 |
|
writeln(OutFile,'Async Wait Called'); |
68 |
|
sleep(500); |
69 |
|
if FEventSignalled then |
70 |
|
begin |
71 |
|
writeln(OutFile,'First Event - usually ignored'); |
72 |
|
FEventSignalled := false; |
73 |
< |
EventHandler.AsyncWaitForEvent(@EventReport); |
73 |
> |
EventHandler.AsyncWaitForEvent(EventReport); |
74 |
|
sleep(100); |
75 |
|
if FEventSignalled then |
76 |
|
begin |
93 |
|
FEventSignalled := false |
94 |
|
end; |
95 |
|
writeln(OutFile,'Call Async Wait'); |
96 |
< |
EventHandler.AsyncWaitForEvent(@EventReport); |
96 |
> |
EventHandler.AsyncWaitForEvent(EventReport); |
97 |
|
writeln(OutFile,'Async Wait Called'); |
98 |
|
sleep(500); |
99 |
|
if FEventSignalled then |
101 |
|
writeln(OutFile,'Deferred Events Caught'); |
102 |
|
ShowEventCounts(EventHandler); |
103 |
|
FEventSignalled := false; |
104 |
< |
EventHandler.AsyncWaitForEvent(@EventReport); |
104 |
> |
EventHandler.AsyncWaitForEvent(EventReport); |
105 |
|
sleep(100); |
106 |
|
if FEventSignalled then |
107 |
|
writeln(OutFile,'Unexpected Event 3'); |
113 |
|
|
114 |
|
FEventSignalled := false; |
115 |
|
writeln(OutFile,'Async Wait: Test Cancel'); |
116 |
< |
EventHandler.AsyncWaitForEvent(@EventReport); |
116 |
> |
EventHandler.AsyncWaitForEvent(EventReport); |
117 |
|
writeln(OutFile,'Async Wait Called'); |
118 |
|
EventHandler.Cancel; |
119 |
|
writeln(OutFile,'Event Cancelled'); |
149 |
|
writeln(OutFile,'Event Counts: ',EventCounts[i].EventName,', Count = ',EventCounts[i].Count); |
150 |
|
end; |
151 |
|
|
152 |
< |
function TTest10.TestTitle: string; |
152 |
> |
function TTest10.TestTitle: AnsiString; |
153 |
|
begin |
154 |
|
Result := 'Test 10: Event Handling'; |
155 |
|
end; |
156 |
|
|
157 |
< |
procedure TTest10.RunTest(CharSet: string; SQLDialect: integer); |
157 |
> |
procedure TTest10.RunTest(CharSet: AnsiString; SQLDialect: integer); |
158 |
|
var Attachment: IAttachment; |
159 |
|
DPB: IDPB; |
160 |
|
begin |