Changeset 91 for trunk/Forms


Ignore:
Timestamp:
Feb 2, 2022, 4:33:25 PM (3 years ago)
Author:
chronos
Message:
  • Added: A windows for showing log output for selected test case.
  • Added: Various load-save tests.
  • Modified: Improved parsing vCard format.
Location:
trunk/Forms
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormTest.lfm

    r90 r91  
    2222      item
    2323        Caption = 'Name'
    24         Width = 200
     24        Width = 300
    2525      end   
    2626      item
    2727        Caption = 'Result'
    28         Width = 869
     28        Width = 769
    2929      end>
    3030    OwnerData = True
     31    PopupMenu = PopupMenuTest
    3132    ReadOnly = True
    3233    RowSelect = True
     
    3435    ViewStyle = vsReport
    3536    OnData = ListViewTestCasesData
     37    OnDblClick = AShowExecute
     38    OnSelectItem = ListViewTestCasesSelectItem
    3639  end
    3740  object ButtonRun: TButton
     
    4548    TabOrder = 1
    4649  end
     50  object ActionList1: TActionList
     51    Left = 537
     52    Top = 115
     53    object AShow: TAction
     54      Caption = 'Show'
     55      OnExecute = AShowExecute
     56    end
     57    object ARun: TAction
     58      Caption = 'Run'
     59      OnExecute = ARunExecute
     60    end
     61  end
     62  object PopupMenuTest: TPopupMenu
     63    Left = 539
     64    Top = 244
     65    object MenuItem1: TMenuItem
     66      Action = AShow
     67    end
     68    object MenuItem2: TMenuItem
     69      Action = ARun
     70    end
     71  end
    4772end
  • trunk/Forms/UFormTest.lrj

    r90 r91  
    33{"hash":346165,"name":"tformtest.listviewtestcases.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"},
    44{"hash":93105204,"name":"tformtest.listviewtestcases.columns[1].caption","sourcebytes":[82,101,115,117,108,116],"value":"Result"},
    5 {"hash":22974,"name":"tformtest.buttonrun.caption","sourcebytes":[82,117,110],"value":"Run"}
     5{"hash":22974,"name":"tformtest.buttonrun.caption","sourcebytes":[82,117,110],"value":"Run"},
     6{"hash":368487,"name":"tformtest.ashow.caption","sourcebytes":[83,104,111,119],"value":"Show"},
     7{"hash":22974,"name":"tformtest.arun.caption","sourcebytes":[82,117,110],"value":"Run"}
    68]}
  • trunk/Forms/UFormTest.pas

    r90 r91  
    77uses
    88  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
    9   UTest;
     9  ActnList, Menus, UTest;
    1010
    1111type
     
    1414
    1515  TFormTest = class(TForm)
     16    ARun: TAction;
     17    AShow: TAction;
     18    ActionList1: TActionList;
    1619    ButtonRun: TButton;
    1720    ListViewTestCases: TListView;
     21    MenuItem1: TMenuItem;
     22    MenuItem2: TMenuItem;
     23    PopupMenuTest: TPopupMenu;
     24    procedure ARunExecute(Sender: TObject);
     25    procedure AShowExecute(Sender: TObject);
    1826    procedure ButtonRunClick(Sender: TObject);
    1927    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    2230    procedure FormShow(Sender: TObject);
    2331    procedure ListViewTestCasesData(Sender: TObject; Item: TListItem);
     32    procedure ListViewTestCasesSelectItem(Sender: TObject; Item: TListItem;
     33      Selected: Boolean);
    2434  private
    2535    procedure ReloadList;
     36    procedure UpdateInterface;
    2637  public
    2738    TestCases: TTestCases;
     
    3748
    3849uses
    39   UCore;
     50  UCore, UFormTestCase;
    4051
    4152{ TFormTest }
     
    4657  with TestCases[Item.Index] do begin
    4758    Item.Caption := Name;
     59    Item.Data := TestCases[Item.Index];
     60    Item.SubItems.Add(ResultText[Result]);
    4861  end;
     62end;
     63
     64procedure TFormTest.ListViewTestCasesSelectItem(Sender: TObject;
     65  Item: TListItem; Selected: Boolean);
     66begin
     67  UpdateInterface;
    4968end;
    5069
     
    5372  ListViewTestCases.Items.Count := TestCases.Count;
    5473  ListViewTestCases.Refresh;
     74end;
     75
     76procedure TFormTest.UpdateInterface;
     77begin
     78  ARun.Enabled := Assigned(ListViewTestCases.Selected);
     79  AShow.Enabled := Assigned(ListViewTestCases.Selected);
    5580end;
    5681
     
    6691  for I := 0 to TestCases.Count - 1 do
    6792    TestCases[I].Run;
     93  ReloadList;
     94end;
     95
     96procedure TFormTest.AShowExecute(Sender: TObject);
     97begin
     98  if Assigned(ListViewTestCases.Selected) then
     99  with TFormTestCase.Create(nil) do
     100  try
     101    MemoLog.Text := TTestCase(ListViewTestCases.Selected.Data).Log;
     102    ShowModal;
     103  finally
     104    Free;
     105  end;
     106end;
     107
     108procedure TFormTest.ARunExecute(Sender: TObject);
     109begin
     110  if Assigned(ListViewTestCases.Selected) then begin
     111    TTestCase(ListViewTestCases.Selected.Data).Run;
     112    ReloadList;
     113  end;
    68114end;
    69115
     
    72118  TestCases := TTestCases.Create;
    73119  with TestCases do begin
    74     AddNew('Load and save');
    75     AddNew('Multi-line');
    76     AddNew('Encoding base64');
    77     AddNew('Encoding quoted-printable');
    78     AddNew('Image format');
     120    with TTestCaseLoadSave(AddNew('Load and save', TTestCaseLoadSave)) do begin
     121      Input := 'BEGIN:VCARD' + LineEnding +
     122        'VERSION:2.1' + LineEnding +
     123        'N:Surname;Name' + LineEnding +
     124        'FN:Name Surname' + LineEnding +
     125        'END:VCARD' + LineEnding;
     126      Output := Input;
     127    end;
     128    with TTestCaseLoadSave(AddNew('Multi-line', TTestCaseLoadSave)) do begin
     129      Input := 'BEGIN:VCARD' + LineEnding +
     130        'VERSION:2.1' + LineEnding +
     131        'NOTE:This is some long test which is really multi-lined\neach line\nis on' + LineEnding +
     132        ' different\nline so it is on multiple\nlines.'  + LineEnding +
     133        'END:VCARD' + LineEnding;
     134      Output := Input;
     135    end;
     136    AddNew('Encoding base64', TTestCaseLoadSave);
     137    AddNew('Encoding quoted-printable', TTestCaseLoadSave);
     138    AddNew('Image format', TTestCaseLoadSave);
     139    with TTestCaseLoadSave(AddNew('Empty', TTestCaseLoadSave)) do begin
     140      Input := '';
     141      Output := '';
     142    end;
     143    with TTestCaseLoadSave(AddNew('Begin only', TTestCaseLoadSave)) do begin
     144      Input := 'BEGIN:VCARD';
     145      Output := '';
     146    end;
     147    with TTestCaseLoadSave(AddNew('Missing end', TTestCaseLoadSave)) do begin
     148      Input := 'BEGIN:VCARD' + LineEnding +
     149        'VERSION:2.1' + LineEnding +
     150        'N:Surname;Name' + LineEnding +
     151        'FN:Name Surname' + LineEnding;
     152      Output := '';
     153    end;
    79154  end;
    80155end;
     
    89164  Core.PersistentForm1.Load(Self);
    90165  ReloadList;
     166  UpdateInterface;
    91167end;
    92168
Note: See TracChangeset for help on using the changeset viewer.