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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
unit TestDbgControlForm;
{$mode objfpc}{$H+}
interface
uses
Interfaces, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
EditBtn, ComCtrls, CheckLst, TestDbgControl, TestDbgConfig,
TTestDbgExecuteables;
type
{ TDbgTestControlForm }
TDbgTestControlForm = class(TForm)
chkDbg: TTreeView;
chkFpc: TTreeView;
chkSym: TCheckListBox;
chkBit: TCheckListBox;
CheckWriteLogs: TCheckBox;
chkTests: TTreeView;
Edit1: TEdit;
EditLogDir: TFileNameEdit;
ilNodeStates: TImageList;
Label1: TLabel;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Splitter1: TSplitter;
Splitter2: TSplitter;
Splitter3: TSplitter;
ToolBar1: TToolBar;
ToolBar2: TToolBar;
ToolBar4: TToolBar;
btnTestAll: TToolButton;
btnTestNone: TToolButton;
btnFpcAll: TToolButton;
btnFpcNone: TToolButton;
btnGdbAll: TToolButton;
btnGdbNone: TToolButton;
WriteLogsOnErr: TCheckBox;
procedure btnFpcAllClick(Sender: TObject);
procedure btnFpcNoneClick(Sender: TObject);
procedure btnGdbAllClick(Sender: TObject);
procedure btnGdbNoneClick(Sender: TObject);
procedure btnTestAllClick(Sender: TObject);
procedure btnTestNoneClick(Sender: TObject);
procedure CheckWriteLogsChange(Sender: TObject);
procedure chkTestsMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
FWriteLogValCache: TWriteLogConfig;
FWriteLogIsCached: Boolean;
public
procedure DbgShow(Data: PtrInt);
end;
var
DbgTestControlForm: TDbgTestControlForm;
function CanCpuBits(b: TCpuBitType): Boolean;
function CanSymType(s: TSymbolType): Boolean;
function CanCompiler(name: string): Boolean;
function CanDebugger(name: string): Boolean;
function CanTest(id: Pointer): Boolean;
function GetTestPattern: string;
procedure SetLogPath(path: string);
function GetLogPath: string;
function GetWriteLog: TWriteLogConfig;
procedure RegisterCompiler(name: string);
procedure RegisterDebugger(name: string);
function RegisterTest(Name: String; Parent: Pointer = nil): Pointer;
implementation
type
TTreeNodeState=(tsUnChecked, tsChecked);
function CanCpuBits(b: TCpuBitType): Boolean;
begin
Result := DbgTestControlForm.chkBit.Checked[ord(b)];
end;
function CanSymType(s: TSymbolType): Boolean;
begin
Result := DbgTestControlForm.chkSym.Checked[ord(s)];
end;
function CanCompiler(name: string): Boolean;
var
i: Integer;
begin
i := DbgTestControlForm.chkFpc.Items.Count - 1;
while i >= 0 do begin
if DbgTestControlForm.chkFpc.Items[i].Text = name then begin
Result := DbgTestControlForm.chkFpc.Items[i].StateIndex = ord(tsChecked);
exit;
end;
dec(i);
end;
Result := False;
end;
function CanDebugger(name: string): Boolean;
var
i: Integer;
begin
i := DbgTestControlForm.chkDbg.Items.Count - 1;
while i >= 0 do begin
if DbgTestControlForm.chkDbg.Items[i].Text = name then begin
Result := DbgTestControlForm.chkDbg.Items[i].StateIndex = ord(tsChecked);
exit;
end;
dec(i);
end;
Result := False;
end;
function CanTest(id: Pointer): Boolean;
begin
Result := TTreeNode(id).StateIndex = ord(tsChecked);
while Result and (TTreeNode(id).Parent <> nil) do begin
id := TTreeNode(id).Parent;
Result := Result and (TTreeNode(id).StateIndex = ord(tsChecked));
end;
end;
function GetTestPattern: string;
begin
Result := DbgTestControlForm.Edit1.Text;
end;
procedure SetLogPath(path: string);
begin
DbgTestControlForm.EditLogDir.Text := path;
end;
function GetLogPath: string;
begin
Result := DbgTestControlForm.EditLogDir.Text;
end;
function GetWriteLog: TWriteLogConfig;
begin
if DbgTestControlForm.FWriteLogIsCached then begin
Result := DbgTestControlForm.FWriteLogValCache;
exit;
end;
Result := wlNever;
if DbgTestControlForm.WriteLogsOnErr.Checked then
Result := wlOnError;
if DbgTestControlForm.CheckWriteLogs.Checked then
Result := wlAlways;
DbgTestControlForm.FWriteLogValCache := Result;
DbgTestControlForm.FWriteLogIsCached := True;
end;
procedure RegisterCompiler(name: string);
begin
DbgTestControlForm.chkFpc.Items.Add(nil, Name)
.StateIndex := ord(tsChecked);
DbgTestControlForm.chkFpc.FullExpand;
end;
procedure RegisterDebugger(name: string);
begin
DbgTestControlForm.chkDbg.Items.Add(nil, name)
.StateIndex := ord(tsChecked);
DbgTestControlForm.chkDbg.FullExpand;
end;
function RegisterTest(Name: String; Parent: Pointer): Pointer;
begin
Result := Pointer(DbgTestControlForm.chkTests.Items.AddChild(TTreeNode(Parent), name));
TTreeNode(Result).StateIndex := ord(tsChecked);
if Parent <> nil then
DbgTestControlForm.chkTests.FullExpand;
end;
{$R *.lfm}
{ TDbgTestControlForm }
procedure TDbgTestControlForm.chkTestsMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
lNode: TTreeNode;
ht: THitTests;
begin
ht := (Sender as TTreeview).GetHitTestInfoAt(X, Y);
if ht * [htOnStateIcon, htOnLabel] = [] then exit;
lNode := (Sender as TTreeview).GetNodeAt(X, Y);
if lNode <> nil then
case lNode.StateIndex of
0: lNode.StateIndex := 1;
1: lNode.StateIndex := 0;
end;
end;
procedure TDbgTestControlForm.btnFpcAllClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkFpc.Items.Count - 1 do
DbgTestControlForm.chkFpc.Items[i].StateIndex := ord(tsChecked);
end;
procedure TDbgTestControlForm.btnFpcNoneClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkFpc.Items.Count - 1 do
DbgTestControlForm.chkFpc.Items[i].StateIndex := ord(tsUnChecked);
end;
procedure TDbgTestControlForm.btnGdbAllClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkDbg.Items.Count - 1 do
DbgTestControlForm.chkDbg.Items[i].StateIndex := ord(tsChecked);
end;
procedure TDbgTestControlForm.btnGdbNoneClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkDbg.Items.Count - 1 do
DbgTestControlForm.chkDbg.Items[i].StateIndex := ord(tsUnChecked);
end;
procedure TDbgTestControlForm.btnTestAllClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkTests.Items.Count - 1 do
DbgTestControlForm.chkTests.Items[i].StateIndex := ord(tsChecked);
end;
procedure TDbgTestControlForm.btnTestNoneClick(Sender: TObject);
var
i: Integer;
begin
for i := 0 to DbgTestControlForm.chkTests.Items.Count - 1 do
DbgTestControlForm.chkTests.Items[i].StateIndex := ord(tsUnChecked);
end;
procedure TDbgTestControlForm.CheckWriteLogsChange(Sender: TObject);
begin
FWriteLogIsCached := False;
end;
procedure TDbgTestControlForm.DbgShow(Data: PtrInt);
var
s: TSymbolType;
b: TCpuBitType;
t: String;
begin
for s := low(TSymbolType) to high(TSymbolType) do begin
WriteStr(t, s);
chkSym.AddItem(t, nil);
end;
chkSym.CheckAll(cbChecked);
for b := low(TCpuBitType) to high(TCpuBitType) do begin
WriteStr(t, b);
chkBit.AddItem(t, nil);
end;
chkBit.CheckAll(cbChecked);
Show;
end;
initialization
DbgTestControlForm := TDbgTestControlForm.Create(Application);
Application.QueueAsyncCall(@DbgTestControlForm.DbgShow, 0);
CanCpuBitsProc := @CanCpuBits;
CanSymTypeProc := @CanSymType;
CanCompilerProc := @CanCompiler;
CanDebuggerProc := @CanDebugger;
CanTestProc := @CanTest;
GetTestPatternProc := @GetTestPattern;
SetLogPathProc := @SetLogPath;
GetLogPathProc := @GetLogPath;
GetWriteLogProc := @GetWriteLog;
RegisterCompilerProc := @RegisterCompiler;
RegisterDebuggerProc := @RegisterDebugger;
RegisterTestProc := @RegisterTest;
end.
|