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
|
unit regfpguitestrunner;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, lazideintf, ProjectIntf, Controls, Forms;
Type
{ TfpGUITestRunnerProjectDescriptor }
TfpGUITestRunnerProjectDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject) : TModalResult; override;
function CreateStartFiles(AProject: TLazProject) : TModalResult; override;
published
{ Published declarations }
end;
var
fpGUIFTestRunnerProjectDescriptor : TfpGUITestRunnerProjectDescriptor;
procedure Register;
implementation
{$define uselazideintf}
{$ifdef uselazideintf}
uses FPCUnitLazIDEIntf;
{$endif}
procedure Register;
begin
fpGUIFTestRunnerProjectDescriptor:=TfpGUITestRunnerProjectDescriptor.Create;
RegisterProjectDescriptor(fpGUIFTestRunnerProjectDescriptor);
end;
{ TfpGUITestRunnerProjectDescriptor }
constructor TfpGUITestRunnerProjectDescriptor.Create;
begin
inherited Create;
Name:='FPCUnit fpGUI Application';
end;
function TfpGUITestRunnerProjectDescriptor.GetLocalizedName: string;
begin
Result:='FPGUITestRunner';
end;
function TfpGUITestRunnerProjectDescriptor.GetLocalizedDescription: string;
begin
Result:='FPCUnit test runner application using a fpGUI front-end';
end;
function TfpGUITestRunnerProjectDescriptor.InitProject(AProject: TLazProject
): TModalResult;
Var
L : TStrings;
MainFile: TLazProjectFile;
begin
inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('fpcunitproject1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
L:=TStringList.Create;
try
With L do
begin
Add('program fpcunitproject1;');
Add('');
Add('{$mode objfpc}{$H+}');
Add('');
Add('uses');
Add(' {$IFDEF UNIX}{$IFDEF UseCThreads}');
Add(' cthreads,');
Add(' {$ENDIF}{$ENDIF}');
Add(' Classes,');
Add(' fpg_main, fpg_guitestrunner;');
Add('');
Add('procedure MainProc;');
Add('');
Add('var');
Add(' frm: TGUITestRunnerForm;');
Add('');
Add('begin');
Add(' fpgApplication.Initialize;');
Add(' frm := TGUITestRunnerForm.Create(nil);');
Add(' try');
Add(' frm.Show;');
Add(' fpgApplication.Run;');
Add(' finally');
Add(' frm.Free;');
Add(' end;');
Add('end;');
Add('');
Add('begin');
Add(' MainProc;');
Add('end.');
end;
AProject.MainFile.SetSourceText(L.text);
finally
L.Free;
end;
// add dependencies
AProject.AddPackageDependency('FCL');
AProject.AddPackageDependency('guitestrunner_fpgui');
// Don't know if this is needed, actually.
// AProject.AddPackageDependency('FPCUnitTestRunner');
Result:=mrOK;
end;
function TfpGUITestRunnerProjectDescriptor.CreateStartFiles(
AProject: TLazProject): TModalResult;
begin
{$ifdef uselazideintf}
LazarusIDE.DoNewEditorFile(FileDescriptorFPCUnitTestCase,'','',
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
{$endif}
Result:=mrOK;
end;
end.
|