Skip to content

Commit

Permalink
Tuned test UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlegel81 committed Mar 11, 2023
1 parent 53fbd52 commit 8d7453d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 16 deletions.
13 changes: 9 additions & 4 deletions boardtestunit.lfm
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
object BoardTestForm: TBoardTestForm
Left = 1739
Height = 240
Top = 255
Left = 1205
Height = 393
Top = 500
Width = 320
Caption = 'Schaltung testen'
ClientHeight = 240
ClientHeight = 393
ClientWidth = 320
Position = poOwnerFormCenter
LCLVersion = '2.2.2.0'
inline TestCreationFrame1: TTestCreationFrame
Height = 393
Width = 320
Align = alClient
ClientHeight = 393
ClientWidth = 320
inherited TestInputsPanel: TPanel
Height = 385
Width = 312
ClientHeight = 385
ClientWidth = 312
inherited TestCasesStringGrid: TStringGrid
Height = 333
Width = 292
end
inherited generateTestCasesShape: TShape
Expand Down
7 changes: 7 additions & 0 deletions challenges.pas
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

PROCEDURE setNumberOfTestCases(CONST count:longint);
PROCEDURE generateTestCases(CONST allInputsThenScramble:boolean=false);
PROCEDURE reInitStepCounts;
PROCEDURE updateTestCaseResults;
FUNCTION lastTestCasePrepared:longint;
end;
Expand Down Expand Up @@ -576,6 +577,12 @@
challengeTestCreationThread.restart;
end;

PROCEDURE T_testCreator.reInitStepCounts;
begin
challengeTestCreationThread.ensureStop;
challengeTestCreationThread.initialRun:=true;
end;

PROCEDURE T_testCreator.updateTestCaseResults;
begin
challengeTestCreationThread.restart;
Expand Down
3 changes: 1 addition & 2 deletions compoundgates.pas
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ T_gateInterfaces=record
lastStepBusy:=result;
end;

FUNCTION T_compoundGate.simulateSteps(CONST count: longint;
CONST inputWires: T_wireValueArray; OUT stepsDone: longint): T_wireValueArray;
FUNCTION T_compoundGate.simulateSteps(CONST count: longint; CONST inputWires: T_wireValueArray; OUT stepsDone: longint): T_wireValueArray;
VAR i:longint;
changed:boolean=true;
g: P_abstractGate;
Expand Down
52 changes: 42 additions & 10 deletions testframeui.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ object TestCreationFrame: TTestCreationFrame
Left = 0
Height = 240
Top = 0
Width = 370
Width = 700
ClientHeight = 240
ClientWidth = 370
ClientWidth = 700
Color = 7354424
ParentBackground = False
ParentColor = False
TabOrder = 0
DesignLeft = 510
DesignTop = 119
DesignLeft = 1139
DesignTop = 638
object TestInputsPanel: TPanel
Left = 4
Height = 232
Top = 4
Width = 362
Width = 692
Align = alClient
BorderSpacing.Left = 4
BorderSpacing.Top = 4
BorderSpacing.Right = 4
BorderSpacing.Bottom = 4
BorderWidth = 5
ClientHeight = 232
ClientWidth = 362
ClientWidth = 692
Color = 7354424
ParentColor = False
TabOrder = 0
Expand Down Expand Up @@ -69,7 +69,7 @@ object TestCreationFrame: TTestCreationFrame
Left = 10
Height = 180
Top = 42
Width = 342
Width = 672
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4
BorderSpacing.Top = 4
Expand All @@ -80,7 +80,7 @@ object TestCreationFrame: TTestCreationFrame
FixedCols = 0
Flat = True
Font.Color = clWhite
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goDblClickAutoSize, goSmoothScroll]
ParentFont = False
TabOrder = 1
OnHeaderClick = TestCasesStringGridHeaderClick
Expand All @@ -91,7 +91,7 @@ object TestCreationFrame: TTestCreationFrame
AnchorSideTop.Control = TestInputsPanel
AnchorSideRight.Control = TestInputsPanel
AnchorSideRight.Side = asrBottom
Left = 223
Left = 553
Height = 28
Top = 10
Width = 129
Expand All @@ -109,7 +109,7 @@ object TestCreationFrame: TTestCreationFrame
AnchorSideTop.Control = generateTestCasesShape
AnchorSideTop.Side = asrCenter
AnchorSideRight.Side = asrBottom
Left = 255
Left = 585
Height = 21
Top = 14
Width = 64
Expand All @@ -125,6 +125,38 @@ object TestCreationFrame: TTestCreationFrame
ParentFont = False
OnMouseDown = generateTestCasesShapeMouseDown
end
object StepCountEdit: TEdit
AnchorSideLeft.Control = Label7
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TestInputsPanel
Left = 258
Height = 23
Top = 10
Width = 80
BorderSpacing.Left = 4
BorderSpacing.Top = 4
Color = 7354424
Font.Color = clWhite
NumbersOnly = True
OnEditingDone = StepCountEditEditingDone
ParentFont = False
TabOrder = 2
end
object Label7: TLabel
AnchorSideLeft.Control = TestCaseCountEdit
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TestInputsPanel
Left = 136
Height = 15
Top = 10
Width = 118
BorderSpacing.Left = 10
BorderSpacing.Top = 4
Caption = 'Schritte für alle setzen:'
Font.Color = clWhite
ParentColor = False
ParentFont = False
end
end
object Timer1: TTimer
OnTimer = Timer1Timer
Expand Down
25 changes: 25 additions & 0 deletions testframeui.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ TTestCreationFrame = class(TFrame)
generateTestCasesLabel: TLabel;
generateTestCasesShape: TShape;
Label6: TLabel;
Label7: TLabel;
TestCaseCountEdit: TEdit;
StepCountEdit: TEdit;
TestCasesStringGrid: TStringGrid;
TestInputsPanel: TPanel;
Timer1: TTimer;
PROCEDURE generateTestCasesShapeMouseDown(Sender: TObject; button: TMouseButton; Shift: TShiftState; X, Y: integer);
PROCEDURE StepCountEditEditingDone(Sender: TObject);
PROCEDURE TestCaseCountEditEditingDone(Sender: TObject);
PROCEDURE TestCasesStringGridHeaderClick(Sender: TObject; IsColumn: boolean; index: integer);
PROCEDURE TestCasesStringGridValidateEntry(Sender: TObject; aCol, aRow: integer; CONST oldValue: string; VAR newValue: string);
Expand Down Expand Up @@ -60,6 +63,7 @@ TTestCreationFrame = class(TFrame)
end else begin
testGenerator^.tests[aRow-1].maxTotalSteps:=newStepCount;
lastUpdatedRow:=-1;
//TODO: Restart of test generator is only necessary if editing an editor before (or equal to) the current test step
testGenerator^.updateTestCaseResults;
end;
exit;
Expand All @@ -80,6 +84,8 @@ TTestCreationFrame = class(TFrame)
VAR i, newUpdatedRow: longint;
begin
if testGenerator=nil then exit;
if TestCasesStringGrid.editor.showing then exit;

newUpdatedRow:=testGenerator^.lastTestCasePrepared;
if (newUpdatedRow<>lastUpdatedRow) then begin
if (lastUpdatedRow<0) or (newUpdatedRow<lastUpdatedRow)
Expand Down Expand Up @@ -193,6 +199,25 @@ TTestCreationFrame = class(TFrame)
testGenerator^.generateTestCases;
end;

PROCEDURE TTestCreationFrame.StepCountEditEditingDone(Sender: TObject);
VAR newCount: int64;
i:longint;
begin
newCount:=StrToInt64Def(StepCountEdit.text,-1);
if newCount>maxLongint
then begin
newCount:=maxLongint;
StepCountEdit.text:=intToStr(maxLongint);
end else if (newCount<=0) then begin
StepCountEdit.text:='';
exit;
end;
for i:=0 to length(testGenerator^.tests)-1 do testGenerator^.tests[i].maxTotalSteps:=newCount;
testGenerator^.reInitStepCounts;
testGenerator^.updateTestCaseResults;
lastUpdatedRow:=-1;
end;

PROCEDURE TTestCreationFrame.TestCasesStringGridHeaderClick(Sender: TObject; IsColumn: boolean; index: integer);
CONST nextMode:array[T_multibitWireRepresentation] of T_multibitWireRepresentation=(wr_decimal,wr_2complement,wr_binary);
begin
Expand Down

0 comments on commit 8d7453d

Please sign in to comment.