2009-09-01 00:37:28 -04:00
|
|
|
unit TestUnit;
|
2009-08-28 18:19:25 -04:00
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2009-09-01 00:37:28 -04:00
|
|
|
StdCtrls, Client, MufasaTypes;
|
2009-08-28 18:19:25 -04:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
|
|
|
Button1: TButton;
|
|
|
|
procedure Button1Click(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ private declarations }
|
|
|
|
public
|
|
|
|
{ public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
type
|
|
|
|
TMyThread = class(TThread)
|
|
|
|
private
|
|
|
|
protected
|
|
|
|
procedure Execute; override;
|
|
|
|
public
|
|
|
|
Constructor Create(CreateSuspended : boolean);
|
|
|
|
end;
|
2009-08-28 18:19:25 -04:00
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
constructor TMyThread.Create(CreateSuspended : boolean);
|
|
|
|
begin
|
|
|
|
FreeOnTerminate := True;
|
|
|
|
inherited Create(CreateSuspended);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TMyThread.Execute;
|
2009-08-28 18:19:25 -04:00
|
|
|
Var
|
|
|
|
Client: TClient;
|
2009-09-01 00:37:28 -04:00
|
|
|
w,h, x, y, xx, yy:integer;
|
2009-08-31 21:42:05 -04:00
|
|
|
bmp: TBitmap;
|
2009-09-01 00:37:28 -04:00
|
|
|
ptr: PRGB32;
|
2009-08-31 21:42:05 -04:00
|
|
|
|
2009-08-28 18:19:25 -04:00
|
|
|
begin
|
2009-09-02 18:40:01 -04:00
|
|
|
while (not Terminated) do
|
|
|
|
begin
|
2009-08-28 18:19:25 -04:00
|
|
|
Client := TClient.Create;
|
|
|
|
Client.MWindow.GetDimensions(w, h);
|
|
|
|
writeln(inttostr(w) + ' , ' + inttostr(h));
|
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
//Client.MWindow.SetTarget(77736320);
|
2009-09-02 01:16:29 -04:00
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h);
|
2009-08-31 21:42:05 -04:00
|
|
|
bmp.SaveToFile('/tmp/test.bmp');
|
|
|
|
bmp.Free;
|
2009-09-02 18:40:01 -04:00
|
|
|
|
2009-09-02 01:16:29 -04:00
|
|
|
//Sleep(1000);
|
2009-09-02 18:40:01 -04:00
|
|
|
Client.MInput.GetMousePos(x, y);
|
|
|
|
writeln(inttostr(x) + ' , ' + inttostr(y));
|
2009-08-31 21:42:05 -04:00
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
Client.MInput.SetMousePos(50, 50);
|
2009-09-01 00:37:28 -04:00
|
|
|
Client.MInput.GetMousePos(x, y);
|
2009-09-02 18:40:01 -04:00
|
|
|
writeln(inttostr(x) + ' , ' + inttostr(y));
|
2009-09-01 00:37:28 -04:00
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
Client.MInput.ClickMouse(60, 60, mouse_Right);
|
2009-09-01 00:37:28 -04:00
|
|
|
|
2009-09-02 18:40:01 -04:00
|
|
|
ptr := Client.MWindow.ReturnData(0, 0, w, h);
|
2009-09-01 00:37:28 -04:00
|
|
|
for yy := 0 to h - 1 do
|
|
|
|
for xx := 0 to w - 1 do
|
|
|
|
begin
|
|
|
|
{ Do comparison here }
|
|
|
|
inc(ptr);
|
|
|
|
end;
|
2009-09-02 18:40:01 -04:00
|
|
|
Client.MWindow.FreeReturnData;
|
2009-09-02 01:16:29 -04:00
|
|
|
|
|
|
|
Client.MInput.IsMouseButtonDown(mouse_Left);
|
|
|
|
Sleep(1000);
|
|
|
|
if Client.MInput.IsMouseButtonDown(mouse_Left) then
|
|
|
|
writeln('Left mouse is down!');
|
|
|
|
if Client.MInput.IsMouseButtonDown(mouse_Right) then
|
|
|
|
writeln('Right mouse is down!');
|
|
|
|
if Client.MInput.IsMouseButtonDown(mouse_Middle) then
|
|
|
|
writeln('Middle mouse is down!');
|
2009-08-28 18:19:25 -04:00
|
|
|
Client.Destroy;
|
2009-09-01 00:37:28 -04:00
|
|
|
writeln('Test completed successfully');
|
2009-09-02 18:40:01 -04:00
|
|
|
break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
procedure TForm1.Button1Click(Sender: TObject);
|
|
|
|
Var
|
|
|
|
MyThread: TMyThread;
|
|
|
|
|
|
|
|
begin
|
|
|
|
MyThread := TMyThread.Create(True);
|
|
|
|
MyThread.Resume;
|
2009-08-28 18:19:25 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
2009-09-01 11:50:09 -04:00
|
|
|
{$I testunit.lrs}
|
2009-08-28 18:19:25 -04:00
|
|
|
|
|
|
|
end.
|
|
|
|
|