mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-24 00:27:06 +02:00
Turbopower_ipro: some more tests.
This commit is contained in:
parent
a05cbeffee
commit
1515bbf643
@ -10,6 +10,10 @@ uses
|
||||
const
|
||||
LE = LineEnding;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <BR> tag
|
||||
//------------------------------------------------------------------------------
|
||||
const
|
||||
BRinBODY_title =
|
||||
'<BR> between two words in BODY';
|
||||
BRinBODY_html =
|
||||
@ -114,9 +118,26 @@ const
|
||||
BRbetweenTwoP_descr =
|
||||
'There should be an empty line between the two lines.';
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Background color
|
||||
//------------------------------------------------------------------------------
|
||||
const
|
||||
TextWithBackgroundInBODY_title =
|
||||
'Text with background in BODY';
|
||||
TextWithBackgroundInBODY_html =
|
||||
'<html>' + LE +
|
||||
'<body>' + LE +
|
||||
' <font style="background-color: yellow;" color="red">Testing backcolor</font>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
TextWithBackgroundInBODY_descr =
|
||||
'This test should show red text on yellow background.';
|
||||
|
||||
|
||||
TextWithBackgroundInBODY_CSS_title =
|
||||
'Text with background in BODY (with CSS)';
|
||||
TextWithBackgroundInBODY_CSS_html =
|
||||
'<html>' + LE +
|
||||
'<head>' + LE +
|
||||
' <style type="text/css">' + LE +
|
||||
@ -130,7 +151,7 @@ const
|
||||
' <p class="class1">Testing backcolor</p>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
TextWithBackgroundInBODY_descr =
|
||||
TextWithBackgroundInBODY_CSS_descr =
|
||||
'This test should show red text on yellow background.';
|
||||
|
||||
TextInColoredTableCell_title =
|
||||
@ -150,6 +171,108 @@ const
|
||||
TextInColoredTableCell_descr =
|
||||
'The left and center cells should have yellow, the right cell uniform red background.';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Text Alignment
|
||||
//------------------------------------------------------------------------------
|
||||
const
|
||||
AlignInCell_title =
|
||||
'Left-/right-aligned and centered text in a table cell';
|
||||
AlignInCell_descr =
|
||||
'The text in the left, center and right cell should be left-aligned, centered, right-aligned, respectively.';
|
||||
AlignInCell_html =
|
||||
'<html>' + LE +
|
||||
'<body>' + LE +
|
||||
' <table border="1" cellspacing="0">' + LE +
|
||||
' <tr>' + LE +
|
||||
' <th>left</td>' + LE +
|
||||
' <th>centered</td>' + LE +
|
||||
' <th>right</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' <tr>' + LE +
|
||||
' <td align="left">a</td>' + LE +
|
||||
' <td align="center">b</td>' + LE +
|
||||
' <td align="right">c</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' </table>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
|
||||
AlignInCellBold_title =
|
||||
'Left-/right-aligned and centered BOLD text in a table cell';
|
||||
AlignInCellBold_descr =
|
||||
'The text in the left, center and right cell should be left-aligned, centered, right-aligned, respectively.';
|
||||
AlignInCellBold_html =
|
||||
'<html>' + LE +
|
||||
'<body>' + LE +
|
||||
' <table border="1" cellspacing="0">' + LE +
|
||||
' <tr>' + LE +
|
||||
' <th>left</td>' + LE +
|
||||
' <th>centered</td>' + LE +
|
||||
' <th>right</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' <tr>' + LE +
|
||||
' <td align="left"><b>a</b></td>' + LE +
|
||||
' <td align="center"><b>b</b></td>' + LE +
|
||||
' <td align="right"><b>c</b></td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' </table>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
|
||||
AlignInCell_CSS_title =
|
||||
'Left-/right-aligned and centered text in a table cell, using body style';
|
||||
AlignInCell_CSS_descr =
|
||||
'The text in the left, center and right cell should be left-aligned, centered, right-aligned, respectively.';
|
||||
AlignInCell_CSS_html =
|
||||
'<html>' + LE +
|
||||
'<head>' + LE +
|
||||
' <style type="text/css">' + LE +
|
||||
' body { font-size:9pt; font-family:Arial, Helvetica, sans-serif }' + LE +
|
||||
' </style>' + LE +
|
||||
'</head>' + LE +
|
||||
'<body>' + LE +
|
||||
' <table border="1" cellspacing="0" style="font-size:9pt; font-family:Arial, Helvetica, sans-serif;">' + LE +
|
||||
' <tr>' + LE +
|
||||
' <th>left</td>' + LE +
|
||||
' <th>centered</td>' + LE +
|
||||
' <th>right</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' <tr>' + LE +
|
||||
' <td align="left">a</td>' + LE +
|
||||
' <td align="center">b</td>' + LE +
|
||||
' <td align="right">c</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' </table>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
|
||||
AlignInCellBold_CSS_title =
|
||||
'Left-/right-aligned and centered BOLD text in a table cell, using body style';
|
||||
AlignInCellBold_CSS_descr =
|
||||
'The text in the left, center and right cell should be left-aligned, centered, right-aligned, respectively.';
|
||||
AlignInCellBold_CSS_html =
|
||||
'<html>' + LE +
|
||||
'<head>' + LE +
|
||||
' <style type="text/css">' + LE +
|
||||
' body { font-size:9pt; font-family:Arial, Helvetica, sans-serif }' + LE +
|
||||
' </style>' + LE +
|
||||
'</head>' + LE +
|
||||
'<body>' + LE +
|
||||
' <table border="1" cellspacing="0" style="font-size:9pt; font-family:Arial, Helvetica, sans-serif;">' + LE +
|
||||
' <tr>' + LE +
|
||||
' <th>left</td>' + LE +
|
||||
' <th>centered</td>' + LE +
|
||||
' <th>right</td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' <tr>' + LE +
|
||||
' <td align="left"><b>a</b></td>' + LE +
|
||||
' <td align="center"><b>b</b></td>' + LE +
|
||||
' <td align="right"><b>c</b></td>' + LE +
|
||||
' </tr>'+ LE +
|
||||
' </table>' + LE +
|
||||
'</body>' + LE +
|
||||
'</html>';
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -3,6 +3,7 @@ object Form1: TForm1
|
||||
Height = 620
|
||||
Top = 127
|
||||
Width = 866
|
||||
ActiveControl = btnRender
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 620
|
||||
ClientWidth = 866
|
||||
@ -10,15 +11,15 @@ object Form1: TForm1
|
||||
LCLVersion = '2.3.0.0'
|
||||
object Panel1: TPanel
|
||||
Left = 6
|
||||
Height = 608
|
||||
Top = 6
|
||||
Height = 577
|
||||
Top = 37
|
||||
Width = 218
|
||||
Align = alLeft
|
||||
BorderSpacing.Around = 6
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 608
|
||||
ClientHeight = 577
|
||||
ClientWidth = 218
|
||||
TabOrder = 0
|
||||
TabOrder = 1
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
@ -27,6 +28,8 @@ object Form1: TForm1
|
||||
Top = 0
|
||||
Width = 80
|
||||
Caption = 'html file name:'
|
||||
Color = clDefault
|
||||
ParentColor = False
|
||||
end
|
||||
object FileNameEdit1: TFileNameEdit
|
||||
AnchorSideLeft.Control = Panel1
|
||||
@ -45,23 +48,25 @@ object Form1: TForm1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 2
|
||||
MaxLength = 0
|
||||
TabOrder = 0
|
||||
TabOrder = 1
|
||||
end
|
||||
object TreeView1: TTreeView
|
||||
Left = 0
|
||||
Height = 608
|
||||
Height = 577
|
||||
Top = 0
|
||||
Width = 218
|
||||
Align = alClient
|
||||
TabOrder = 1
|
||||
ReadOnly = True
|
||||
TabOrder = 0
|
||||
OnDeletion = TreeView1Deletion
|
||||
OnSelectionChanged = TreeView1SelectionChanged
|
||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 238
|
||||
Height = 608
|
||||
Top = 6
|
||||
Height = 577
|
||||
Top = 37
|
||||
Width = 622
|
||||
Align = alClient
|
||||
BorderSpacing.Left = 3
|
||||
@ -69,9 +74,9 @@ object Form1: TForm1
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Bottom = 6
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 608
|
||||
ClientHeight = 577
|
||||
ClientWidth = 622
|
||||
TabOrder = 1
|
||||
TabOrder = 3
|
||||
object Splitter2: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
@ -83,7 +88,7 @@ object Form1: TForm1
|
||||
end
|
||||
object IpHtmlPanel1: TIpHtmlPanel
|
||||
Left = 0
|
||||
Height = 260
|
||||
Height = 229
|
||||
Top = 348
|
||||
Width = 622
|
||||
Align = alClient
|
||||
@ -100,7 +105,7 @@ object Form1: TForm1
|
||||
PrintSettings.Preview.Top = 270
|
||||
PrintSettings.Preview.Width = 1920
|
||||
PrintSettings.Preview.Height = 810
|
||||
TabOrder = 1
|
||||
TabOrder = 2
|
||||
end
|
||||
object Panel4: TPanel
|
||||
Left = 0
|
||||
@ -111,22 +116,11 @@ object Form1: TForm1
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 340
|
||||
ClientWidth = 622
|
||||
TabOrder = 2
|
||||
object Memo1: TMemo
|
||||
Left = 0
|
||||
Height = 50
|
||||
Top = 0
|
||||
Width = 622
|
||||
Align = alTop
|
||||
BorderSpacing.Bottom = 3
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
WantReturns = False
|
||||
end
|
||||
TabOrder = 0
|
||||
inline SynEdit1: TSynEdit
|
||||
Left = 0
|
||||
Height = 245
|
||||
Top = 61
|
||||
Height = 287
|
||||
Top = 53
|
||||
Width = 622
|
||||
Align = alClient
|
||||
BorderSpacing.Top = 3
|
||||
@ -136,7 +130,7 @@ object Form1: TForm1
|
||||
Font.Quality = fqNonAntialiased
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
TabOrder = 1
|
||||
TabOrder = 2
|
||||
Gutter.Width = 57
|
||||
Gutter.MouseActions = <>
|
||||
RightGutter.Width = 0
|
||||
@ -624,72 +618,87 @@ object Form1: TForm1
|
||||
end
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 312
|
||||
Width = 622
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
BorderSpacing.Bottom = 3
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 25
|
||||
ClientWidth = 622
|
||||
TabOrder = 2
|
||||
object Button1: TButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel3
|
||||
AnchorSideRight.Control = Bevel1
|
||||
Left = 230
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'Render'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button2: TButton
|
||||
AnchorSideLeft.Control = Bevel1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel3
|
||||
Left = 317
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 113
|
||||
AutoSize = True
|
||||
Caption = 'Show in Browser'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
AnchorSideLeft.Control = Panel3
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = 305
|
||||
Height = 13
|
||||
Top = 3
|
||||
Width = 12
|
||||
Shape = bsSpacer
|
||||
end
|
||||
end
|
||||
object Splitter3: TSplitter
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 53
|
||||
Top = 45
|
||||
Width = 622
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
end
|
||||
object Memo1: TMemo
|
||||
Left = 0
|
||||
Height = 42
|
||||
Top = 0
|
||||
Width = 622
|
||||
Align = alTop
|
||||
BorderSpacing.Bottom = 3
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
WantReturns = False
|
||||
end
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 230
|
||||
Height = 620
|
||||
Top = 0
|
||||
Height = 583
|
||||
Top = 37
|
||||
Width = 5
|
||||
end
|
||||
object Panel3: TPanel
|
||||
Left = 6
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 854
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 25
|
||||
ClientWidth = 854
|
||||
TabOrder = 0
|
||||
object btnRender: TButton
|
||||
AnchorSideLeft.Control = btnLoadFromFile
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel3
|
||||
Left = 115
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 75
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'Render'
|
||||
OnClick = btnRenderClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object btnShowInBrowser: TButton
|
||||
AnchorSideLeft.Control = btnRender
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel3
|
||||
Left = 196
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 113
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'Show in Browser'
|
||||
OnClick = btnShowInBrowserClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object btnLoadFromFile: TButton
|
||||
AnchorSideLeft.Control = Panel3
|
||||
AnchorSideTop.Control = Panel3
|
||||
AnchorSideRight.Control = btnRender
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 109
|
||||
AutoSize = True
|
||||
Caption = 'Load from file...'
|
||||
OnClick = btnLoadFromFileClick
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object SynHTMLSyn1: TSynHTMLSyn
|
||||
DefaultFilter = 'HTML Document (*.htm,*.html)|*.htm;*.html'
|
||||
Enabled = False
|
||||
|
@ -13,9 +13,9 @@ type
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
btnRender: TButton;
|
||||
btnShowInBrowser: TButton;
|
||||
btnLoadFromFile: TButton;
|
||||
FileNameEdit1: TFileNameEdit;
|
||||
IpHtmlPanel1: TIpHtmlPanel;
|
||||
Label1: TLabel;
|
||||
@ -30,8 +30,9 @@ type
|
||||
SynEdit1: TSynEdit;
|
||||
SynHTMLSyn1: TSynHTMLSyn;
|
||||
TreeView1: TTreeView;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure btnRenderClick(Sender: TObject);
|
||||
procedure btnShowInBrowserClick(Sender: TObject);
|
||||
procedure btnLoadFromFileClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure TreeView1Deletion(Sender: TObject; Node: TTreeNode);
|
||||
procedure TreeView1SelectionChanged(Sender: TObject);
|
||||
@ -84,12 +85,12 @@ begin
|
||||
TTestCase(Node.Data).Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
procedure TForm1.btnRenderClick(Sender: TObject);
|
||||
begin
|
||||
IpHtmlPanel1.SetHtmlFromStr(SynEdit1.Lines.Text);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
procedure TForm1.btnShowInBrowserClick(Sender: TObject);
|
||||
const
|
||||
TEST_FILE = 'test.html';
|
||||
begin
|
||||
@ -97,6 +98,25 @@ begin
|
||||
OpenURL(TEST_FILE);
|
||||
end;
|
||||
|
||||
procedure TForm1.btnLoadFromFileClick(Sender: TObject);
|
||||
begin
|
||||
with TOpenDialog.Create(nil) do
|
||||
try
|
||||
filter := 'HTML files (*.html; *.htm)|*.html;*.htm';
|
||||
if FileName <> '' then
|
||||
InitialDir := ExtractFileDir(FileName);
|
||||
Options := Options + [ofFileMustExist];
|
||||
if Execute then
|
||||
begin
|
||||
Memo1.Lines.Clear;
|
||||
SynEdit1.Lines.LoadFromFile(FileName);
|
||||
IpHtmlPanel1.SetHtmlFromStr(SynEdit1.Lines.Text);
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.TreeView1SelectionChanged(Sender: TObject);
|
||||
var
|
||||
testcase: TTestCase;
|
||||
@ -138,8 +158,17 @@ begin
|
||||
|
||||
node := TreeView1.Items.AddChild(nil, 'Text background');
|
||||
AddTest(node, TextWithBackgroundInBODY_title, TextWithBackgroundInBODY_descr, TextWithBackgroundInBODY_html);
|
||||
AddTest(node, TextWithBackgroundInBODY_CSS_title, TextWithBackgroundInBODY_CSS_descr, TextWithBackgroundInBODY_CSS_html);
|
||||
AddTest(node, TextInColoredTableCell_title, TextInColoredTableCell_descr, TextInColoredTableCell_html);
|
||||
node.Expanded := true;
|
||||
|
||||
node := TreeView1.Items.AddChild(nil, 'Text alignment');
|
||||
AddTest(node, AlignInCell_title, AlignInCell_descr, AlignInCell_html);
|
||||
AddTest(node, AlignInCellBold_title, AlignInCellBold_descr, AlignInCellBold_html);
|
||||
AddTest(node, AlignInCell_CSS_title, AlignInCell_CSS_descr, AlignInCell_CSS_html);
|
||||
AddTest(node, AlignInCellBold_CSS_title, AlignInCellBold_CSS_descr, AlignInCellBold_CSS_html);
|
||||
node.Expanded := true;
|
||||
|
||||
finally
|
||||
TreeView1.Items.EndUpdate;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user